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

OperatorDescription
eq= Equals
ne<> or != Not Equals
inAllows you to specify multiple string values
ninAllows you to specify multiple string values
containsContains target string
regexRegular 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)">&quot;XXX&quot;</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)">&quot;[0-9]+&quot;</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)">&quot;YY&quot;</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

OperatorDescription
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.
inin: [x, y …. ] Allows you to specify multiple values (n == x or n == y)
ninnin: [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

OperatorDescription
eq=Equals enum value
ne<>or != Not Equals enum value
inin: [x, y …. ] Allows you to specify multiple enum values (n == x or n == y)
ninnin: [x, y …. ] Allows you to specify multiple enum values (n != x and n != y)

UUIDFilter

OperatorDescription
eq=Equals enum value
ne<>or != Not Equals enum value
inin: [x, y …. ] Allows you to specify multiple id values (n == x or n == y)
ninnin: [x, y …. ] Allows you to specify multiple id values (n != x and n != y)

BooleanFilter

OperatorDescription
eq=Equals enum value
ne<>or != Not Equals enum value

ArrayFilter

Array fields support specialized filters for both length and content operations.

OperatorDescription
lenFilter based on array length with sub-operators: eq, ne, lt, lte, gt, gte
hasFilter based on array elements with sub-operators matching the element type
existsCheck 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)">&quot;Corellian&quot;</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 returns true 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.

OperatorDescription
andand:[{condition1, condition2 }]
oror:[{condition1, condition2 }]
notnot:[{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)">&quot;XXX&quot;</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)">&quot;XXX&quot;</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)">&quot;YYY&quot;</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)">&quot;XXX&quot;</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)">&quot;mercedes&quot;</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)">&quot;XXX&quot;</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>