0

Seeing some strange behavior querying a Prismic data source and filtering by a content relationship in my gatsby site. I"m trying to create a page filtering some products based on the category passed into this page. Reading both the Prismic and Gatsby docs, i should be able to filter the data with the where clause but i get this error when i try to build

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

Below is the relevant sections of the query

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

Anybody ever encountered this or know how to resolve it?

2 Answers2

1

where doesn't exist in Gatsby. I'd highly recommend using GraphiQL (under localhost:8000/___graphql) to see what you can do. There is also this doc showing all possibilities: https://www.gatsbyjs.org/docs/graphql-reference/

It'll probably will be in the end (untested):

filter: { system_category: { eq: $uid } }
LekoArts
  • 1,521
  • 1
  • 7
  • 7
  • Interesting. I saw that Gatsby supports a filter operator but Prismic's docs suggest using the `where` clause. Anyway, when I use the filter operator, i get this error `Field "system_category" is not defined by type PrismicModelFilterInput` – Cameron Lewis Oct 31 '19 at 15:16
0

allPrismicModel(filter: { system_category : { eq: $uid } }) {  
edges {
        node {
          data {
            system_category {
              uid
            }
            ...other fields here...
          }
        }
      }
    }
  }

This is a more common way to run that query

Auzziland
  • 188
  • 1
  • 8