Query filters
To filter data, you can use query filters.
The available operator sets for query filters depend on the data type. These same filters can also be used for conditional updates.
To apply a query filter to a <data_type>
type, use the input <data_type>Filter
input.
For example, for a String
data type, use input StringFilter
.
Filters for each data type
StringFilter
Operator | Description |
---|---|
eq | = Equals |
ne | <> or != Not Equals |
in | Allows you to specify multiple string values |
nin | Allows you to specify multiple string values |
contains | Contains target string |
regex | Regular expression search |
Examples
<span><span style="color: var(--shiki-color-text)">{</span></span>
<span><span style="color: var(--shiki-color-text)"> cars(query: { </span><span style="color: var(--shiki-token-string)">carName</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">eq</span><span style="color: var(--shiki-color-text)">: </span><span style="color: var(--shiki-token-string-expression)">"XXX"</span><span style="color: var(--shiki-color-text)"> } }) {</span></span>
<span><span style="color: var(--shiki-color-text)"> edges {</span></span>
<span><span style="color: var(--shiki-color-text)"> node {</span></span>
<span><span style="color: var(--shiki-color-text)"> id</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)">}</span></span>
<span></span>
<span><span style="color: var(--shiki-color-text)">{</span></span>
<span><span style="color: var(--shiki-color-text)"> cars(query: { </span><span style="color: var(--shiki-token-string)">carName</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">regex</span><span style="color: var(--shiki-color-text)">: </span><span style="color: var(--shiki-token-string-expression)">"[0-9]+"</span><span style="color: var(--shiki-color-text)"> } }) {</span></span>
<span><span style="color: var(--shiki-color-text)"> edges {</span></span>
<span><span style="color: var(--shiki-color-text)"> node {</span></span>
<span><span style="color: var(--shiki-color-text)"> id</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)">}</span></span>
<span></span>
<span><span style="color: var(--shiki-color-text)">{</span></span>
<span><span style="color: var(--shiki-color-text)"> cars(query: { </span><span style="color: var(--shiki-token-string)">carName</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">contains</span><span style="color: var(--shiki-color-text)">: </span><span style="color: var(--shiki-token-string-expression)">"YY"</span><span style="color: var(--shiki-color-text)"> } }) {</span></span>
<span><span style="color: var(--shiki-color-text)"> edges {</span></span>
<span><span style="color: var(--shiki-color-text)"> node {</span></span>
<span><span style="color: var(--shiki-color-text)"> id</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)">}</span></span>
<span></span>
Integer, Float, DateTime, Date, and Time Filters
Operator | Description |
---|---|
eq | =Equals |
ne | <>or != Not Equals |
lt | < Less Than |
lte | <= Less Than Equals |
gt | > Greater Than |
gte | >= Greater Than Equals |
between | {min:x, max: y} |
x <= n && n <= y Between x and y. | |
in | in: [x, y …. ] Allows you to specify multiple values (n == x or n == y) |
nin | nin: [x, y …. ] Allows you to specify multiple values (n != x and n != y) |
Examples
<span><span style="color: var(--shiki-color-text)">{</span></span>
<span><span style="color: var(--shiki-color-text)"> cars(query: { </span><span style="color: var(--shiki-token-string)">carNumber</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">gt</span><span style="color: var(--shiki-color-text)">: </span><span style="color: var(--shiki-token-constant)">10</span><span style="color: var(--shiki-color-text)"> } }) {</span></span>
<span><span style="color: var(--shiki-color-text)"> edges {</span></span>
<span><span style="color: var(--shiki-color-text)"> node {</span></span>
<span><span style="color: var(--shiki-color-text)"> id</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)">}</span></span>
<span></span>
<span><span style="color: var(--shiki-color-text)">{</span></span>
<span><span style="color: var(--shiki-color-text)"> cars(query: { </span><span style="color: var(--shiki-token-string)">carNumber</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">between</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">min</span><span style="color: var(--shiki-color-text)">: </span><span style="color: var(--shiki-token-constant)">5</span><span style="color: var(--shiki-color-text)">, </span><span style="color: var(--shiki-token-string)">max</span><span style="color: var(--shiki-color-text)">: </span><span style="color: var(--shiki-token-constant)">10</span><span style="color: var(--shiki-color-text)"> } } }) {</span></span>
<span><span style="color: var(--shiki-color-text)"> edges {</span></span>
<span><span style="color: var(--shiki-color-text)"> node {</span></span>
<span><span style="color: var(--shiki-color-text)"> id</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)">}</span></span>
<span></span>
<span><span style="color: var(--shiki-color-text)">{</span></span>
<span><span style="color: var(--shiki-color-text)"> cars(query: { </span><span style="color: var(--shiki-token-string)">carNumber</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">in</span><span style="color: var(--shiki-color-text)">: [</span><span style="color: var(--shiki-token-constant)">1</span><span style="color: var(--shiki-color-text)">, </span><span style="color: var(--shiki-token-constant)">2</span><span style="color: var(--shiki-color-text)">, </span><span style="color: var(--shiki-token-constant)">3</span><span style="color: var(--shiki-color-text)">] } }) {</span></span>
<span><span style="color: var(--shiki-color-text)"> edges {</span></span>
<span><span style="color: var(--shiki-color-text)"> node {</span></span>
<span><span style="color: var(--shiki-color-text)"> id</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)">}</span></span>
<span></span>
EnumFilter
Operator | Description |
---|---|
eq | =Equals enum value |
ne | <>or != Not Equals enum value |
in | in: [x, y …. ] Allows you to specify multiple enum values (n == x or n == y) |
nin | nin: [x, y …. ] Allows you to specify multiple enum values (n != x and n != y) |
UUIDFilter
Operator | Description |
---|---|
eq | =Equals enum value |
ne | <>or != Not Equals enum value |
in | in: [x, y …. ] Allows you to specify multiple id values (n == x or n == y) |
nin | nin: [x, y …. ] Allows you to specify multiple id values (n != x and n != y) |
BooleanFilter
Operator | Description |
---|---|
eq | =Equals enum value |
ne | <>or != Not Equals enum value |
ArrayFilter
Array fields support specialized filters for both length and content operations.
Operator | Description |
---|---|
len | Filter based on array length with sub-operators: eq, ne, lt, lte, gt, gte |
has | Filter based on array elements with sub-operators matching the element type |
exists | Check for the presence of elements in an array |
Examples
<span><span style="color: var(--shiki-color-text)">{</span></span>
<span><span style="color: var(--shiki-color-text)"> starships(query: {</span></span>
<span><span style="color: var(--shiki-color-text)"> </span><span style="color: var(--shiki-token-string)">manufacturers</span><span style="color: var(--shiki-color-text)">: {</span></span>
<span><span style="color: var(--shiki-color-text)"> </span><span style="color: var(--shiki-token-string)">len</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">lt</span><span style="color: var(--shiki-color-text)">: </span><span style="color: var(--shiki-token-constant)">3</span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }) {</span></span>
<span><span style="color: var(--shiki-color-text)"> edges {</span></span>
<span><span style="color: var(--shiki-color-text)"> node {</span></span>
<span><span style="color: var(--shiki-color-text)"> name</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)">}</span></span>
<span></span>
<span><span style="color: var(--shiki-color-text)">{</span></span>
<span><span style="color: var(--shiki-color-text)"> starships(query: {</span></span>
<span><span style="color: var(--shiki-color-text)"> </span><span style="color: var(--shiki-token-string)">manufacturers</span><span style="color: var(--shiki-color-text)">: {</span></span>
<span><span style="color: var(--shiki-color-text)"> </span><span style="color: var(--shiki-token-string)">has</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">contains</span><span style="color: var(--shiki-color-text)">: </span><span style="color: var(--shiki-token-string-expression)">"Corellian"</span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }) {</span></span>
<span><span style="color: var(--shiki-color-text)"> edges {</span></span>
<span><span style="color: var(--shiki-color-text)"> node {</span></span>
<span><span style="color: var(--shiki-color-text)"> name</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)">}</span></span>
<span></span>
<span><span style="color: var(--shiki-color-text)">{</span></span>
<span><span style="color: var(--shiki-color-text)"> starships(query: {</span></span>
<span><span style="color: var(--shiki-color-text)"> </span><span style="color: var(--shiki-token-string)">manufacturers</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">exists</span><span style="color: var(--shiki-color-text)">: </span><span style="color: var(--shiki-token-constant)">true</span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }) {</span></span>
<span><span style="color: var(--shiki-color-text)"> edges {</span></span>
<span><span style="color: var(--shiki-color-text)"> node {</span></span>
<span><span style="color: var(--shiki-color-text)"> name</span></span>
<span><span style="color: var(--shiki-color-text)"> manufacturers</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)">}</span></span>
<span></span>
Note:
- The
has
operator returnstrue
if at least one element in the array matches the specified condition. - If an array field's value is null, its
len
is considered 0. - The
exists
operator can be used to check for the presence of elements in an array.
Advanced Filters
And, Or and Not Operators
You can combine filter conditions with logical AND, logical OR, and negation (NOT) across all types.
Operator | Description |
---|---|
and | and:[{condition1, condition2 }] |
or | or:[{condition1, condition2 }] |
not | not:[{condition}] |
Examples
If you want to query data with different conditions, you don't need to use and
or or
operators. You may simply add multiple conditions.
<span><span style="color: var(--shiki-color-text)">{</span></span>
<span><span style="color: var(--shiki-color-text)"> cars(query: {</span></span>
<span><span style="color: var(--shiki-color-text)"> </span><span style="color: var(--shiki-token-string)">carName</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">eq</span><span style="color: var(--shiki-color-text)">: </span><span style="color: var(--shiki-token-string-expression)">"XXX"</span><span style="color: var(--shiki-color-text)"> },</span></span>
<span><span style="color: var(--shiki-color-text)"> </span><span style="color: var(--shiki-token-string)">carNumber</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">gt</span><span style="color: var(--shiki-color-text)">: </span><span style="color: var(--shiki-token-constant)">10</span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }) {</span></span>
<span><span style="color: var(--shiki-color-text)"> edges {</span></span>
<span><span style="color: var(--shiki-color-text)"> node {</span></span>
<span><span style="color: var(--shiki-color-text)"> id</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)">}</span></span>
<span></span>
<span><span style="color: var(--shiki-color-text)">{</span></span>
<span><span style="color: var(--shiki-color-text)"> cars(query: {</span></span>
<span><span style="color: var(--shiki-color-text)"> </span><span style="color: var(--shiki-token-string)">and</span><span style="color: var(--shiki-color-text)">: [</span></span>
<span><span style="color: var(--shiki-color-text)"> { </span><span style="color: var(--shiki-token-string)">carName</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">eq</span><span style="color: var(--shiki-color-text)">: </span><span style="color: var(--shiki-token-string-expression)">"XXX"</span><span style="color: var(--shiki-color-text)"> } }</span></span>
<span><span style="color: var(--shiki-color-text)"> { </span><span style="color: var(--shiki-token-string)">carName</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">eq</span><span style="color: var(--shiki-color-text)">: </span><span style="color: var(--shiki-token-string-expression)">"YYY"</span><span style="color: var(--shiki-color-text)"> } }</span></span>
<span><span style="color: var(--shiki-color-text)"> ]</span></span>
<span><span style="color: var(--shiki-color-text)"> }) {</span></span>
<span><span style="color: var(--shiki-color-text)"> edges {</span></span>
<span><span style="color: var(--shiki-color-text)"> node {</span></span>
<span><span style="color: var(--shiki-color-text)"> id</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)">}</span></span>
<span></span>
<span><span style="color: var(--shiki-color-text)">{</span></span>
<span><span style="color: var(--shiki-color-text)"> cars(query: {</span></span>
<span><span style="color: var(--shiki-color-text)"> </span><span style="color: var(--shiki-token-string)">not</span><span style="color: var(--shiki-color-text)">: [</span></span>
<span><span style="color: var(--shiki-color-text)"> { </span><span style="color: var(--shiki-token-string)">carName</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">eq</span><span style="color: var(--shiki-color-text)">: </span><span style="color: var(--shiki-token-string-expression)">"XXX"</span><span style="color: var(--shiki-color-text)"> } }</span></span>
<span><span style="color: var(--shiki-color-text)"> ]</span></span>
<span><span style="color: var(--shiki-color-text)"> }) {</span></span>
<span><span style="color: var(--shiki-color-text)"> edges {</span></span>
<span><span style="color: var(--shiki-color-text)"> node {</span></span>
<span><span style="color: var(--shiki-color-text)"> id</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)">}</span></span>
<span></span>
If the conditions are matched in one of the not query, then matching data will be excluded from the response.
<span><span style="color: var(--shiki-token-keyword)">query</span><span style="color: var(--shiki-color-text)"> </span><span style="color: var(--shiki-token-function)">cars</span><span style="color: var(--shiki-color-text)"> {</span></span>
<span><span style="color: var(--shiki-color-text)"> cars(query: {</span></span>
<span><span style="color: var(--shiki-color-text)"> </span><span style="color: var(--shiki-token-string)">not</span><span style="color: var(--shiki-color-text)">: [</span></span>
<span><span style="color: var(--shiki-color-text)"> { </span><span style="color: var(--shiki-token-string)">carName</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">eq</span><span style="color: var(--shiki-color-text)">: </span><span style="color: var(--shiki-token-string-expression)">"mercedes"</span><span style="color: var(--shiki-color-text)">} }</span></span>
<span><span style="color: var(--shiki-color-text)"> { </span><span style="color: var(--shiki-token-string)">carNumber</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">eq</span><span style="color: var(--shiki-color-text)">: </span><span style="color: var(--shiki-token-constant)">10</span><span style="color: var(--shiki-color-text)"> } }</span></span>
<span><span style="color: var(--shiki-color-text)"> ]</span></span>
<span><span style="color: var(--shiki-color-text)"> }) {</span></span>
<span><span style="color: var(--shiki-color-text)"> edges {</span></span>
<span><span style="color: var(--shiki-color-text)"> node {</span></span>
<span><span style="color: var(--shiki-color-text)"> id</span></span>
<span><span style="color: var(--shiki-color-text)"> carName</span></span>
<span><span style="color: var(--shiki-color-text)"> carNumber</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)">}</span></span>
<span></span>
You can also nest the and/or/not queries.
<span><span style="color: var(--shiki-color-text)">{</span></span>
<span><span style="color: var(--shiki-color-text)"> cars(</span></span>
<span><span style="color: var(--shiki-color-text)"> query: { </span><span style="color: var(--shiki-token-string)">or</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">not</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">carName</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">eq</span><span style="color: var(--shiki-color-text)">: </span><span style="color: var(--shiki-token-string-expression)">"XXX"</span><span style="color: var(--shiki-color-text)"> } }, </span><span style="color: var(--shiki-token-string)">carNumber</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">gt</span><span style="color: var(--shiki-color-text)">: </span><span style="color: var(--shiki-token-constant)">10</span><span style="color: var(--shiki-color-text)"> } } }</span></span>
<span><span style="color: var(--shiki-color-text)"> ) {</span></span>
<span><span style="color: var(--shiki-color-text)"> edges {</span></span>
<span><span style="color: var(--shiki-color-text)"> node {</span></span>
<span><span style="color: var(--shiki-color-text)"> id</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)">}</span></span>
<span></span>
Null condition
For all types except Boolean
, it is possible to filter on null values with the eq
and ne
operators.
Note: For array fields and nested fields, you can use the
exists
operator to check for the existence of elements.
Examples
<span><span style="color: var(--shiki-color-text)">{</span></span>
<span><span style="color: var(--shiki-color-text)"> cars(query: { </span><span style="color: var(--shiki-token-string)">carNumber</span><span style="color: var(--shiki-color-text)">: { </span><span style="color: var(--shiki-token-string)">eq</span><span style="color: var(--shiki-color-text)">: </span><span style="color: var(--shiki-token-constant)">null</span><span style="color: var(--shiki-color-text)"> } }) {</span></span>
<span><span style="color: var(--shiki-color-text)"> edges {</span></span>
<span><span style="color: var(--shiki-color-text)"> node {</span></span>
<span><span style="color: var(--shiki-color-text)"> id</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)"> }</span></span>
<span><span style="color: var(--shiki-color-text)">}</span></span>
<span></span>