首页 > 解决方案 > 如何在 graphQL 中使用 where 参数?

问题描述

我有这个正在运行的查询:

{
  ArticleGalleriesCollection(limit: 2, locale: "en", where: {articleTitle: "Hello"}) {
    items {
      articleTitle
      articleGalleryType {
        type
        width
        height
      }
      articleAssetsElementsCollection(limit: 100) {
        items {
          fileName
          url
          contentType
          width
          height
          size
        }
      }
    }
  }
}

我想更新我的 where 参数,告诉 graphQL 只过滤 ArticleGalleriesCollection 中具有 type="standard" 的 articleGalleryType 的文章

我应该如何更新我的查询?

Schema : ArticleGalleriesCollection 中的每个项目都有一个 1:1 的 articleGalleryType 和一个 type 属性

标签: graphql

解决方案


graphql 可以询问的内容直接取决于模式、服务器(解析器)

如果您的 api 不支持过滤,articleGalleryType那么构造无效查询是没有意义的。

过滤没有通用标准(准备好,内置) - 这是您的服务器的责任(业务逻辑)。


推荐阅读