javascript - graphqljs - 如何搜索枚举类型

标签 javascript graphql

我正在尝试将我的枚举定义为字符串,但它似乎仍然会因无法理解枚举而引发错误。我猜我查询错了,但我不确定如何正确查询。

定义:

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/

相关文章:

c# - GraphQL 我将如何编写查询以按名字查找

angular - 如何在 Strapi、GraphQL 的 where 子句中使用多个 'and' 条件进行查询?

javascript - apollo graphql 突变 - JSON 输入意外结束

javascript - 确保元素 id 属性是单独的

javascript - Phaser - For 循环抛出 "TypeError: Cannot read property ' 长度'未定义”

node.js - 使用单个服务器将 GraphQL 订阅添加到现有的 Express 应用程序

graphql - 如何在联合中查询不同类型的相同字段?

javascript - 使用 jQuery/Javascript 的 DOM 事件仅适用于 $().ready 或 window.onload

javascript - 有没有办法通过选择将 "suffix"附加到 javascript 函数?

javascript - 使用 json 填充下拉列表(SyntaxError : Unexpected token { in JSON. 。)