0

我正在努力寻找清楚这一点的文档:我可以在定义类型时在同一个模式文档中扩展类型吗?我不断收到如下错误:

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]
}

这是不允许的,但任何人都可以指出规范/其他文档明确说明的地方吗?

4

1 回答 1

0

通常,类型扩展在与类型定义相同的文档中起作用。大多数接受多个文档或类型定义的库在使用该文档生成架构之前将它们全部合并到一个文档中。

从规范的角度来看,您的类型定义没有任何问题。您看到的是neo4j-graphql-js 特有的错误。

于 2019-07-15T16:33:45.157 回答