Query Language
Simple Object Queries
A GraphQL query in its simplest form defines the fields on an object to query for. The following example queries the fields name
, make
, and model
on the machines
object.
{
machines {
name
make
model
}
}
It returns a resultset as a JSON object in the following format:
{
"data": {
"machines": [
{
"name": "Machine A",
"make": "Tsugami",
"model": "B02-II"
},
{
"name": "Machine B",
"make": "Tsugami",
"model": "B02-III"
},
{
"name": "Machine C",
"make": "Miyano",
"model": "BNA-42"
},
{
"name": "Machine D",
"make": "Miyano",
"model": "BNA-42"
}
]
}
}
The data can be filtered using a where
clause. The clause is a map of field names (e.g. make
) and comparisons. The The following query only returns machines of the make "Miyano".
- Query
- Result
{
machines(where: {make: {_eq: "Miyano"}}) {
name
make
model
}
}
{
"data": {
"machines": [
{
"name": "Machine C",
"make": "Miyano",
"model": "BNA-42"
},
{
"name": "Machine D",
"make": "Miyano",
"model": "BNA-42"
}
]
}
}
Comparison Operators
We support a variety of comparison operators:
- Equality operators
_eq
tests for strict equality_neq
negated version of_eq
- Greater than or less than operators
_gt
equivalent to >_lt
equivalent to <_gte
equivalent to >=_lte
equivalent to =<
- List based search operators
_in
expects an array of scalar values_nin
negated version of_in
- Text search or pattern matching operators
_like
matching a string pattern (_
matches any single character,%
matches any sequence of zero or more characters)_ilike
same as_like
but case insensitive
- Boolean operators
_not
_and
_or