Kaizen 149 : Using GraphQL APIs to fetch data in a consolidated way

Kaizen 149 : Using GraphQL APIs to fetch data in a consolidated way



Hello everyone!
Welcome to this week's post in the Kaizen Series! This week, we will discuss GraphQL APIs, a query language that provides an efficient, powerful, and flexible method for fetching and manipulating data from Zoho CRM.
Let us consider the scenario of a large industrial equipment manufacturer,  Zylker Manufacturing.  They utilize Zoho CRM to streamline their sales processes and customer relationship management. Their sales support team uses a legacy system to manage their activities. When a contact seeks support, the support team must have access to the latest data from Zoho CRM to assist them better. They need:
  • details of the contact, such as email, phone, and Account details
  • details of the ongoing deals of the contact, including potential revenue and stages .
With GraphQL APIs, with a single API call, you can create custom unified view that combine information from multiple Zoho CRM modules. This allows the support team to view all relevant information in one place, making it easier to manage sales processes and customer interactions. To create the view, metadata of the fields is also required.  This structured approach in GraphQL allows Zylker Manufacturing to efficiently aggregate data.


You need to construct a GraphQL query to fetch specific data related to a contact and associated deals, as well as metadata about the fields in the Contacts and Deals modules. Let's break down each part of the query that can achieve this.

1. Fetching Contact and Deal Information


  • Records: Records comprises the records from the different Zoho CRM modules.
  • Contacts: Specifies that we want to query the records of the Contacts module. The where clause filters the contacts based on their email address.
  • _data: This indicates the fields we want to retrieve from the records. In this case:
    • Email: Fetches the email of the contact.
    • Full_Name: Fetches the full name of the contact.
    • Deals__r: Fetches the related deal record of the Contact. 
      • Expected_Revenue: Fetches the expected revenue from each deal.
      • Deal_Name: Fetches the name of each deal.
      • Stage: Fetches the current stage of each deal.


Records {
    Contacts(where: { Email: { equals: "krismarrier@noemail.com" } }) {
        _data {
            Email {
                value}
            Full_Name {
                value}
            Deals__r {
                _data {
                    Expected_Revenue {
                        value}
                    Deal_Name {
                        value}
                    Stage {
                        value
                    }}}}}}




2. Fetching Metadata for Contacts


  • Meta: This fetches the details of the metadata for Contacts module. It uses the alias "contact_meta"
  • Modules(filter: { api_name: "Contacts" }): Specifies that we want to fetch the metadata of the Contacts module.
  • _data: This indicates the fields we want to retrieve. In this case:
    • id: The unique identifier for the module.
    • api_name: The API name for the module.
    • module_name: The name of the module.
    • description: The description of the module.
    • plural_label, singular_label: Labels used for the module.
    • fields: Retrieves metadata for specific fields within the module. filter: { api_names: ["Last_Name", "Email"] }: Specifies which fields' metadata to retrieve.For each field, it retrieves:
      • id: Field identifier.
      • api_name: API name for the field.
      • display_label: The display name of the field.
      • json_type: The data type as represented in JSON.
      • data_type: The Zoho CRM data type of the field.
 contact_meta: Meta {
    Modules(filter: { api_name: "Contacts" }) {
      _data {
        id
        api_name
        module_name
        description
        singular_label
        plural_label
        fields(filter: { api_names: ["Last_Name", "Email"] }) {
          _data {
            id
            api_name
            display_label
            json_type
            data_type
          }
        }
      }
    }
 }

3. Fetching Metadata for Deals


  • Meta: This fetches the details of the metadata for Deals module. It uses the alias "deal_meta"
  • Modules(filter: { api_name: "Deals" }): Specifies that we want to fetch the metadata of the Deals module.
  • _data: This indicates the fields we want to retrieve. In this case:
    • id: The unique identifier for the module.
    • api_name: The API name for the module.
    • module_name: The name of the module.
    • description: description of the module.
    • plural_label, singular_label: Labels used for the module.
    • fields: Retrieves metadata for specific fields within the module.
    • filter:  api_names: ["Expected_Revenue", "Deal_Name","Stage"] }: Specifies which fields' metadata to retrieve.For each field, it retrieves:
      • id: Field identifier.
      • api_name: API name for the field.
      • display_label: The display name of the field.
      • json_type: The data type as represented in JSON.
      • data_type: The Zoho CRM data type of the field.
