Glavin001 / graphql-sequelize-crud

Automatically generate queries and mutations from Sequelize models
https://www.npmjs.com/package/graphql-sequelize-crud
MIT License
128 stars 23 forks source link

Input Types can't define resolvers #19

Closed prijindal closed 7 years ago

prijindal commented 7 years ago

Running the demo code is giving this error:

Unhandled rejection Error: createUserInput.id field type has a resolve property, but Input Types cannot define resolvers.
    at invariant (/home/prijindal/projects/Ideas/express/express-api/node_modules/graphql/jsutils/invariant.js:19:11)
    at /home/prijindal/projects/Ideas/express/express-api/node_modules/graphql/type/definition.js:657:31
    at Array.forEach (native)
    at GraphQLInputObjectType._defineFieldMap (/home/prijindal/projects/Ideas/express/express-api/node_modules/graphql/type/definition.js:651:16)
    at GraphQLInputObjectType.getFields (/home/prijindal/projects/Ideas/express/express-api/node_modules/graphql/type/definition.js:640:49)
    at /home/prijindal/projects/Ideas/express/express-api/node_modules/graphql/type/schema.js:224:27
    at typeMapReducer (/home/prijindal/projects/Ideas/express/express-api/node_modules/graphql/type/schema.js:229:7)
    at typeMapReducer (/home/prijindal/projects/Ideas/express/express-api/node_modules/graphql/type/schema.js:187:12)
    at Array.reduce (native)
    at /home/prijindal/projects/Ideas/express/express-api/node_modules/graphql/type/schema.js:215:38
    at Array.forEach (native)
    at /home/prijindal/projects/Ideas/express/express-api/node_modules/graphql/type/schema.js:208:29
    at typeMapReducer (/home/prijindal/projects/Ideas/express/express-api/node_modules/graphql/type/schema.js:219:7)
    at Array.reduce (native)
    at new GraphQLSchema (/home/prijindal/projects/Ideas/express/express-api/node_modules/graphql/type/schema.js:95:34)
    at getSchema (/home/prijindal/projects/Ideas/express/express-api/node_modules/graphql-sequelize-crud/lib/index.js:887:10)
mderid commented 7 years ago

Same here

respectTheCode commented 7 years ago

same here

tnrich commented 7 years ago

Dropping my dependencies to : "graphql": "^0.8.0", fixed it.

amaury1093 commented 7 years ago

Any plans to fix this?

Glavin001 commented 7 years ago

Please provide sample code, such as Sequelize models, which reproduces this issue.

Glavin001 commented 7 years ago

I am also experiencing this now with:

    "graphql": "^0.11.7",

Here are my logs:

Unhandled rejection Error: createUserInput.id field type has a resolve property, but Input Types cannot define resolvers.
    at invariant (/Users/glavin/Development/HealthForms/packages/api/node_modules/graphql/jsutils/invariant.js:18:11)
    at /Users/glavin/Development/HealthForms/packages/api/node_modules/graphql/type/definition.js:698:58
    at Array.forEach (native)
    at GraphQLInputObjectType._defineFieldMap (/Users/glavin/Development/HealthForms/packages/api/node_modules/graphql/type/definition.js:692:16)
    at GraphQLInputObjectType.getFields (/Users/glavin/Development/HealthForms/packages/api/node_modules/graphql/type/definition.js:681:49)
    at typeMapReducer (/Users/glavin/Development/HealthForms/packages/api/node_modules/graphql/type/schema.js:223:26)
    at typeMapReducer (/Users/glavin/Development/HealthForms/packages/api/node_modules/graphql/type/schema.js:189:12)
    at Array.reduce (native)
    at /Users/glavin/Development/HealthForms/packages/api/node_modules/graphql/type/schema.js:216:36
    at Array.forEach (native)
    at typeMapReducer (/Users/glavin/Development/HealthForms/packages/api/node_modules/graphql/type/schema.js:209:27)
    at Array.reduce (native)
    at new GraphQLSchema (/Users/glavin/Development/HealthForms/packages/api/node_modules/graphql/type/schema.js:97:34)
    at Object.getSchema (/Users/glavin/Development/HealthForms/packages/api/node_modules/graphql-sequelize-crud/lib/index.js:887:10)
    at /Users/glavin/Development/HealthForms/packages/api/dist/index.js:116:43
    at tryCatcher (/Users/glavin/Development/HealthForms/packages/api/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/glavin/Development/HealthForms/packages/api/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/Users/glavin/Development/HealthForms/packages/api/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/Users/glavin/Development/HealthForms/packages/api/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/Users/glavin/Development/HealthForms/packages/api/node_modules/bluebird/js/release/promise.js:693:18)
    at Async._drainQueue (/Users/glavin/Development/HealthForms/packages/api/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/Users/glavin/Development/HealthForms/packages/api/node_modules/bluebird/js/release/async.js:143:10)
Glavin001 commented 7 years ago

@tnrich For some reason I am receiving errors with GraphQL version 0.8.2, which you are using: https://github.com/TeselaGen/graphql-sequelize-crud/blob/master/yarn.lock#L1729

  getSchema
    ✓ should return GraphQL Schema (39ms)
    1) should successfully create records
    2) should successfully create and update single User record
    3) should successfully create and update User records
    4) should successfully create and delete User records
    5) should successfully create and delete single User record
    ✓ should fail to create user with excluded field
    ✓ should fail to create user with excluded field
    ✓ should successfully create custom record with custom mutation

  4 passing (612ms)
  5 failing

  1) getSchema should successfully create records:
     AssertionError: An error occurred: GraphQLError: Cannot read property 'selectionSet' of undefined: expected [ Array(1) ] to equal undefined
      at test/getSchema.test.ts:249:37
      at <anonymous>

  2) getSchema should successfully create and update single User record:
     AssertionError: expected null to be an object
      at test/getSchema.test.ts:498:54
      at <anonymous>

  3) getSchema should successfully create and update User records:
     AssertionError: expected null to be an object
      at test/getSchema.test.ts:600:54
      at <anonymous>

  4) getSchema should successfully create and delete User records:
     AssertionError: expected null to be an object
      at test/getSchema.test.ts:690:54
      at <anonymous>

  5) getSchema should successfully create and delete single User record:
     AssertionError: expected null to be an object
      at test/getSchema.test.ts:777:54
      at <anonymous>

npm ERR! Test failed.  See above for more details.

I have 0.7.2 passing tests though.

It may be an issue with the refactoring I have done with #31.


Any plans to fix this?

I hope to fix this and get everything working on latest GraphQL version.


Update: Turns out the Cannot read property 'selectionSet' of undefined error is from a breaking change in GraphQL: https://github.com/jakepusateri/graphql-list-fields/issues/1#issuecomment-261023412 and https://github.com/jakepusateri/graphql-list-fields/commit/28cbd89672d9debf495e44e83bb29822fbb4ebb6 A newer version of graphql-sequelize fixes this: https://github.com/mickhansen/graphql-sequelize/blob/25c9c5089a9ce039ecc8da6c679ab942431d4df6/src/relay.js#L351

However I now have other issues to fix with updating these dependencies. Will take more time.

Glavin001 commented 7 years ago

Published a big new release, v0.4.1! https://github.com/Glavin001/graphql-sequelize-crud/releases/tag/v0.4.1