GraphQL & Rest API Filtering

We support a number of operators to filter your content using GraphQL or the Rest API. This documentation goes over the basic usage and filtering of them.

To query a nested property, you would use the . operator eg. fields.name. To create a basic expression you would use square brackets to denote the operator from the operands.

eg. an equality query fields.name[eq]"Kevin" // You will need to escape the quotation marks when using a string as an operand { people(filter:"fields.name[eq]\"Kevin\""){ contentID fields{ firstName } } }

To query numeric values, do not wrap your operand in quotation marks.

eg. a numeric query fields.age[eq]28 { people(filter:"fields.age[eq]28"){ contentID fields{ firstName } } }

And of course you can chain your operators using the logical expressions and and or eg. { people(filter:"fields.age[eq]28 and fields.name[eq]\"Kevin\""){ contentID fields{ firstName } } }

You can also use brackets to group your expressions together

eg. This will get a people with the name Kevin and age 28, as well as people with the name Sarah and age 26 { people(filter:"(fields.name[eq]\"Kevin\" and fields.age[eq]28) or (fields.name[eq]\"Sarah\" and fields.age[eq]26)"){ contentID fields{ firstName } } }

A recent addition to our API are the IN and CONTAINS operators.

IN -> for querying a field whose value is a singleton. The API will stringify the left hand operand to compare against the string csv of the right hand operand. eg. { people(filter:"fields.age[in]\"28,24,60,54\""){ contentID fields{ firstName } } }

CONTAINS -> for querying a field whose value is a csv. This is useful for querying against linked content. In the API it is usually denoted as yourField_ValueField. However this will work for any field whose value is csv.

eg. This query will get people that have friends with the content ID of 32,45,65,33 { people(filter:"fields.friends_valueField[contains]\"32,45,65,33\""){ contentID fields{ firstName } } }

Equality [eq]

Non Equality [ne]

Less Than/Greater Than [lt] [gt]

Less than/Greater than or Equal To [lte] [gte]

Range [range]

Like [like]

In [in]

Contains [contains]