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
}
}
}
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
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With