从Prismic和GatsbyJS筛选查询

问题描述 投票:0回答:1

[在我的gatsby站点中看到一些奇怪的行为查询Prismic数据源并通过内容关系进行过滤。我正在尝试创建一个页面,该页面根据传递到此页面的类别过滤一些产品。阅读Prismic和Gatsby文档,我应该能够使用where子句过滤数据,但是在尝试时会出现此错误建立

error    Unknown argument "where" on field "allPrismicModel" of type "Query"

下面是查询的相关部分

query getProducts($uid: String) {
    allPrismicModel(where: { system_category: $uid }) {
      edges {
        node {
          data {
            system_category {
              uid
            }
            ...other fields here...
          }
        }
      }
    }
  }

任何人都遇到或知道如何解决?

reactjs graphql gatsby prismic.io
1个回答
0
投票

where在盖茨比中不存在。我强烈建议使用GraphiQL(在localhost:8000 / ___ graphql下)查看您可以做什么。该文档还显示了所有可能性:https://www.gatsbyjs.org/docs/graphql-reference/

可能会最终(未试用):

filter: { system_category: { eq: $uid } }
© www.soinside.com 2019 - 2024. All rights reserved.