在与类型定义相同的模式文档中扩展类型是否有效
Is it valid to extend a type in the same schema doc as the type definition
我正在努力寻找明确说明这一点的文档:我可以在定义类型的同一架构文档中扩展类型吗?我不断收到如下错误:
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]
}
我 猜想 这是不允许的,但谁能告诉我 spec/other 文档在哪里明确说明了这一点?
通常,类型扩展仅在与类型定义相同的文档中起作用。大多数接受多个文档或类型定义的库在使用该文档生成模式之前将它们全部合并到一个文档中。
从规范的角度来看,您的类型定义没有任何问题。您看到的是 specific to neo4j-graphql-js.
的错误
我正在努力寻找明确说明这一点的文档:我可以在定义类型的同一架构文档中扩展类型吗?我不断收到如下错误:
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]
}
我 猜想 这是不允许的,但谁能告诉我 spec/other 文档在哪里明确说明了这一点?
通常,类型扩展仅在与类型定义相同的文档中起作用。大多数接受多个文档或类型定义的库在使用该文档生成模式之前将它们全部合并到一个文档中。
从规范的角度来看,您的类型定义没有任何问题。您看到的是 specific to neo4j-graphql-js.
的错误