ElasticGraph Query API: Equality Filtering
Try these example queries by visiting the GraphiQL UI after booting locally.
Copied!
$ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always
The most commonly used predicate supports equality filtering:
equalToAnyOf- Matches records where the field value is equal to any of the provided values.
This works just like an
INoperator in SQL.When
nullis passed, matches all documents. When an empty list is passed, this part of the filter matches no documents. Whennullis passed in the list, this part of the filter matches records where the field value isnull.
Here’s a basic example:
Copied!
query FindU2OrRadiohead {
artists(filter: {
name: {equalToAnyOf: ["U2", "Radiohead"]}
}) {
nodes {
name
bio {
yearFormed
}
}
}
}
Unlike the SQL IN operator, you can find records with null values if you put null in the list:
Copied!
query FindUnnamedVenues {
venues(filter: {
name: {equalToAnyOf: [null]}
}) {
nodes {
name # will be null on all returned nodes
capacity
}
}
}