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: Ultimate Edition.

Note that it is not available in Ultimate Trial Edition.

Using Zoho CRM GraphQL APIs, you can retrieve the metadata and data defined as types Meta and Records respectively, in the root Query type.

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.