Skip to main content
Version: Firesquid

AND/OR filters

Overview

When performing queries, our GraphQL implementation offers a vast selection of tools to filter and section results. One of these is the where clause, very common in most database query languages and explained here in great detail.

In our GraphQL server implementation, we included logical operators to be used in the where clause, allowing to group multiple parameters in the same where argument using the AND or the OR operators to filter results based on more than one criteria.

Example of OR clause:

Fetch a list of accounts that either have a balance bigger than a certain amount, or have a specific id.

query {
accounts(
orderBy: balance_DESC,
where: {
OR: [
{balance_gte: "240000000000000000"}
{id_eq: "CksmaBx9rKUG9a7eXwc5c965cJ3QiiC8ELFsLtJMYZYuRWs"}
]
}
) {
balance
id
}
}

Example of AND clause:

Fetch a list of accounts that have a balance between two specific amounts:

query {
accounts(
orderBy: balance_DESC,
where: {
AND: [
{balance_lte: "240000000000000000"}
{balance_gte: "100000000000000"}
]
}
) {
balance
id
}
}