GraphQL multiple values eq filter

Viewed 3897

How do I filter multiple values in GraphQL? For example, I want both databaseID 59 and 170 to be filtered.

I've tried with 170, 59 but it returns error "Syntax Error: Expected Name, found Int \"59\"."

My GraphQL Query:

query MyQuery {
  allWpPage(filter: {databaseId: {eq: 170, 59}}) {
    nodes {
      title
      databaseId
    }
  }
}
1 Answers

Found the answer with the help of @xadms comment.

I could use either in if I only want those ids, or nin if I want them excluded. In order to have multiple, I should pass the ids as an array

query MyQuery {
  allWpPage(filter: {databaseId: {in: [170, 59]}}) {
    nodes {
      title
      databaseId
    }
  }
}
Related