Using GraphQL with Zoho CRM allows you to fetch exactly the data you need in a single request, reducing over-fetching and under-fetching. It also enables you to combine multiple operations in one request, which can improve performance and reduce network overhead.
query { Records { Leads {_data {Last_Name {value}}} } } |
{"data":{"Records":{"Leads":{"_data":[ {"Last_Name":{"value":"Kitzman"}}, {"Last_Name":{"value":"Frey"}} // ... ]}}}} |
{ Records { Leads { _data { Last_Name { value } } } } Meta { Modules(filter: { api_name: "Leads" }) { _data { fields(filter: { api_names: "Last_Name" }) { _data { id api_name display_label json_type data_type }}}}}} |
{ "data": { "Records": { "Leads": { "_data": [ { "Last_Name": { "value": "Kitzman" } }, { "Last_Name": { "value": "Frey" } } // ... ] } }, "Meta": { "Modules": { "_data": [ { "fields": { "_data": [ { "id": "6660682000000002595", "api_name": "Last_Name", "display_label": "Last Name", "json_type": "string", "data_type": "text" }]}}]}}}} |
For example. to fetch Email, Last_Name, ID, Phone and Mobile of contacts where last name starts with "Ni" and mobile contains the digit 5 or phone number equals 555-678-9999
Request body
{ Records { Contacts(where: { and: [ { Last_Name: { like: "Ni%" } }, { or: [ { Phone: { equals: "555-678-9999" } }, { Mobile: { like: "%5%" } } ] } ] }) { _data { Email { value } Last_Name { value } id { value } Phone { value } Mobile { value } }}}} |
Introspecting the GraphQL schema in Postman will reveal the details of fields and supported operators for each module. Check out our previous Kaizen, where we explained this using videos.
For example, the query below fetches metadata of Deals module and api_name of its layouts and fields
query { Meta { Modules(filter: { api_name: "Deals" }) { _data { id singular_label plural_label layouts { _data { id api_name } } fields { _data { api_name }}}}}} |
The order_by argument can be used to sort the response set after fetching records to ascending or descending order.
query { Records { Deals(order_by: { Probability: { order: DESC } }) { _data { Deal_Name { value } Expected_Revenue { value } Probability { value } }}}} |
Use Zoho CRM GraphQL APIs when:
You need to fetch complex, nested data from multiple resources (e.g., accounts with linked contacts and deals) in a single request and avoid under-fetching of required data/metadata.
You need to minimize over-fetching of data/metadata by selecting only specific resources, fields of the resources, and relationships of the resources.
You need to query data and metadata together efficiently.
Use Zoho CRM REST APIs when :
You need to perform simple CRUD operations (e.g., fetch/update a single product).
Your use case involves straightforward endpoints without nested data/metadata.
You need to do add/update/delete operations.
We trust that this post addressed your doubts on GraphQL APIs. If you have any questions please let us know in the comment section or reach out to us at support@zohocrm.com.
