mickhansen / graphql-sequelize

GraphQL & Relay for MySQL & Postgres via Sequelize
MIT License
1.9k stars 172 forks source link

graphql 0.10.0-1 input type breakage #496

Closed RichAyotte closed 7 years ago

RichAyotte commented 7 years ago

After upgrading to graphql 0.10.1, I get the following error.

Error: RootQueryType.AddressStreetType(limit:) argument type must be Input Type but got: Int. at invariant (/home/rich/Projects/omn/backend/node_modules/graphql/jsutils/invariant.js:19:11) at /home/rich/Projects/omn/backend/node_modules/graphql/type/definition.js:367:33 at Array.map (native) at /home/rich/Projects/omn/backend/node_modules/graphql/type/definition.js:364:44 at Array.forEach (native) at defineFieldMap (/home/rich/Projects/omn/backend/node_modules/graphql/type/definition.js:348:14) at GraphQLObjectType.getFields (/home/rich/Projects/omn/backend/node_modules/graphql/type/definition.js:302:44) at typeMapReducer (/home/rich/Projects/omn/backend/node_modules/graphql/type/schema.js:206:25) at Array.reduce (native) at new GraphQLSchema (/home/rich/Projects/omn/backend/node_modules/graphql/type/schema.js:95:34) at Object. (/home/rich/Projects/omn/backend/schema.js:135:18) at Module._compile (module.js:571:32) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3)

Work fine with 0.9.6.

I'm using defaultArgs() and defaultListArgs() helper functions to generate the args.

Here's the field object.

{
  args: {
    limit: {
      type: GraphQLScalarType {
        name: 'Int'
        , description: 'The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1. '
        , _scalarConfig: [Object]
      }
    }
    , order: {
      type: GraphQLScalarType {
        name: 'String'
        , description: 'The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.'
        , _scalarConfig: [Object]
      }
    }
    , where: {
      type: GraphQLScalarType {
        name: 'SequelizeJSON'
        , description: 'The `JSON` scalar type represents raw JSON as values.'
        , _scalarConfig: [Object]
      }
      , description: 'A JSON object conforming the the shape specified in http://docs.sequelizejs.com/en/latest/docs/querying/'
    }
    , offset: {
      type: GraphQLScalarType {
        name: 'Int'
        , description: 'The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1. '
        , _scalarConfig: [Object]
      }
    }
  }
  , resolve: [Function: resolver]
  , type: GraphQLList {
    ofType: GraphQLObjectType {
      name: 'AddressStreetType'
      , description: 'AddressStreetType'
      , isTypeOf: undefined
      , _typeConfig: {
        args: [Object]
        , description: 'AddressStreetType'
        , fields: [Function: fields]
        , name: 'AddressStreetType'
      }
    }
  }
}
louisremi commented 7 years ago

The title of the bug mentions graphql 0.10.0-1, while the description mentions 0.10.1. Which version are you using?

RichAyotte commented 7 years ago

Same problem on both 0.10.0 and 0.10.1. I just used to 0-1 to indicate range.

mickhansen commented 7 years ago

Isn't InputType only enforced for mutations? I'm not aware they changed the way args works but that doesn't say much.

Yarkhan commented 7 years ago

Can confirm. I have a similar issue with attributeFields helper function

const type = new GraphQLObjectType({
    name: 'user',
    description: 'A user',
    fields: attributeFields(model)
    // fields: {
    //     id:{
    //         type: GraphQLInt
    //     }
    // }
})

where it yelds the following error

Error: user.id field type must be Output Type but got: Int!.

reverting graphql to version 0.9.6 solves the problem

mickhansen commented 7 years ago

Can anyone link a relevant changelog? Seems like a change to the spec

RichAyotte commented 7 years ago

I'm no longer experiencing this problem and I'm not sure what fixed it. The only relevant change that think I've made is update Node to v8.1.2.

@Yarkhan what version of Node are you running?

Yarkhan commented 7 years ago

I didn't find anything on the changelog that seems related to these errors.

@RichAyotte I was on 7.6.0. I've updated node to 8.1.2 to see if it would solve my problem, but got the same error. I will stick with graphql 0.9.6 for the moment

RichAyotte commented 7 years ago

@Yarkhan Another shot in the dark... maybe your node_modules directory has become inconsistent? Can you rm -r node_modules; yarn or npm to reinstall?

I'm ready to close this issue as I'm no longer able to reproduce it.

Yarkhan commented 7 years ago

@RichAyotte Tried that too, didn't work. Maybe my issue is not related with this one at all. I will open an issue describing the exact steps to reproduce it. Anyway, reverting to 0.9.6 has worked for me Thanks guys!

rpellerin commented 7 years ago

Just upgraded graphql to 0.10.3 and I am experiencing the very same issue you described.