【发布时间】:2019-07-07 12:29:58
【问题描述】:
我正在使用实现SchemaDirectiveVisitor 的visitFieldDefinition 函数的架构指令。我想知道架构中定义的字段的类型,例如该类型是否为数组。
在架构中:
type DisplayProperties {
description: StringProperty @property
descriptions: [StringProperty]! @property
}
属性指令:
class PropertyDirective extends SchemaDirectiveVisitor {
visitFieldDefinition(field) {
// how to check that field type is StringProperty?
// how to find out that the field type is an array?
}
}
使用 Apollo 服务器和 graphql-tools。
【问题讨论】:
-
Apollo 页面上的示例真的很有帮助:apollographql.com/docs/graphql-tools/schema-directives.html 只需阅读代码就可以了解很多内容。
标签: graphql apollo-server