Skip to main content

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".

{
machines(where: {make: {_eq: "Miyano"}}) {
name
make
model
}
}

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