【问题标题】:Dgraph - graphql where are described the directives on schema?Dgraph - graphql 在哪里描述了关于模式的指令?
【发布时间】:2020-02-28 23:42:16
【问题描述】:

随着最近对原生 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 可能已经提供的指令不是很满意。它们很容易出错。

有没有更好的选择?

【问题讨论】:

    标签: graphql schema directive dgraph


    【解决方案1】:

    编辑:这现已添加到我们的文档https://graphql.dgraph.io/docs/schema/#schemafragment

    (这里是 Dgraph 的 GraphQL 开发人员的迈克尔。感谢您的提问。)

    抱歉,这不是一次很棒的开发者体验。我们将努力改善这一点。

    您的架构使用什么编辑器和 graphql 插件?是否支持包含另一个文件?如果是这样,我们可以发布我们的基础架构,您可以将其包含在内。

    否则,您必须像以前一样粘贴所需的部分。

    【讨论】:

    • 我正在使用带有a graphql plugin 的Webstorm。该插件依赖于.graphqlconfig,没有任何设置,graphql 命名空间将使用相对于.graphqlconfig 文件的glob ./**/*.graphql。因此,我们可以将dgraph.graphql 放在schema.graphql 旁边,它就像一个魅力。现在,如果 dgraph 团队可以提供一个官方的dgraph.graphql 文件那就更好了。
    猜你喜欢
    • 1970-01-01
    • 2013-01-21
    • 2019-12-16
    • 1970-01-01
    • 2017-12-12
    • 2022-08-03
    • 1970-01-01
    • 1970-01-01
    • 2020-07-04
    相关资源
    最近更新 更多