deal_meta: Meta {
    Modules(filter: { api_name: "Deals" }) {
        _data {
            id
            api_name
            module_name
            description
            singular_label
            plural_label
            fields(filter: { api_names: ["Expected_Revenue", "Deal_Name","Stage"] }) {
                _data {
                    api_name
                    id
                    display_label
                    json_type
                    data_type
                }
            }
        }
    }
}

The complete query will look this:


query {
  Records {
    Contacts(where: { Email: { equals: "krismarrier@noemail.com" } }) {
      _data {
        Email {
          value
        }
        Full_Name {
          value
        }
        Deals__r {
          _data {
            Expected_Revenue {
              value
            }
            Deal_Name {
              value
            }
            Stage {
              value
            }
          }
        }
      }
    }
  }
  contact_meta: Meta {
    Modules(filter: { api_name: "Contacts" }) {
      _data {
        plural_label
        id
        api_name
        module_name
        description
        singular_label
        fields(filter: { api_names: ["Last_Name", "Email"] }) {
          _data {
            id
            api_name
            display_label
            json_type
            data_type
          }
        }
      }
    }
  }
  deal_meta: Meta {
    Modules(filter: { api_name: "Deals" }) {
      _data {
        plural_label
        id
        api_name
        module_name
        description
        singular_label
        fields(
          filter: { api_names: ["Expected_Revenue", "Deal_Name", "Stage"] }
        ) {
          _data {
            api_name
            id
            display_label
            json_type
            data_type
          }
        }
      }
    }
  }
}


If you were to fetch this data using REST APIs, it will involve multiple calls to the 
  • Query API
  • Related Records API
  • Modules meta API, and 
  • Fields meta API.
Using the GraphQL query you can fetch the required data alone in a less round trip time. While constructing a query for your custom requirement, please note that you can query up to three levels of depth (nesting levels of a field) for Records and 7 levels of depth for Metadata. 

Constructing GraphQL query using Postman

To construct a GraphQL query in Postman to suit your requirements, type {api_domain}/crm/graphql in the URL box. Postman will automatically fetch the query schema in the schema explorer, which can be used to explore the types of queries that can be made, including what fields are available on each type, what arguments those fields accept, and what other types they return.   
Constructing a Zoho CRM GraphQL query in Postman using schema explorer



You can refer to the help documentation on GraphQL APIs for more details on GraphQL APIs. 

Update 25th Sep 2024:
GraphQL APIs are now open across all DCs including IN DC for Enterprise, Zoho One Enterprise, CRM Plus and Ultimate edition orgs. Please note that GraphQL APIs are not available for Trial Edition of these editions.



We hope you found this post useful. We will meet you next week with another interesting topic!
If you have any questions, let us know in the comment section or reach out to us directly at support@zohocrm.com.

