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 :

OperatorDescription
equalsThe expression is true if the field value is equal to the specified value.
not_equalsThe expression is true if the field value is not equal to the specified value.
greater_thanThe expression is true if the field value is greater than the specified value.
greater_equalThe expression is true if the field value is greater than or equal to the specified value.
less_thanThe expression is true if the field value is less than the specified value.
less_equalThe expression is true if the field value is less than or equal to the specified value.
likeThe expression is true if the string field value matches the pattern specified.
not_likeThe expression is true if the string field value does not match the pattern specified.
inThe expression is true if the field value is present in a list specified.
not_inThe 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 TypeField OperatorAllowed Operators
Int_IntOperatorsequals,not_equals,in,not_in,greater_than,greater_equal,less_equal,less_than
Encrypted Int_EncryptedIntOperatorsequals,not_equals
Float_FloatOperatorsequals,not_equals,in,not_in,greater_than,greater_equal,less_equal,less_than
encrypted float_EncryptedFloatOperatorsequals,not_equals
long_LongOperatorsequals,not_equals,in,not_in,greater_than,greater_equal,less_equal,less_than
encrypted long_EncryptedLongOperatorsequals,not_equals
string_StringOperatorsequals,not_equals,in,not_in,like,not_like
date long_DateLongOperatorsequals,not_equals,in,not_in,greater_than,greater_equal,less_equal,less_than
boolean_BooleanOperatorsequals

Each Zoho CRM Data Type is mapped to a GraphQL field type as shown in the table below:

GraphQL Field TypesZoho CRM Data Types
String Field TypesSingle Line
Multi Line
String
Email
Picklist
URL
Date
DateTime
Integer Field TypesNumber
Double Field TypesDecimal
Currency
Percent
Long Field TypesLong Integer
Boolean Field TypesCheckbox

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
                }
            }
        }
    }
}