Filter Response
In Zoho CRM GraphQL queries, the result set of _Records type can be filtered according to your needs using where clause. Each {module}__connection supports {module}__Filter type argument. For example, in the _Records schema, Products module has Products_Filter. In the Products_Filter possible fields and operator types are defined.
type Products__Filter
Copiedinput Products__Filter {
Qty_in_Demand: _FloatOperators
Product_Category: _StringOperators
Modified_Time: _DateLongOperators
or: [Products__Filter]
Created_Time: _DateLongOperators
Commission_Rate: _FloatOperators
Product_Name: _StringOperators
Sales_Start_Date: _DateLongOperators
Support_Start_Date: _DateLongOperators
Product_Active: _BooleanOperators
Usage_Unit: _StringOperators
Product_Code: _StringOperators
Qty_Ordered: _FloatOperators
and: [Products__Filter]
Manufacturer: _StringOperators
Locked__s: _BooleanOperators
Qty_in_Stock: _FloatOperators
id: _DateLongOperators
Support_Expiry_Date: _DateLongOperators
Sales_End_Date: _DateLongOperators
Unit_Price: _FloatOperators
Reorder_Level: _FloatOperators
Taxable: _BooleanOperators
}
Field Operators
Field operators refer to the operators that can be applied to fields within a query. Fields operators when combined with each field and specified value form each predicate in the where clause of the query. The field operators that are available in Zoho CRM GraphQL are :
Operator | Description |
---|---|
equals | The expression is true if the field value is equal to the specified value. |
not_equals | The expression is true if the field value is not equal to the specified value. |
greater_than | The expression is true if the field value is greater than the specified value. |
greater_equal | The expression is true if the field value is greater than or equal to the specified value. |
less_than | The expression is true if the field value is less than the specified value. |
less_equal | The expression is true if the field value is less than or equal to the specified value. |
like | The expression is true if the string field value matches the pattern specified. |
not_like | The expression is true if the string field value does not match the pattern specified. |
in | The expression is true if the field value is present in a list specified. |
not_in | The expression is true if the field value is not present in a list specified. |
Each _Records Type has a corresponding Filter where the filtering capacity of each field is defined. For example in the Products_Filter shown above the field Qty_in_Demand is _FloatOperators. The operators supported for Float are as below
Type _FloatOperators
Copiedinput _FloatOperators {
equals: Float
not_equals: Float
in: [Float]
not_in: [Float]
greater_than: Float
greater_equal: Float
less_equal: Float
less_than: Float
}
Field types and Operators
Field Type | Field Operator | Allowed Operators |
---|---|---|
Int | _IntOperators | equals,not_equals,in,not_in,greater_than,greater_equal,less_equal,less_than |
Encrypted Int | _EncryptedIntOperators | equals,not_equals |
Float | _FloatOperators | equals,not_equals,in,not_in,greater_than,greater_equal,less_equal,less_than |
encrypted float | _EncryptedFloatOperators | equals,not_equals |
long | _LongOperators | equals,not_equals,in,not_in,greater_than,greater_equal,less_equal,less_than |
encrypted long | _EncryptedLongOperators | equals,not_equals |
string | _StringOperators | equals,not_equals,in,not_in,like,not_like |
date long | _DateLongOperators | equals,not_equals,in,not_in,greater_than,greater_equal,less_equal,less_than |
boolean | _BooleanOperators | equals |
Each Zoho CRM Data Type is mapped to a GraphQL field type as shown in the table below:
GraphQL Field Types | Zoho CRM Data Types |
---|---|
String Field Types | Single Line |
Multi Line | |
String | |
Picklist | |
URL | |
Date | |
DateTime | |
Integer Field Types | Number |
Double Field Types | Decimal |
Currency | |
Percent | |
Long Field Types | Long Integer |
Boolean Field Types | Checkbox |
Like Operator
The like operator behaves similarly to how it behaves in COQL. The % wildcard can be used with the like operator to achieve functionalities similar to the contains, starts_with, and ends_with operators. For instance, consider that you are filtering based on Email field. '%john, queries for email field values ending with 'john', 'john%' queries for values starting with 'john', and '%john%' translates to contains john. If you query for 'john' like works as equals. Please note that for the Not Like operator, it only works if you give '%' at both ends (not contains). Using '%' only at the beginning (not starting with) or at the end (not ending with) doesn't work and will throw INVALID_QUERY error. Not using wildcard will make not like work like not equal.
_StringOperators
Copiedinput _StringOperators {
equals: String
not_equals: String
like: String
not_like: String
in: [String]
not_in: [String]
}
input _BooleanOperators {
equals: Boolean
}
input _DateLongOperators {
equals: String
not_equals: String
in: [String]
not_in: [String]
greater_than: String
greater_equal: String
less_equal: String
less_than: String
}
input _EncryptedFloatOperators {
equals: Float
not_equals: Float
}
input _EncryptedIntOperators {
equals: Int
not_equals: Int
}
_BooleanOperators
Copiedinput _BooleanOperators {
equals: Boolean
}
_DateLongOperators
Copiedinput _DateLongOperators {
equals: String
not_equals: String
in: [String]
not_in: [String]
greater_than: String
greater_equal: String
less_equal: String
less_than: String
}
_EncryptedFloatOperators
Copiedinput _EncryptedFloatOperators {
equals: Float
not_equals: Float
}
_EncryptedIntOperators
Copiedinput _EncryptedIntOperators {
equals: Int
not_equals: Int
}
_EncryptedLongOperators
Copiedinput _EncryptedLongOperators {
equals: Long
not_equals: Long
}
_IntOperators
Copiedinput _IntOperators {
equals: Int
not_equals: Int
in: [Int]
not_in: [Int]
greater_than: Int
greater_equal: Int
less_equal: Int
less_than: Int
}
_FloatOperators
Copiedinput _FloatOperators {
equals: Float
not_equals: Float
in: [Float]
not_in: [Float]
greater_than: Float
greater_equal: Float
less_equal: Float
less_than: Float
}
_LongOperators
Copiedinput _LongOperators {
equals: Long
not_equals: Long
in: [Long]
not_in: [Long]
greater_than: Long
greater_equal: Long
less_equal: Long
less_than: Long
}
Boolean Operators
Boolean Operators combines the several predicates in your where clause. Supported Boolean Operator in Zoho CRM GraphQL are AND, OR. You can use the OR function to combine filters, and use the AND function to overlap filters.
AND operator
Syntax
where: { and: [ {filter1}, {filter2} ] }
OR operator
Syntax
where: { or: [filter1, filter2, filter3] }
Query contacts where last name starts with Di and mobile contains the digit 5 or phone number equals 555-555-5555
Copied
{
Records {
Contacts(
where: {
and: [
{ Last_Name: { like: "Di%" } }
{
or: [{ Phone: { equals: "555-555-5555" } }, { Mobile: { like: "%5%" } }]
}
]
}
) {
_data {
Email {
value
}
Last_Name {
value
}
id {
value
}
Phone {
value
}
Mobile {
value
}
}
}
}
}
Response
Copied{
"data": {
"Records": {
"Contacts": {
"_data": [
{
"Email": {
"value": "leota-dilliard@noemail.com"
},
"Last_Name": {
"value": "Dilliard"
},
"id": {
"value": "5843104000000425353"
},
"Phone": {
"value": "555-555-5555"
},
"Mobile": {
"value": "555-555-5555"
}
}
]
}
}
}
}
More examples
Query Leads by sending list of IDs
Copiedquery {
Records {
Leads(where: { id: { equals: "2484261000000496222" } }) {
_data {
id {
value
}
}
}
}
}
Query lead if its id present in list of ids
Copiedquery {
Records {
Leads(where: { id: { in: [ "2484261000000496222", "2484261000000496223" ] } }) {
_data {
id {
value
}
}
}
}
}
Query Leads where full name is like given string
Copiedquery {
Records {
Leads(where: { Full_Name: { like: "%John%" } }) {
_data {
id {
value
}
}
}
}
}
Query Leads where full name is not null
Copiedquery {
Records {
Leads(where: { Full_Name: { not_equals: "null" } }) {
_data {
id {
value
}
}
}
}
}
Query Leads where number of employees are less than 10
Copiedquery {
Records {
Leads(where: { No_of_Employees: { less_than: 10 } }) {
_data {
id {
value
}
}
}
}
}