mlipscombe/postgraphile-plugin-nested-mutations

Error: Can only create NonNull of a Nullable GraphQLType but got: UUID

Closed this issue · 2 comments

I'm getting Error: Can only create NonNull of a Nullable GraphQLType but got: UUID, which I guess is because I'm using an UUID, but might also be from having a composite primary key.

Here's a simplified version of the base table everything in my schema inherits from:

create table base (
  entity_id       uuid default uuid_generate_v1mc(),
  valid_from       timestamp with time zone not null default now(),
  valid_until      timestamp with time zone not null default 'infinity',
  primary key (entity_id, valid_until)
);

As well as the full log:

DEBUG="graphile-build:warn" yarn postgraphile --append-plugins postgraphile-plugin-nested-mutations -c 'postgres://localhost:5432/my_app' -s
 my_app -X -p 5001 --export-schema-json ./schema/__generated__/schema.json --expor
t-schema-graphql ./schema/__generated__/schema.gql
yarn run v1.7.0
$ /Path/to/app/node_modules/.bin/postgraphile --append-plugins postgraphile-plugin-nested-mutations -c postgres://localhost:5432/my_app -s my_app -X -p 5001 --export-schema-json ./schema/__generated__/schema.json --export-schema-graphql ./schema/__generated__/schema.gql
An error occurred, it might be okay but it doesn't look like the error we were expecting... run with envvar 'DEBUG="graphile-build:warn"' to view the error
  graphile-build:warn Error: Can only create NonNull of a Nullable GraphQLType but got: UUID.
  graphile-build:warn     at invariant (/Path/to/app/node_modules/graphile-build/node_modules/graphql/jsutils/invariant.js:18:11)
  graphile-build:warn     at new GraphQLNonNull (/Path/to/app/node_modules/graphile-build/node_modules/graphql/type/definition.js:779:84)
  graphile-build:warn     at args.keys.reduce (/Path/to/app/node_modules/postgraphile/node_modules/graphile-build-pg/node8plus/plugins/PgRowByUniqueConstraint.js:67:25)
  graphile-build:warn     at Array.reduce (<anonymous>)
  graphile-build:warn     at memo.(anonymous function).fieldWithHooks (/Path/to/app/node_modules/postgraphile/node_modules/graphile-build-pg/node8plus/plugins/PgRowByUniqueConstraint.js:61:26)
  graphile-build:warn     at fieldWithHooks (/Path/to/app/node_modules/graphile-build/node8plus/makeNewBuild.js:372:29)
  graphile-build:warn     at uniqueConstraints.forEach.constraint (/Path/to/app/node_modules/postgraphile/node_modules/graphile-build-pg/node8plus/plugins/PgRowByUniqueConstraint.js:58:29)
  graphile-build:warn     at Array.forEach (<anonymous>)
  graphile-build:warn     at introspectionResultsByKind.class.filter.filter.reduce (/Path/to/app/node_modules/postgraphile/node_modules/graphile-build-pg/node8plus/plugins/PgRowByUniqueConstraint.js:46:27)
  graphile-build:warn     at Array.reduce (<anonymous>) +0ms
An error occurred, it might be okay but it doesn't look like the error we were expecting... run with envvar 'DEBUG="graphile-build:warn"' to view the error
  graphile-build:warn TypeError: getGqlInputTypeByTypeIdAndModifier is not a function
  graphile-build:warn     at PostGraphileNestedMutationPlugin.builder.hook (/Path/to/app/node_modules/postgraphile-plugin-nested-mutations/src/PostgraphileNestedMutationsPlugin.js:60:28)
  graphile-build:warn     at SchemaBuilder.applyHooks (/Path/to/app/node_modules/graphile-build/node8plus/SchemaBuilder.js:145:20)
  graphile-build:warn     at fieldWithHooks (/Path/to/app/node_modules/graphile-build/node8plus/makeNewBuild.js:374:35)
  graphile-build:warn     at pgIntrospectionResultsByKind.class.filter.filter.filter.reduce (/Path/to/app/node_modules/postgraphile/node_modules/graphile-build-pg/node8plus/plugins/PgMutationCreatePlugin.js:110:25)
  graphile-build:warn     at Array.reduce (<anonymous>)
  graphile-build:warn     at PgMutationCreatePlugin.builder.hook (/Path/to/app/node_modules/postgraphile/node_modules/graphile-build-pg/node8plus/plugins/PgMutationCreatePlugin.js:55:210)
  graphile-build:warn     at SchemaBuilder.applyHooks (/Path/to/app/node_modules/graphile-build/node8plus/SchemaBuilder.js:145:20)
  graphile-build:warn     at fields (/Path/to/app/node_modules/graphile-build/node8plus/makeNewBuild.js:391:40)
  graphile-build:warn     at resolveThunk (/Path/to/app/node_modules/graphile-build/node_modules/graphql/type/definition.js:168:40)
  graphile-build:warn     at defineFieldMap (/Path/to/app/node_modules/graphile-build/node_modules/graphql/type/definition.js:349:18) +4ms
Error: Schema query must be Object Type but got: undefined.
    at invariant (/Path/to/app/node_modules/graphile-build/node_modules/graphql/jsutils/invariant.js:18:11)
    at new GraphQLSchema (/Path/to/app/node_modules/graphile-build/node_modules/graphql/type/schema.js:71:88)
    at Object.newWithHooks (/Path/to/app/node_modules/graphile-build/node8plus/makeNewBuild.js:476:20)
    at SchemaBuilder.buildSchema (/Path/to/app/node_modules/graphile-build/node8plus/SchemaBuilder.js:190:37)
    at Object.exports.createPostGraphileSchema (/Path/to/app/node_modules/postgraphile/node_modules/postgraphile-core/node8plus/index.js:219:26)
    at process._tickCallback (internal/process/next_tick.js:68:7)

I think the stack trace from the nested mutations plugin comes because you have a version of postgraphile older than the peer dependency. I've also refactored the code and added support for composite keys today, but check the README.md because there are some breaking changes in field naming to accomodate that. Please try again with 1.0.0-alpha.7 and let me know!

Looks like that was indeed the issue! Will let you know if I encounter any more issues using this - very excited about this plugin, thanks a lot for working on it 😄