Filtering
Filtering allows you to query your content for items which match a set of parameters. You can define these parameters by passing the filter
argument to your query.
Basic Filtering
The available filter options will depend on the fields that were defined within the content type that is being filtered and the types of those fields. Each field type supports a different set of filters.
Supplying just one filter will only return items which match the specified constraint. For example, the below query will only return books which have a title that equals “My Awesome Book”.
query {
bookCollection(filter: {
title: { _eq: "My Awesome Book" }
}) {
items {
title
publishedDate
}
}
}
If you specify multiple filters, they will be combined using an AND expression. Extending the above example, the following query will only return books that were also published after 1st January 2020.
query {
bookCollection(filter: {
title: { _eq: "My Awesome Book" }
publishedDate: { _gt: "2020-01-01" }
}) {
items {
title
publishedDate
}
}
}
AND / OR
You can also go further and provide the special _AND
and _OR
filters which allow to create more complicated filter expressions.
The below example uses the _OR
filter and will only return books which were published after 1st January 2020 but were also given a 5 star rating or are in the “Techology” genre.
query {
bookCollection(filter: {
publishedDate: { _gt: "2020-01-01" }
_OR: [
{ rating: { _eq: 5 } }
{ genre: { _eq: "Technology" } }
]
}) {
items {
title
publishedDate
}
}
}
Available Filters for Field Types
As mentioned earlier, the types of filters that are available depends on the fields and the types of those fields that are defined within the content model for the content type being filtered.
This section will cover the list of available filters for each possible field type.
Boolean
_exists
_eq
Filter for records that have the specified field populated or not.
query {
bookCollection(filter: {
booleanField: { _exists: true }
}) {
# ...
}
}
Filter for records where the specified field matches the provided value exactly.
query {
bookCollection(filter: {
booleanField: { _eq: false }
}) {
# ...
}
}
Date/Time
_exists
_eq
_neq
_gt
_gte
_lt
_lte
Filter for records that have the specified field populated or not.
query {
bookCollection(filter: {
dateTimeField: { _exists: true }
}) {
# ...
}
}
Filter for records where the specified field matches the provided value exactly.
The value must be provided in as a valid ISO-8601 string, for example the following values are all valid inputs:
2020-01-01T00:00:00.000Z
2020-01-01T00:00:00.000+0300
2020-01-01T00:00:00
2020-01-01T00:00
2020-01-01
query {
bookCollection(filter: {
dateTimeField: { _eq: "2020-01-01" }
}) {
# ...
}
}
Filter for records where the specified field does not match the provided value.
Please see the _eq
filter for examples of valid input values.
query {
bookCollection(filter: {
dateTimeField: { _neq: "2020-01-01" }
}) {
# ...
}
}
Filter for records where the provided value is greater than the specified fields value.
Please see the _eq
filter for examples of valid input values.
query {
bookCollection(filter: {
dateTimeField: { _gt: "2020-01-01" }
}) {
# ...
}
}
Filter for records where the provided value is greater than or equal to the specified fields value.
Please see the _eq
filter for examples of valid input values.
query {
bookCollection(filter: {
dateTimeField: { _gte: "2020-01-01" }
}) {
# ...
}
}
Filter for records where the provided value is less than the specified fields value.
Please see the _eq
filter for examples of valid input values.
query {
bookCollection(filter: {
dateTimeField: { _lt: "2020-01-01" }
}) {
# ...
}
}
Filter for records where the provided value is less than or equal to the specified fields value.
Please see the _eq
filter for examples of valid input values.
query {
bookCollection(filter: {
dateTimeField: { _lte: "2020-01-01" }
}) {
# ...
}
}
Decimal
_exists
_eq
_neq
_gt
_gte
_lt
_lte
Filter for records that have the specified field populated or not.
query {
bookCollection(filter: {
decimalField: { _exists: true }
}) {
# ...
}
}
Filter for records where the specified field matches the provided value exactly.
query {
bookCollection(filter: {
decimalField: { _eq: "1.234" }
}) {
# ...
}
}
Filter for records where the specified field does not match the provided value.
query {
bookCollection(filter: {
decimalField: { _neq: "1.234" }
}) {
# ...
}
}
Filter for records where the provided value is greater than the specified fields value.
query {
bookCollection(filter: {
decimalField: { _gt: "1.234" }
}) {
# ...
}
}
Filter for records where the provided value is greater than or equal to the specified fields value.
query {
bookCollection(filter: {
decimalField: { _gte: "1.234" }
}) {
# ...
}
}
Filter for records where the provided value is less than the specified fields value.
query {
bookCollection(filter: {
decimalField: { _lt: "1.234" }
}) {
# ...
}
}
Filter for records where the provided value is less than or equal to the specified fields value.
query {
bookCollection(filter: {
decimalField: { _lte: "1.234" }
}) {
# ...
}
}
Image
Image fields do not currently support filtering, though it will be coming in a future release.
Integer
_exists
_eq
_neq
_gt
_gte
_lt
_lte
Filter for records that have the specified field populated or not.
query {
bookCollection(filter: {
integerField: { _exists: true }
}) {
# ...
}
}
Filter for records where the specified field matches the provided value exactly.
query {
bookCollection(filter: {
integerField: { _eq: 42 }
}) {
# ...
}
}
Filter for records where the specified field does not match the provided value.
query {
bookCollection(filter: {
integerField: { _neq: 42 }
}) {
# ...
}
}
Filter for records where the provided value is greater than the specified fields value.
query {
bookCollection(filter: {
integerField: { _gt: 42 }
}) {
# ...
}
}
Filter for records where the provided value is greater than or equal to the specified fields value.
query {
bookCollection(filter: {
integerField: { _gte: 42 }
}) {
# ...
}
}
Filter for records where the provided value is less than the specified fields value.
query {
bookCollection(filter: {
integerField: { _lt: 42 }
}) {
# ...
}
}
Filter for records where the provided value is less than or equal to the specified fields value.
query {
bookCollection(filter: {
integerField: { _lte: 42 }
}) {
# ...
}
}
Markdown
_exists
_contains
_startsWith
_endsWith
Filter for records that have the specified field populated or not.
query {
bookCollection(filter: {
markdownField: { _exists: true }
}) {
# ...
}
}
Filter for records where specified fields value contains the provided value.
query {
bookCollection(filter: {
markdownField: { _contains: "string value" }
}) {
# ...
}
}
Filter for records where specified fields value starts with the provided value.
query {
bookCollection(filter: {
markdownField: { _startsWith: "string value" }
}) {
# ...
}
}
Filter for records where specified fields value ends with the provided value.
query {
bookCollection(filter: {
markdownField: { _endsWith: "string value" }
}) {
# ...
}
}
Relationship
Relationship fields currently only support filtering based on the ID of child content items.
Note: Support for filtering relationship fields by non-ID fields will be coming in a future release.
_eq
Filter for records which contain a relationship to the specified content item.
query {
bookCollection(filter: {
relationshipField: {
id: { _eq: "a90a173d-be9a-40d3-b012-cf3c5bce9d1a" }
}
}) {
# ...
}
}
Select (Dropdown)
_exists
_eq
_neq
_gt
_gte
_lt
_lte
_contains
_startsWith
_endsWith
Filter for records that have the specified field populated or not.
query {
bookCollection(filter: {
selectField: { _exists: true }
}) {
# ...
}
}
Filter for records where the specified field matches the provided value exactly.
query {
bookCollection(filter: {
selectField: { _eq: "string value" }
}) {
# ...
}
}
Filter for records where the specified field does not match the provided value.
query {
bookCollection(filter: {
selectField: { _neq: "string value" }
}) {
# ...
}
}
Filter for records where the provided value is greater than the specified fields value.
query {
bookCollection(filter: {
selectField: { _gt: "string value" }
}) {
# ...
}
}
Filter for records where the provided value is greater than or equal to the specified fields value.
query {
bookCollection(filter: {
selectField: { _gte: "string value" }
}) {
# ...
}
}
Filter for records where the provided value is less than the specified fields value.
query {
bookCollection(filter: {
selectField: { _lt: "string value" }
}) {
# ...
}
}
Filter for records where the provided value is less than or equal to the specified fields value.
query {
bookCollection(filter: {
selectField: { _lte: "string value" }
}) {
# ...
}
}
Filter for records where specified fields value contains the provided value.
query {
bookCollection(filter: {
selectField: { _contains: "string value" }
}) {
# ...
}
}
Filter for records where specified fields value starts with the provided value.
query {
bookCollection(filter: {
selectField: { _startsWith: "string value" }
}) {
# ...
}
}
Filter for records where specified fields value ends with the provided value.
query {
bookCollection(filter: {
selectField: { _endsWith: "string value" }
}) {
# ...
}
}
Text (Single Line)
_exists
_eq
_neq
_gt
_gte
_lt
_lte
_contains
_startsWith
_endsWith
Filter for records that have the specified field populated or not.
query {
bookCollection(filter: {
textSingleField: { _exists: true }
}) {
# ...
}
}
Filter for records where the specified field matches the provided value exactly.
query {
bookCollection(filter: {
textSingleField: { _eq: "string value" }
}) {
# ...
}
}
Filter for records where the specified field does not match the provided value.
query {
bookCollection(filter: {
textSingleField: { _neq: "string value" }
}) {
# ...
}
}
Filter for records where the provided value is greater than the specified fields value.
query {
bookCollection(filter: {
textSingleField: { _gt: "string value" }
}) {
# ...
}
}
Filter for records where the provided value is greater than or equal to the specified fields value.
query {
bookCollection(filter: {
textSingleField: { _gte: "string value" }
}) {
# ...
}
}
Filter for records where the provided value is less than the specified fields value.
query {
bookCollection(filter: {
textSingleField: { _lt: "string value" }
}) {
# ...
}
}
Filter for records where the provided value is less than or equal to the specified fields value.
query {
bookCollection(filter: {
textSingleField: { _lte: "string value" }
}) {
# ...
}
}
Filter for records where specified fields value contains the provided value.
query {
bookCollection(filter: {
textSingleField: { _contains: "string value" }
}) {
# ...
}
}
Filter for records where specified fields value starts with the provided value.
query {
bookCollection(filter: {
textSingleField: { _startsWith: "string value" }
}) {
# ...
}
}
Filter for records where specified fields value ends with the provided value.
query {
bookCollection(filter: {
textSingleField: { _endsWith: "string value" }
}) {
# ...
}
}
Text (Multi Line)
_exists
_contains
_startsWith
_endsWith
Filter for records that have the specified field populated or not.
query {
bookCollection(filter: {
textMultiField: { _exists: true }
}) {
# ...
}
}
Filter for records where specified fields value contains the provided value.
query {
bookCollection(filter: {
textMultiField: { _contains: "string value" }
}) {
# ...
}
}
Filter for records where specified fields value starts with the provided value.
query {
bookCollection(filter: {
textMultiField: { _startsWith: "string value" }
}) {
# ...
}
}
Filter for records where specified fields value ends with the provided value.
query {
bookCollection(filter: {
textMultiField: { _endsWith: "string value" }
}) {
# ...
}
}