Further Reading.                                                                                                                                



    Access your files securely from anywhere


              Zoho Developer Community




                                      • Desk Community Learning Series


                                      • Digest


                                      • Functions


                                      • Meetups


                                      • Kbase


                                      • Resources


                                      • Glossary


                                      • Desk Marketplace


                                      • MVP Corner


                                      • Word of the Day


                                      • Ask the Experts



                                          Zoho Marketing Automation


                                                  Manage your brands on social media



                                                        Zoho TeamInbox Resources

                                                          Zoho DataPrep Resources



                                                            Zoho CRM Plus Resources

                                                              Zoho Books Resources


                                                                Zoho Subscriptions Resources

                                                                  Zoho Projects Resources


                                                                    Zoho Sprints Resources


                                                                      Qntrl Resources


                                                                        Zoho Creator Resources



                                                                            Zoho CRM Resources

                                                                            • CRM Community Learning Series

                                                                              CRM Community Learning Series


                                                                            • Kaizen

                                                                              Kaizen

                                                                            • Functions

                                                                              Functions

                                                                            • Meetups

                                                                              Meetups

                                                                            • Kbase

                                                                              Kbase

                                                                            • Resources

                                                                              Resources

                                                                            • Digest

                                                                              Digest

                                                                            • CRM Marketplace

                                                                              CRM Marketplace

                                                                            • MVP Corner

                                                                              MVP Corner





                                                                                Design. Discuss. Deliver.

                                                                                Create visually engaging stories with Zoho Show.

                                                                                Get Started Now


                                                                                  Zoho Show Resources


                                                                                    Zoho Writer Writer

                                                                                    Get Started. Write Away!

                                                                                    Writer is a powerful online word processor, designed for collaborative work.

                                                                                      Zoho CRM コンテンツ








                                                                                        Nederlandse Hulpbronnen


                                                                                            ご検討中の方




                                                                                                  • Recent Topics

                                                                                                  • License Issue

                                                                                                    Hello Campaigns Team, we have 17 ZOHO One licenses but in campaigns I get the message that we have a free plan. How can we use ZOHO campaigns? As far as I understood campaigns is a part of ZOHO One. THX Niels
                                                                                                  • Visual Sync Status Indicator

                                                                                                    I think I've see in documentation that WorkDrive had the industry standard of indicating a sync status for individual files and folders. I'm just starting with WD and synced my first test folder, but there was no way to tell what's happening by just looking
                                                                                                  • Is there a way to make the new tab button open a new cloud document?

                                                                                                    I'm coming from Google Docs. Plus, is there any way to have a set a default font? I'm using the desktop app and I prefer the options I can get through the cloud documents. I want the convenience of just opening a new cloud document rather than doc that's
                                                                                                  • Tip 26: How to hide the "Submit" button from a form

                                                                                                    Hi everyone, Hope you're staying safe and working from home. We are, too. By now, we at Zoho are all very much accustomed to the new normal—working remotely. Today, we're back with yet another simple but interesting tip--how to hide the Submit button from your forms. In certain scenarios, you may want to hide the submit button from a form until all the fields are filled in.  Use case In this tip, we'll show you how to hide the Submit button while the user is entering data into the form, and then
                                                                                                  • Trying to export a report to Excel via a deluge script

                                                                                                    I have this code from other posts but it gives me an error of improper statement, due to missing ; at end of line or incomplete expression. Tried lots of variations to no avail. openUrl(https://creatorapp.zoho.com/<username>/<app name>/XLSX/#Report:<reportname>,"same
                                                                                                  • Bigin_Email Notification not being sent when a new lead is created

                                                                                                    I have a workflow in BIGIN set to send an email notification when a new lead is created via a webform (integrated with ZohoForm) The trigger is whenever a contact is "Create or Edit". Conditioning was applied for contacts which source is "Website" If
                                                                                                  • ZOHO CRM API Python SDK Convert Quote to Sales Order

                                                                                                    I can see footprints that this may be possible through Inventory Conversion. But I am unable to locate any specific details or samples on how to do this. I am using the most current Python SDK. Any support or even sample code would be much appreciated
                                                                                                  • Displaying Notes/Description Columns in "All Expense" showing Tabs

                                                                                                    It's surprising to see there is no option to view description columns in tab showing all expenses. There are provisions for Reference# and Status, but why not the description/notes. Please Add. Thank You.
                                                                                                  • Zoho Books - uploading company logo squashed

                                                                                                    I am trying to upload my company logo with the following dimensions - 240 x 240 pixels and a file size of 106Kb. When I look at the logo in my invoices, it is squashed and not the right size. Any idea what is going on? I've tried uploading jpeg and png
                                                                                                  • Petty cash discrepancy

                                                                                                    How do I record a petty cash discrepancy? We had money go missing and need to document that in the books, but I'm not sure how to put that in. It's not an expense, just a loss of cash.
                                                                                                  • Zoho Workdrive file versions

                                                                                                    Hello. I have Workdrive setup to sync files offline to an external hard drive. The off line sync folder currently shows at 1.42 TB. I have a 5 TB storage limit in Workdrive. The cloud version of Workdrive says that I have used all 5 TB! I have 27, 285
                                                                                                  • Integration with Zoho CRM?

                                                                                                    Will it be possible to integrate WorkDrive with CRM similar do Zoho Docs?
                                                                                                  • How to control the # of version of files to keep?

                                                                                                    Currently most of the WorkDrive Storage comprise of the many versions of files saved. How do I save some space and reduce the number of version of date or files saved in WorkDrive? Thanks
                                                                                                  • Should I Use Zoho Mail Calendar, or Zoho CRM Calendar, or Zoho Calendar?

                                                                                                    After a couple of dozens Zoho solopreneur products that I transitioned to after becoming a Zoho One enthusiast 5 years ago, I am finally preparing to conquer the remaining two bastions: Mail and WorkDrive (using Google Workspace at the moment). A NYC
                                                                                                  • Add comments to a form

                                                                                                    Hello, I'm trying to add comments to a form using a subform with one field named comment, but I don't want prior comments to be editable or deleteable by anyone (except the admin).  Is there a way to only display prior comments (with a datetime, user and comment field preferably) but still be able to add new ones when editing the main form?  I'm not tied to subforms if there is an easier was to do this?
                                                                                                  • Zoho Books | Product updates | March 2025

                                                                                                    Hello users, We have rolled out new updates in Zoho Books to enhance your accounting experience. These include the ability to create workflow rules for manual journals and Multi-Factor Authentication (MFA) for customer and vendor portals. Explore these
                                                                                                  • Work Drive Tray Icon Missing

                                                                                                    How can I get the tray icon back? The app froze, had to restart PC and then it's been gone since...  I've re-installed the windows program and restarted my machine twice now.
                                                                                                  • cant receive emails

                                                                                                    I have checked the Dns and everything seems to be fine pls check the print screens attached below help me cause i need to solve this fast
                                                                                                  • Retainer invoice in Zoho Finance modlue

                                                                                                    Hello, Is there a way of creating retainer invoices in the Zoho Finance module? If not can I request this is considered for future updates please.
                                                                                                  • iOS Widget Not Working

                                                                                                    It appears that the iOS widget is not working, displaying a blank white screen instead of a selected note. I’m using app version 6.5.12 and iOS 18.3.1.
                                                                                                  • Two Problems With Data Imported to Notes

                                                                                                    Occasionally I want to create a note by copying and pasting a few paragraphs from an article on line. When I create a new note and paste in the section the newly created note winds up with each paragraph in white text on a dark background rather than
                                                                                                  • Workdrive on Android - Gallery Photo Backups

                                                                                                    Hello, Is there any way of backing up the photos on my android phone directly to a specific folder on Workdrive? Assuming i have the workdrive app installed on the phone in question. Emma
                                                                                                  • Generate a link for Zoho Sign we can copy and use in a separate email

                                                                                                    Please consider adding functionality that would all a user to copy a reminder link so that we can include it in a personalized email instead of sending a Zoho reminder. Or, allow us to customize the reminder email. Use Case: We have clients we need to
                                                                                                  • How to associate a document sent in Zoho Sign with an deal in the CRM?

                                                                                                    Hi, often documents are loaded in Zoho sign and sent for signature. These sometimes are linked to a deal in the Zoho CRM and would be nice to see the status of the document within the CRM. I am aware of the integration, but that assumes that the document
                                                                                                  • Preventing auto-redirect to Parent Record on Save...

                                                                                                    Our users often create records from the related list on th left side of the screen. They click the blue "plus" button to create the record. This is handy, but for some modules, or situations, they would like to remain on the record AFTER clicking "Save",
                                                                                                  • CRM Portal Help

                                                                                                    Hello, I am trying to set up a portal to connect with our referring doctors to keep patient cases organized. I set up the accounts module as office, the contacts as doctors, the leads as patients, and the deals as treatments. Everything seems to work
                                                                                                  • Zoho Books (UK) needs to be able to submit a CT600 CTSA return

                                                                                                    As well as a VAT Return, most (if not all) small businesses have to submit a CT600 Corporation Tax Self-Assessment. There are many providers who do this (like Xero) bujt not Zoho. Can you add this to the request list please? Many thanks Steve
                                                                                                  • No image image comes out in the recipient when I sent an email

                                                                                                    Hello to the entire forum, when I send an email from Zoho, my profile picture does not come out. On the other hand, if you do, using Gmail accounts. How is it configured to leave ??? Thank you Greetings !!
                                                                                                  • Zoho Desk & Tasks

                                                                                                    Hi, I'd like to be able to create a set of tasks each time a customer request comes in, as I understand it, currently each would need to be create manually. Project is too much of an overhead for what we want to use. Effectively in various use cases we
                                                                                                  • zet pack not working

                                                                                                    We are using the zet pack command to package our Zoho extension. However, after running the command, the extension gets packed, but the resulting package is empty. We've attached a screenshot for reference. Could you please assist us with resolving this
                                                                                                  • While retrieving the Balance Sheet Report, there is always this "COST OF GOODS SOLD", This is not editable.

                                                                                                    Hi Zoho & Readers, While retrieving the Balance Sheet Report, there is always this "COST OF GOODS SOLD", which is reduced from the Sales to arrive at the gross profit. The issue I face here is that Service Oriented Companies don't incur any COGS, hence
                                                                                                  • Changing salesorder_number via zoho flow

                                                                                                    For some reason updating salesorder_number via zoho flow does not stick. Flow is triggered by new sales order filtered by sales channel update sales order: PO#: CX${trigger.reference_number} Salesorder_number: CX${trigger.reference_number} PO# successfully
                                                                                                  • Working with Products that are non-tangible

                                                                                                    How does one create a 'service' in products? Is there a way to disable inventory functions for things like Sofware as a service? The services module doesn't look to be much help either. Not sure how to do this in CRM
                                                                                                  • Loop in Blueprint but it works. Why? How should this be set?

                                                                                                    see picture
                                                                                                  • Zoho Error: This Operation has been restricted. Please contact support-as@zohocorp.com for further details

                                                                                                    Hello There, l tried to verify my domain (florindagoreti.com.br) and its shows this error: This Operation has been restricted. Please contact support-as@zohocorp.com for further details. Screenshot Given Below -  please check what went wrong. Thanks
                                                                                                  • Bulk Delete Images

                                                                                                    How do I bulk Delete Images from Zoho Campaigns. We have been using the Zoho since 2019 and can still only see the option to delete images one by one and we have a lot of old Campaign imagery we don't need anymore. Thanks!
                                                                                                  • Tip #5: Setting access rights at the subfolder level

                                                                                                    Hello everyone, We hope you're finding our WorkDrive Tips and Tricks series useful. For today's tip, we'll teach you how to assign higher subfolder permissions to Team Folder members. Team Folders helps you avoid the drawbacks of traditional file sharing.
                                                                                                  • I want to update the photo from the mobile app to the product tab product.

                                                                                                    I want to update the photo from the mobile app to the product tab product. Because I want to use the CRM product tab for inventory management Contact registration can save photos from the mobile app. Attached screenshot.
                                                                                                  • Setting default From address when replying to request

                                                                                                    At the moment, if I want to reply to a request, the From field has three options, company@zohosupport.com, support@company.zohosupport.com, and support@company.com.  The first two are really internal address that should never be seen by the customer and
                                                                                                  • Enable Image and Hyperlink Sync in Zoho Desk - Jira Integration

                                                                                                    Hi, We are using the Zoho Desk - Jira integration, which allows comments to sync automatically between a Zoho Desk ticket and its linked Jira issue. However, we have noticed a limitation: When adding a hyperlink or image in a Zoho Desk comment, it is
                                                                                                  • Next Page