I am trying to write a schema with a single mutation, which should return null. Problem is when I try to do that, I get this error:
/home/capaj/git_projects/tgm/api-mock/node_modules/graphql/utilities/buildASTSchema.js:266
throw new Error('Type "' + typeName + '" not found in document.');
^
Error: Type "null" not found in document.
at typeDefNamed (/home/capaj/git_projects/tgm/api-mock/node_modules/graphql/utilities/buildASTSchema.js:266:13)
at produceType (/home/capaj/git_projects/tgm/api-mock/node_modules/graphql/utilities/buildASTSchema.js:232:19)
at produceOutputType (/home/capaj/git_projects/tgm/api-mock/node_modules/graphql/utilities/buildASTSchema.js:243:16)
at /home/capaj/git_projects/tgm/api-mock/node_modules/graphql/utilities/buildASTSchema.js:318:15
at /home/capaj/git_projects/tgm/api-mock/node_modules/graphql/jsutils/keyValMap.js:36:31
at Array.reduce (native)
at keyValMap (/home/capaj/git_projects/tgm/api-mock/node_modules/graphql/jsutils/keyValMap.js:35:15)
at makeFieldDefMap (/home/capaj/git_projects/tgm/api-mock/node_modules/graphql/utilities/buildASTSchema.js:314:36)
at fields (/home/capaj/git_projects/tgm/api-mock/node_modules/graphql/utilities/buildASTSchema.js:305:16)
at resolveThunk (/home/capaj/git_projects/tgm/api-mock/node_modules/graphql/type/definition.js:162:40)
My schema:
type Mutation {
forgottenPassword(email: String!): null
}
Is this a valid schema definition? If not how can I write it?
null is not a GraphQL type. You need to specify a return value as a type (e.g. String, Boolean etc). Types can be nullable, i.e. the value can be null, and, in fact, they are nullable by default (unless you define them with !).
Try:
type Mutation {
forgottenPassword(email: String!): Boolean
}
Also, this sort of question should go to stackoverflow.
@petrbela thanks, that's ... surprising
@petrbela > Also, this sort of question should go to stackoverflow.
no
Most helpful comment
nullis not a GraphQL type. You need to specify a return value as a type (e.g. String, Boolean etc). Types can be nullable, i.e. the value can benull, and, in fact, they are nullable by default (unless you define them with!).Try: