我正在尝试将我的枚举定义为字符串,但它似乎仍然会因无法理解枚举而引发错误。我猜我查询错了,但我不确定如何正确查询。
定义:
status: {
type: new graphql.GraphQLEnumType({
name:
"status",
values:
{
"accepted":
{
value:
"accepted"
},
"pending":
{
value:
"pending"
},
"reviewing":
{
value:
"reviewing"
},
}
})
},
我的查询:
const payload =
{
account_id:
instanced_accounts[0]._id,
account_type:
instanced_accounts[0].type,
page:
1,
page_length:
5,
search_text:
"",
status:
"accepted",
}
let query =
new QueryBuilder(
"retrieveContacts",
payload
)
我正在使用 graphlq-query-builder
当我运行查询时,它返回:
"message": "Expected type status, found \"accepted\"; Did you mean the enum value accepted?"
最佳答案
看起来有一个 Unresolved 问题 here那是十个月大。查看代码,似乎不支持枚举。我怀疑除了猴子修补代码之外是否有任何可行的解决方法。查询生成器是个好主意,但 GraphQL 中有大量常用功能(例如片段、枚举、联合、接口(interface)和指令),我希望一个完整的查询生成器能够支持所有这些功能。看起来这个特定的库在功能上非常有限,可能不再维护。您现在最好自己编写查询。
关于javascript - graphqljs - 如何搜索枚举类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54049640/