I'm struggling to find docs which are clear about this: Can I extend a type in the same schema doc as I define a type? I keep getting errors like the following:
Error: Cannot extend type "Healthcheck" because it is not defined.
at assertValidSDL (/Users/rhys.evans/Projects/or/biz-ops-api/node_modules/graphql/validation/validate.js:80:11)
at Object.buildASTSchema (/Users/rhys.evans/Projects/or/biz-ops-api/node_modules/graphql/utilities/buildASTSchema.js:69:34)
at Object.buildSchemaFromTypeDefinitions (/Users/rhys.evans/Projects/or/biz-ops-api/node_modules/graphql-tools/dist/generate/buildSchemaFromTypeDefinitions.js:23:28)
at makeExecutableSchema (/Users/rhys.evans/Projects/or/biz-ops-api/node_modules/graphql-tools/dist/makeExecutableSchema.js:26:29)
at makeAugmentedExecutableSchema (/Users/rhys.evans/Projects/or/biz-ops-api/node_modules/neo4j-graphql-js/dist/augment.js:75:49)
at makeAugmentedSchema (/Users/rhys.evans/Projects/or/biz-ops-api/node_modules/neo4j-graphql-js/dist/index.js:232:53)
at createSchema (/Users/rhys.evans/Projects/or/biz-ops-api/server/data/graphql-schema.js:36:17)
at EventEmitter.constructAPI (/Users/rhys.evans/Projects/or/biz-ops-api/server/routes/graphql.js:19:21)
at emitOne (events.js:121:20)
at EventEmitter.emit (events.js:211:7)
Schema doc:
directive @deprecated(
reason: String = "No longer supported"
) on FIELD_DEFINITION | ENUM_VALUE | ARGUMENT_DEFINITION
type Healthcheck {
code: String
}
type Check {
name: String
}
extend type Healthcheck {
checks: [Check]
}
I guess it's not allowed, but can anyone point me to where the spec/other docs make this clear?
Generally, type extensions only work within the same document as the type definitions. Most libraries that accept multiple documents or type definitions merge all of them into a single document before using that document to generate the schema.
There's nothing wrong with your type definitions from a specification perspective. What you're seeing is a bug that is specific to neo4j-graphql-js.