我正在努力寻找清晰的文档:我可以在定义类型的同一架构文档中扩展类型吗?我不断收到如下错误:
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)
架构文档:
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]
}
我猜测这是不允许的,但是有人可以指出我在规范/其他文档中明确指出的地方吗?
答案 0 :(得分:0)
通常,仅类型扩展名 在与类型定义相同的文档中起作用。大多数接受多个文档或类型定义的库都将它们全部合并到一个文档中,然后再使用该文档生成架构。
从规范的角度来看,类型定义没有问题。您看到的是一个specific to neo4j-graphql-js的错误。