I wanted to share a quick example of how to use comparison operators like $lt
(less than), $gt
(greater than), and others in GraphQL Explorer. These operators are handy when you need to filter data based on certain conditions. Below is a sample query to illustrate the usage.
Example Query
Here’s a simple query where we are using the $lt
operator to fetch records where the field myNumber
is less than 10:
query {
newPage(query: { data: "{ myNumber: { \"$lt\": 10 } }"}) {
data {
myNumber
}
}
}
Example Using $gt
and $ne
Here’s another example where we use both $gt
and $ne
:
query {
newPage(query: { data: "{ myNumber: { \"$gt\": 20, \"$ne\": 30 } }"}) {
data {
myNumber
}
}
}
Using these operators can significantly enhance your queries, allowing you to retrieve exactly the data you need. Feel free to experiment with different operators and share your findings or any questions you might have!