【问题标题】:Use enum as query argument in Graphql在 Graphql 中使用枚举作为查询参数
【发布时间】:2019-06-06 07:03:42
【问题描述】:

SDL 中使用枚举作为查询参数的 graphql 语法是什么?

schema {
  query: Query
}
type Query {
    getWordsCountByLanguage (language: LanguageIso): [WordCount]
}
enum LanguageIso {
    AA
    AB
}

解析上述架构会抛出Expected type 'language' to be a GraphQLInputType, but it wasn't!的错误

定义包含枚举的输入类型将导致类似的错误。

看起来没有办法在 SDL 中使用枚举作为查询参数。

【问题讨论】:

    标签: graphql graphql-java graphql-java-tools


    【解决方案1】:

    已经报告了一个错误here 问题在于嵌套输入(即,您有一个包含枚举的输入参数)。如果您像我的问题一样直接将枚举作为参数传递应该可以工作。

    【讨论】:

      猜你喜欢
      • 2023-03-28
      • 2017-03-31
      • 2015-02-27
      • 1970-01-01
      • 2013-12-13
      • 2022-10-23
      • 2015-11-22
      • 2016-04-23
      • 2022-01-20
      相关资源
      最近更新 更多