Query filters
To filter data, you can use query filters.
The available operator sets for query filters depend on the data type.
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 |
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.
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>