graphql - 如何在GraphQL查询中使用distinct?

标签 graphql

这是我尝试在graphQl查询中使用与众不同的查询:

query{
    contacts(take: 10, distinct: true) {
        firstName
        lastName
        title
    }
}

但是我得到了错误:
{
    "errors": [
        {
            "message": "Unknown argument \"distinct\" on field \"contacts\" of type \"QuerySchema\".",
            "locations": [
                {
                    "line": 2,
                    "column": 21
                }
            ]
        }
    ]
}

最佳答案

GraphQL没有内置的排序/过滤功能。由服务器来实现类似的功能,因此,如果您依赖第三方API并且它不支持它,那么您将不得不自己过滤响应。

关于graphql - 如何在GraphQL查询中使用distinct?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46552167/

相关文章:

python - 具有循环依赖的 GraphQL 设计

graphql - 如何在 .NET Core 6 中实现微服务的 GraphQL 模式拼接和身份验证

javascript - Express GraphQL 必须提供查询字符串。

graphql - 测试运行完成后,Jest 一秒钟都没有退出。 --检测打开句柄

java - 使用模式对 GraphQL 响应进行类型保留反序列化

graphql - 仅在 React 组件挂载上运行 Apollo 查询(没有 queryData 和生命周期)

reactjs - Apollo客户端查询错误: "Network error: Failed to fetch" How to troubleshoot?

mysql - 如何为 MySQL 模型制作 GraphQL 模式?

syntax-error - 发现 GraphQL gql 语法错误 : Expected Name, }

python - 我可以从 GraphQL 模式生成 REST 服务吗?