For advanced filtering use the
where allows you to construct complex filters on
fields by using the boolean operators
NOT. There is an implicit
applied to all adjacent keys. Using a where input will override the
onlyEnabled default filter.
All shape fields are available to filter against, in addition to three special operator fields:
ANDtakes an array of conditions that must appear in the matching results. Nested boolean operators can be used to create complex filters.
ORtakes an array of conditions that should appear in the matching results. Nested boolean operators can be used to create complex filters.
NOTtakes a single condition that must not appear in the matching results.
Filters can be applied using comparison operators:
|An array of possible exact match values|
|Greater than or equal|
|Less than or equal|
|Full text search with fuzzy string matching|
|Regular expression string matching. There are some limitations - see the regular expression section below for more details.|
Not all operators are available on every field type. For example, boolean fields only provide the
Filters are available for common types like
Bool. They're also available for more
Relationships can be used in list queries like any other nested object. In the example below,
company is a
relationship field on the Job shape:
Nested relationships are not supported. For example, if the Company shape also had a relationship field, that would not be available within the Job list query.
Keep in mind that including multiple relationship filters may degrade the performance of your query.
In some cases, shapes may have fields with conflicting names because of a relationship with another shape that has an
identical field name. This is mostly an issue when searching across multiple shapes. A common example is when two types
each have an
image field, but one is a file or asset, and the other is a url. In these cases, the field name will be
prefixed with the shape name, like the example below. To avoid confusion, it is best to give fields a unique name.
TakeShape queries support date ranges and date math expressions. The expression starts with an "anchor" date, which can
be either now or a date string (in
yyyy-mm-dd ISO 8601 format) ending
||. It can be followed by a math expression, supporting
/ (rounding). The units supported are
If Workflows are enabled, the
_status field can be used to compare the status of a content item within a Workflow.
Since workflow steps have a specified order, the status field can be treated as a range. In the example below, if the
workflow had steps "draft", "edit", "legal", and "published", the query would return items in either the "edit" or
TakeShape queries support all Unicode characters. However, the following characters are reserved as operators:
To use one of these characters literally, escape it with a preceding backslash or surround it with double quotes. For example:
Here is an example Job list query with a
where clause provided as a GraphQL variable, and below are sample filters
that could be applied to this query.
The simplest filter would be to have one or more fields adjacent to one another. This will apply the implicit
condition to return "hot" jobs whose title contains "engineer".
Now we can make this an
OR condition. Note how each field is contained within its own object.
Boolean operators can be nested to create complex filters. While specifying the
AND operator here isn't entirely
necessary, it improves the readability of the filter, especially when there are multiple conditions.