James
James

Reputation: 1475

Multiple filters on the same graphql query

Hi I'm making a navigation component by mapping through gatsby pages I'm trying to filter out both the "/" index page and the "/dev-404-page/" page

my query which successfully filters the "/dev-404-page/"

 query MyQuery {
        allSitePage(filter: {path: {ne: "/dev-404-page/"}}) {
          nodes {
            path
          }
        }
      }

How should I go about adding

{ne: "/"}

have tried commas and "&", but I think I'm barking up the wrong tree.

Thanks in advance

Upvotes: 0

Views: 2201

Answers (1)

Herku
Herku

Reputation: 7666

It does not seem like Gatsby is offering a way to use multiple conditions. But it offers support for "not in" as well as regex:

type StringQueryOperatorInput {
  # ...
  nin: [String]
  regex: String
}

So maybe try this query:

query MyQuery {
  allSitePage(filter: {path: {nin: ["/dev-404-page/", "/"]}}) {
    nodes {
      path
    }
  }
}

Upvotes: 1

Related Questions