Graphql-js: Flow errors after graphql upgrade

Created on 18 Jul 2017  路  10Comments  路  Source: graphql/graphql-js

I upgraded graphql from 0.9.6 to 0.10.5 (but the problem occurs from 0.10.0) and I'm getting similar errors mentioned here #878.

Everything was fine with [email protected] and [email protected] but upgrade cause errors and higher flow-bin versions didn't helped.

export default {
  type: GraphQLBooking,
  description: 'Flight booking by ID.',
  args: {
    id: {
      type: new GraphQLNonNull(GraphQLID),
    },
    ...
};

The errors occur on GraphQLNonNull. When I remove it, it's ok _(type: new GraphQLID,)_.
The errors I get on flow check:

src/queries/RootQuery.js:10
                    v----------------------
 10: export default new GraphQLObjectType({
 11:   name: 'RootQuery',
 12:   description: 'Root Query',
...:
 19: });
     -^ constructor call
 14:       type: new GraphQLNonNull(GraphQLID),
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ GraphQLNonNull. This type is incompatible with. See: src/queries/Booking.js:14
661:   type: GraphQLInputType;
             ^^^^^^^^^^^^^^^^ union: GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | type application of class `GraphQLList` | type application of class `GraphQLNonNull`. See: node_modules/graphql/type/definition.js.flow:661
  Member 1:
   74:   GraphQLScalarType |
         ^^^^^^^^^^^^^^^^^ GraphQLScalarType. See: node_modules/graphql/type/definition.js.flow:74
  Error:
   14:       type: new GraphQLNonNull(GraphQLID),
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ GraphQLNonNull. This type is incompatible with. See: src/queries/Booking.js:14
   74:   GraphQLScalarType |
         ^^^^^^^^^^^^^^^^^ GraphQLScalarType. See: node_modules/graphql/type/definition.js.flow:74
  Member 2:
   75:   GraphQLEnumType |
         ^^^^^^^^^^^^^^^ GraphQLEnumType. See: node_modules/graphql/type/definition.js.flow:75
  Error:
   14:       type: new GraphQLNonNull(GraphQLID),
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ GraphQLNonNull. This type is incompatible with. See: src/queries/Booking.js:14
   75:   GraphQLEnumType |
         ^^^^^^^^^^^^^^^ GraphQLEnumType. See: node_modules/graphql/type/definition.js.flow:75
  Member 3:
   76:   GraphQLInputObjectType |
         ^^^^^^^^^^^^^^^^^^^^^^ GraphQLInputObjectType. See: node_modules/graphql/type/definition.js.flow:76
  Error:
   14:       type: new GraphQLNonNull(GraphQLID),
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ GraphQLNonNull. This type is incompatible with. See: src/queries/Booking.js:14
   76:   GraphQLInputObjectType |
         ^^^^^^^^^^^^^^^^^^^^^^ GraphQLInputObjectType. See: node_modules/graphql/type/definition.js.flow:76
  Member 4:
   77:   GraphQLList<GraphQLInputType> |
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type application of class `GraphQLList`. See: node_modules/graphql/type/definition.js.flow:77
  Error:
   14:       type: new GraphQLNonNull(GraphQLID),
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ GraphQLNonNull. This type is incompatible with. See: src/queries/Booking.js:14
   77:   GraphQLList<GraphQLInputType> |
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ GraphQLList. See: node_modules/graphql/type/definition.js.flow:77
  Member 5:
         v--------------
   78:   GraphQLNonNull<
   79:     GraphQLScalarType |
   80:     GraphQLEnumType |
  ...:
   83:   >;
         ^ type application of class `GraphQLNonNull`. See: node_modules/graphql/type/definition.js.flow:78
  Error:
   80:     GraphQLEnumType |
           ^^^^^^^^^^^^^^^ GraphQLEnumType. This type is incompatible with. See: node_modules/graphql/type/definition.js.flow:80
   14:       type: new GraphQLNonNull(GraphQLID),
                                      ^^^^^^^^^ GraphQLScalarType. See: src/queries/Booking.js:14

Most helpful comment

I am having the same problem with GraphQL 0.11.3 and flow-bin 0.56.0. Flow is great but seems REALLY fragile in terms of version mismatching.

All 10 comments

+1

@jakubzaba
you may try to add type on GraphQLBooking and default export

const GraphQLBooking: GraphQLFieldConfig<any, any> = {
  name: ...,
  type: ...,
  ...
}

I saw similar errors. I upgraded to [email protected], matching package.json for v0.10.5, and it worked fine. Going to the most recent flow causes a whole new suite of errors.

This issue is probably stale. The most recent release of GraphQL-js (0.11.3) should work with Flow-bin 0.54. Closing out the issue, but please feel free to re-open and add more details if there is still a problem.

It's not stale. It's still valid. We found out that Flow is broken (Or GraphQL? I don't know.). We were exporting queries and mutations like this:

export default {
  type: GraphQLUser,
  args: {
    email: {
      type: new GraphQLNonNull(GraphQLString),
    },
  },
  // ...
};

But it didn't work in root query because of GraphQLNonNull. Flow was not able to resolve the import properly and I don't know why. So we fixed it like this:

export default ({
  type: GraphQLUser,
  // ...
}: GraphQLFieldConfig<mixed, GraphqlContextType>);

And now it works. I really think it's broken because it doesn't work only if the GraphQLNonNull is in arguments. Otherwise, it's fine...

We recently merged a PR that fixed the latest version of GraphQL-js (0.11.3) when used with the latest version of flow (0.54). Can you update and try again?

I was very optimistic about this change but it, unfortunately, didn't help (GraphQL 0.11.3 with Flow-bin 0.54.1). I have created a minimal example: https://github.com/mrtnzlml-archive/graphql-broken

Test 1 is valid (one file), test 2 is broken (two files with import / export) and test 3 is fixed test 2. At least you can tell by why I am doing it wrong... 馃檪

I am having the same problem with GraphQL 0.11.3 and flow-bin 0.56.0. Flow is great but seems REALLY fragile in terms of version mismatching.

Closing this aging issue, however the master branch has been tested to work with the latest version of flow and will be released shortly.

Also, error messages in flow can be confusing sometimes - I find flow check --traces 100 is a way to see flow's thought process which sometimes reveals a more compelling reason for an error.

I confirm that it's fixed in the last version! Thank you very much, good job! 馃檪

Was this page helpful?
0 / 5 - 0 ratings

Related issues

closertb picture closertb  路  3Comments

adriano-di-giovanni picture adriano-di-giovanni  路  3Comments

thomasdingemanse picture thomasdingemanse  路  4Comments

itajaja picture itajaja  路  3Comments

sudheerj picture sudheerj  路  3Comments