Query Records
You can query the records in different modules in Zoho CRM using GraphQL queries. Access to different fields depends on the module and field level permission of your profile.
_Records type
The _Records type comprises all the modules that are accessible to you. It has one field for each accessible module with the same name as its api name. Refer below for a snippet of the schema showing Leads,Accounts and Products modules.
_Records Specification
Copiedtype _Records {
Leads(
offset: String,
limit: Int,
order_by: Leads__OrderBy,
where: Leads__Filter
): Leads__Connection
Accounts(
offset: String,
limit: Int,
order_by: Accounts__OrderBy,
where: Accounts__Filter
): Accounts__Connection
Products(
offset: String,
limit: Int,
order_by: Products__OrderBy,
where: Products__Filter
): Products__Connection
.
.
}
Each module field supports the below four arguments:
- offset: Used for fetching the next set of results after the initial set of results were fetched. You should pass the offset received from your previous request to fetch the next set of data. The default value is null and the first set of results are fetched. Refer Paginate Response
- limit: Used to specify the number of records to fetch, with a maximum value of 100. Maximum number of records that can be fetched for while querying at rootlevel is 100 and for a querying sublevel is 10. Refer Paginate Response
- order_by: Used for sorting the query using a specified field. Refer Order Response
- where: Used for filtering the query with an argument. Refer Filter Response
{Module}__Connection
Each module field returns as {Module}__Connection which combines records and page information. For instance, the Leads field returns Leads__Connection.
{Module}__Connection links the result set (_data) with details about their relative position of the returned set of data among all potential results.
Copiedtype Leads__Connection {
_data: [Leads__data]
_info: info!
}
The _RecordsConnection type comprises of:
- _data
- _info
_data type
The _data type of each module returns its corresponding {Module Name}__data which contains all the fields of the module. The _data field of the {module}__connection type is array of {module}__data type. This {module}__data type holds the particular module's data. For instance, for Leads module, Leads_data holds all the data in the Leads module.
Copiedtype Leads__data implements Record {
.
.
Last_Name: _StringValue
Full_Name: _StringValue
Zip_Code: _StringValue
Country: _StringValue
.
.
}
type _StringValue
Copiedtype _StringValue {
value: String
}
type _BooleanValue
Copiedtype _StringValue {
value: String
}
type _FloatValue
Copiedtype _BooleanValue {
value: Boolean
}
type _IntValue
Copiedtype _FloatValue {
value: Float
}
type _LongValue
Copiedtype _IntValue {
value: Int
}
type _StringArrValue
Copiedtype _LongValue {
value: Long
}
_infotype
The _info includes information about the location of the current page within the entire result set and also whether more records are present in the result set.
Copiedtype info {
next_offset: String
previous_offset: String
more_records: Boolean
}
_infotype comprises of:
- next_offset: consists of offset value of the next page.
- previous_offset: consists of offset value of the previous page.
- more_records: Boolean value that indicates whether more records are present or not for the query.
Querying Leads
For querying lead data in GraphQL you can use the below query:
GraphQL Request
Copiedquery{
Records {
Leads {
_data {
Email {
value
}
Last_Name {
value
}
id {
value
}
Phone {
value
}
Mobile {
value
}
}
}
}
}
GraphQL Response
Copied{
"data": {
"Records": {
"Leads": {
"_data": [
{
"Email": {
"value": "chau-kitzman@noemail.com"
},
"Last_Name": {
"value": "Kitzman"
},
"id": {
"value": "2484261000000496222"
},
"Phone": {
"value": "555-555-5555"
},
"Mobile": {
"value": "555-555-5555"
}
},
{
"Email": {
"value": "theola-frey@noemail.com"
},
"Last_Name": {
"value": "Frey"
},
"id": {
"value": "2484261000000496223"
},
"Phone": {
"value": "555-555-5555"
},
"Mobile": {
"value": "555-555-5555"
}
},
{
"Email": {
"value": "michael-gruta@noemail.com"
},
"Last_Name": {
"value": "Ruta"
},
"id": {
"value": "2484261000000496224"
},
"Phone": {
"value": "555-555-5555"
},
"Mobile": {
"value": "555-555-5555"
}
},
.
.
.
.
.
]
}
}
}
}
Mapping Zoho CRM Modules to GraphQL objects
Each accessible module maps to corresponding GraphQL object type. The GraphQL object name has same name as the api name of the module with a _data suffix. For example Leads module maps to Leads__data. Each of the GraphQL objects implement the _Records interface.
_Record interface
Copiedinterface _Record {
id: _StringValue
}
Primitive Types
In Zoho CRM the fields are mapped to a GraphQL scalar or "Field Value" type . A GraphQL scalar is the final data point in a query.
The list of scalars available in Zoho CRM are:
Scalar Types
Copied
scalar BigInteger
scalar Boolean
scalar Float
scalar Int
scalar Long
scalar Object
scalar String
Non - primitive types
Field values are objects with names formed by adding an underscore as a prefix and '_Value' as a suffix to the field name. These objects have a property named 'value' that can hold the corresponding field's value. eg: _StringValue.
Multi-select picklists are stored in GraphQL as string arrays.
Subform, multi user lookups, related lists are referred to as child relationship to the current module.
Lookup are referred to as parent relationship to the current module.
Note
Multi-select lookups data has to be queried through the corresponding linking module.