GraphQL - An overview
GraphQL is a query language that provides a more flexible and efficient way to access data and metadata within your Zoho CRM. Unlike REST APIs that return fixed datasets, GraphQL allows you to request specific resources, fields of the resources and relationships of the resources, reducing redundant data and streamlining your development process. A key component of GraphQL is its schema, which serves as a contract between the server and client for data exchange. This document serves as your guide to understanding and utilizing GraphQL within our platform, offering clear instructions and code examples to help you get started, including insights into working with the GraphQL schema for optimal data retrieval.
Use of GraphQL is advantageous in these scenarios:
- Precise data retrieval is necessary to avoid over-fetching (retrieving surplus data) and under-fetching (the inability to obtain all requisite data), ensuring optimal bandwidth and resource utilization.
- A unified API call is desired to aggregate data from multiple dependent or independent entities, thereby minimizing the number of network round trips required for comprehensive data interaction with the Zoho CRM server.
- Advanced querying capabilities are needed for directly accessing nested data structures, facilitating the streamlined retrieval of sub-resources via hierarchical query constructs.
Available in: Enterprise, Zoho One Enterprise, CRM Plus and Ultimate edition.
Please note that GraphQL APIs are not available in the trial versions of any Zoho CRM editions.
Using Zoho CRM GraphQL APIs, you can retrieve the metadata and data defined as types Meta and Records respectively, in the root Query type.
- Meta : Retrieve metadata from Modules, Users, KanbanView, UserProperties, ProfilePermissions, Profiles, Roles, and Widgets. Some of the types support filtering and pagination.
- Records : Retrieve data from the modules that are accessible to your profile. Filtering and pagination are supported for all modules.
Example
With the following query, you can retrieve the Last_Name field from the Leads module, Account_Name from the Accounts module, the Last_name field from Users and api_name of the Roles.
Copiedquery {
Records {
Accounts {
_data {
Account_Name {
value
}
}
}
Leads {
_data {
Last_Name {
value
}
}
}
}
Meta {
Roles {
_data {
api_name
}
}
Users {
_data {
last_name
}
}
}
}
Response
Copied{
"data": {
"Records": {
"Accounts": {
"_data": [
{
"Account_Name": {
"value": "Benton"
}
},
{
"Account_Name": {
"value": "Chanay"
}
}
.
.
.
]
},
"Leads": {
"_data": [
{
"Last_Name": {
"value": "Kitzman"
}
},
{
"Last_Name": {
"value": "Frey"
}
},
{
"Last_Name": {
"value": "Ruta"
}
},
.
.
.
]
}
},
"Meta": {
"Roles": {
"_data": [
{
"api_name": "CEO"
},
{
"api_name": "Manager"
}
]
},
"Users": {
"_data": [
{
"last_name": "kumar"
}
]
}
}
}
}
To make your first Zoho CRM GraphQL API call, refer to the Getting Started page.
To know more about API credits consumption, head to the Credits, Complexity, and Depth page.