随着最近对原生 GraphQL 的支持,dgraph 引入了@hasInverse和@search指令的使用。当我在编辑器中编写模式时,linter 会警告我那些未知指令。
(Unknown directive "search"和Unknown directive "hasInverse")
因此,我将文件中的指令描述directive.schema如下:
enum SearchTypes {
hash,
exact,
regexp,
term,
fulltext
}
directive @search(by: [SearchTypes]) on FIELD_DEFINITION
directive @hasInverse(field: __EnumValue) on FIELD_DEFINITION
type DateTime
并且错误消失了……但是,我对重新定义 dgraph 可能已经提供的指令不是很满意。它们可能容易出错。
有没有更好的选择呢?