Use comparison operators in GraphQL queries, allowing for more powerful and flexible data filtering capabilities.
exact
: Equal toiexact
: Case-insensitive equalcontains
: String containsicontains
: Case-insensitive string containsin_list
: Included in an arraynot_in_list
: Not included in an arraygt
: Greater thangte
: Greater than or equal tolt
: Less thanlte
: Less than or equal tostartswith
: String starts withistartswith
: Case-insensitive string starts withendswith
: String ends withiendswith
: Case-insensitive string ends withregex
: String regexiendswith
: Case-insensitive string regex
- Docker and Docker Compose
- Git
-
Clone the repository:
git clone https://github.com/yourusername/graphql-comparison-operators.git cd graphql-comparison-operators
-
Build the Docker containers:
docker-compose build
-
Start the application:
docker-compose up
-
Access the GraphQL playground at:
http://0.0.0.0:8000/graphql
mutation {
createTask(
task: {
content: "first task"
}
) {
id
content
createdAt
}
}
{
tasks(
query: {
createdAt: {
gt: "2023-06-19T12:21:35.640+00:00"
}
}
) {
id
content
createdAt
}
}
{
tasks(
query: {
createdAt: {
gte: "2023-06-01T00:00:00.000+00:00",
lte: "2025-03-03T07:48:11.572456"
}
}
) {
id
content
createdAt
}
}
For a detailed explanation of how comparison operators work in GraphQL, check out my article: Query Operators in GraphQL