Backend Support for Advanced Filters
What are Advanced Filters:
To provide users with greater flexibility and control over the customers data, advance filters have been introduced in system that when applied, returns us only those customers that fits the criteria.
More about Filter Object:
The filter object has two primary fields:
Filter Name - Always unique and case sensitive
Filter Query - A complex query containing multiple query conditions combined together with “and”, “or“. The query is a string with predefined JSON syntax.
Attributes that can be used in filters:
By default, following customerSchema attributes are set “isSearchAble = true” and can be used in filters:
firstName
phoneNumber
labels
To use any other customerSchema attribute in filters, first one must edit the customerSchema attribute and set “isSearchAble” to “true”.
Note: To enhance system performance and reduce the filter execution time, only those customer attributes can be used in filter queries whose “isSearchAble” flag is set to “true”.
Filter Query Syntax Guidelines:
Logical Operators:
Use
"or"
and"and"
keys to define logical groupings. Each should hold an array of conditions or nested groups.
Example:
{ "or": [ <condition1>, <condition2>, { "and": [ <condition3>, <condition4> ] } ] }
Conditions:
Define each condition as an object with the field name as the key and an operation-object as the value.
Supported operators:
equalTo: Exact match with the specified value.
notEqualTo: Match if the value does not equal the specified value.
greaterThan: Match if the value is greater than the specified value.
greaterThanOrEqualTo: Match if the value is greater than or equal to the specified value.
lessThan: Match if the value is less than the specified value.
lessThanOrEqualTo: Match if the value is less than or equal to the specified value.
startsWith: Match if the string begins with the specified characters.
endsWith: Match if the string ends with the specified characters.
contains: Partial match within a string containing the specified substring.
notContains: Match if the string does not contain the specified substring.
isEmpty: Match if the field has no value or is empty.
isNotEmpty: Match if the field has a value or is not empty.
Examples usage each operator:
{ "firstName": { "equalTo": "Faraz" } }
{ "status": { "notEqualTo": "inactive" } }
{ "age": { "greaterThan": 25 } }
{ "age": { "greaterThanOrEqualTo": 18 } }
{ "price": { "lessThan": 100 } }
{ "price": { "lessThanOrEqualTo": 50 } }
{ "phoneNumber": { "startsWith": "123" } }
{ "email": { "endsWith": "@example.com" } }
{ "description": { "contains": "urgent" } }
{ "notes": { "notContains": "confidential" } }
{ "middleName": { "isEmpty": true } }
{ "lastName": { "isNotEmpty": true } }
Nested Queries:
Conditions can be nested within "and"
or "or"
arrays to create more complex filters.
Example Structure:
A query with both "or"
and "and"
conditions:
{
"or": [
{ "field1": { "equalTo": "value1" } },
{
"and": [
{ "field2": { "contains": "value2" } },
{ "field3": { "equalTo": "value3" } }
]
},
{ "field4": { "startsWith": "value4" } }
]
}
Filters CRUD APIs:
GraphQL is used in implementation of all the filter crud APIs. Following are the APIs available:
CreateFilter API:

CreateFilter API
getFilterByName:

getFilterByName API
getFilterByID:

getFilterByID API
getAllFilters (paginated response):

getAllFilters API
updateFilterByID:

updateFilterByID
deleteFilterByID:

deleteFilterByID
Want to try the filters CRUD yourself?Check this postman collection and get some hands on the APIs:
Using Filters to Get the Customers' Profiles:
We have provide a new GraphQL based API that takes filterQuery (either takken from saved filter or newly made at runtime) as a parameter and in return provides us paginated response of customers’ profiles.
Here is how this API look like:
getCustomerByFilterQuery:

getCustomersByFilterQuery API
Note: All the constraints that have been mentioned for filterQuery in Filters section also apply to the filterQuery passed in this API.
Want to use this API? checkout this postman collection: