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





                                                        Manage your brands on social media



                                                              Zoho TeamInbox 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

                                                                                                        • Restricting Printing

                                                                                                          Hi Is it possible to stop users printing documents?
                                                                                                        • Backup and Restore of Projects

                                                                                                          Hi Guys, my boss asked me "do we store regulary offline Backups of Zoho Projects" and i could only answer "no way". Is there really no way to backup and restore a project manualy? As Projects is the main Product we decided to use Zoho it could be that
                                                                                                        • Enable Zia Bot for Intelligent Conversations in Zoho Cliq

                                                                                                          Hi Zoho Cliq Team, We would like to request a new feature: the ability to interact with Zia via a dedicated bot in Zoho Cliq, in a way similar to how users interact with GPT-based assistants. Use Case: We're looking for functionality beyond the existing
                                                                                                        • Zoho RPA is now available in your Zoho One bundle!

                                                                                                          Hello All! Of late, it's been quite a stint of new app integrations in Zoho One. This announcement pertains to the addition of another Zoho application, the most sought-after Zoho RPA - Robotic Process Automation, to the bundle. What is Zoho RPA? Zoho
                                                                                                        • Script on Page used as dashboard don't work anymore

                                                                                                          Salut, I have a page used as dashboard that worked fine, but recently the workflows don't seem to work, I have the icons like on a page for portal user when I try to look at it as admin. See screen shot : Anybody knows what could have happen ? The only
                                                                                                        • Data types in custom fields

                                                                                                          Hi, I've been trying to create a custom field to enter purchase order dates , but there is only one data type in the drop down to choose from which is a "Text Box ( Single Line )". I need the "Date" Data type. Please give me a solution regarding thi
                                                                                                        • Change rate after xxxx kilometers

                                                                                                          Is there a way to change the miileage rate after a certain mileage. After 5000 kilometers, we want the rate to automaticly change. Thank !
                                                                                                        • Idea: Workflow Rule Trigger Only When Subform Row Is Updated (Thanks to New Inline Row Feature)

                                                                                                          Hi Zoho team and community, With the recent update to Zoho CRM, we can now add or delete rows inside subforms without entering edit mode, using the inline Add row button. This is a fantastic improvement for user experience — seamless, fast, and efficient.
                                                                                                        • Sync desktop folders instantly with WorkDrive TrueSync (Beta)

                                                                                                          Keeping your important files backed up and accessible has never been easier! With WorkDrive desktop app (TrueSync), you can now automatically sync specific desktop folders to WorkDrive Web, ensuring seamless, real-time updates across devices. Important:
                                                                                                        • Can't attach

                                                                                                          I am having problems sending attachments. I am trying to attach some PDFs to an email (as I do several times every day) but the progress bar on the attached file gets stuck somewhere between 20%-70% and when I hit send I get the error message 'Attachment
                                                                                                        • WhatsApp Channels in Zoho Campaigns

                                                                                                          Now that Meta has opened WhatsApp Channels globally, will you add it to Zoho Campaigns? It's another top channel for marketing communications as email and SMS. Thanks.
                                                                                                        • Existing subform data is being changed when new subform entries are added

                                                                                                          I'm having trouble with existing subform data being changed when new subform entries are created. I have the following setup to track registrations for a girl scout troop: Main Form: Child Subform: Registrations The data are a one-to-many relationship where each Child record has many Registrations (new Registration will be created for each year the child is in the troop.) Per the instructions, I have created the subfom, added it to the main form, gone back to the subform and created the bi-directional
                                                                                                        • Bigin: filter Contacts by Company fields

                                                                                                          Hello, I was wondering if there's a way to filter the contacts based on a field belonging to their company. I.e.: - filter contacts by Company Annual Revenue field - filter contacts by Company Employee No. field In case this is not possibile, what workaround
                                                                                                        • Button on Deal screen to automate changing deal dates?

                                                                                                          Hi I spend a lot of time working with our accounts managers here moving deals around the calendar, qualifying things etc. I'd like to have an easy way to change the closing date on a deal, from the deal screen table, rather than either click in to the
                                                                                                        • Support for Renaming System-Defined Fields in Zoho CRM

                                                                                                          Hello all! We are excited to announce an upcoming enhancement in Zoho CRM: support for renaming system-defined fields! Current Behavior Currently, system-defined fields returned by the GET - Fields Metadata API have display_label and field_label properties
                                                                                                        • Can Zoho CRM JS SDK Send Notifications, Create Tasks & Calendar Events?

                                                                                                          Hello everyone! I’m just starting to explore this topic, so please excuse my beginner-level questions! Is it possible to use the JS SDK (https://help.zwidgets.com/help/latest/index.html) to: Send messages (signals, notifications) to specific employees,
                                                                                                        • How to authenticate my domain on ovh

                                                                                                          I don't succeed in adding an domain authentification on ovh. Should i first create a subdomain? But this doesn't work either, ti gi ves te same screen and the next button is greyed out when adding the info received from zoho
                                                                                                        • Undelivered Mail Returned to Sender

                                                                                                          commerciale@etruriadesign.it, ERROR CODE :550 - "The mail server detected your message as spam and has prevented delivery." I have been corresponding with the receiver and they wrote "Ciao, ho fatto verificare ma purtroppo non è un problema che deriva
                                                                                                        • Kaizen #190 - Queries in Custom Related Lists

                                                                                                          Hello everyone! Welcome back to another week of Kaizen! This week, we will discuss yet another interesting enhancement to Queries. As you all know, Queries allow you to dynamically retrieve data from CRM as well as third-party services directly within
                                                                                                        • Notifications no longer being sent to my email address for any scheduled events

                                                                                                          The last few weeks, I stopped receiving email notifications to my email for events I have scheduled and have a selected reminder option checked.
                                                                                                        • This domain is not allowed to add. Please contact support-as@zohocorp.com for further details

                                                                                                          I am trying to setup the free version of Zoho Mail. When I tried to add my domain, theselfreunion.com I got the error message that is the subject of this Topic. I've read your other community forum topics, and this is NOT a free domain. So what is the
                                                                                                        • Group to shared mailbox conversion

                                                                                                          Is it possible to convert a group in Zoho mail to a shared mailbox?
                                                                                                        • Mail Merge Stuck in Queue

                                                                                                          I am trying to send Mail Merge's and it never sends out to the full list. It always hits a portion and the rest remain in the "Queue" - the emails I am sending are time sensitive, so I need this to be resolved or have a way to push the emails through
                                                                                                        • why do I get error message each time I open zoho mail

                                                                                                          why do I get error message each time I open zoho mail
                                                                                                        • CRM HAS BEEN SOOO SLOW For Days 05/15/25

                                                                                                          I have fantastic Wifi speed and have zero issues with other websites, apps, or programs. It takes an excruciatingly amount of time to simply load a record, open an email, compose an email, draft a new template, etc. Am I in a subset/region of subscribers
                                                                                                        • Cross-department Parent-Child ticketing for faster and efficient ticket resolution

                                                                                                          Hello everyone, Organizations frequently need to have multiple departments set up in their customer service ticketing system. However, when a customer raises an issue or an internal process that requires agents to collaborate with their peers, a lack
                                                                                                        • Can't setup email on outlook (Android Phone)

                                                                                                          Dear All Support, I have tried many time to setup this zoho mail over the android phone (outlook app) . But it's always show me to check username/password of my email . But i can login from the webmail , that's why i confuse , How can i able to access
                                                                                                        • Having problem with MX records and SPF

                                                                                                          Hi there, I have been facing a problem that my zoho mail doesn't receive mail. See Error in below The MX Records of your domain(s) mydomain.com are not pointed to Zoho and you may not receive emails in Zoho SPF entries in your domains DNS are not configured
                                                                                                        • ZOHO Mail App Not working

                                                                                                          There seems to be an issue with Zoho Mail App today. It is not connecting to server, internet is working fine, tried uninstalling app and reinstalling, loading circle keeps spinning round. Is there an update on the way?
                                                                                                        • Account with own domain, IMAP vs IMAPPRO

                                                                                                          Hi, I have email account with my own domain. I use Em Client email plan and when I use IMAPPRO incoming host, email comes in Em Client only when I restart program. If I use IMAP incoming host everything is ok. Port is 993 both option. Why so? What´s different
                                                                                                        • Change default "Sort by"

                                                                                                          Is there a way to change the default "sort by" when searching across modules?" in Zoho CRM? Currently the default sort method is "Modified time" but i would like to utilize the second option of "relevance" as the sort by default and not have to change
                                                                                                        • Automatic Display the Price from CPQ

                                                                                                          Is it possible to display the discounted price from CPQ that I created for my customer? For example, when the customer selects Product A, instead of showing the default price, it should display the discounted CPQ price.
                                                                                                        • Enhancement - Financial Reports

                                                                                                          Hello Everyone, As part of enhancing reports in Zoho Books, we have added an option`Compare With` in Financial reports. Using this, you can compare the current period with Previous Year(s)/Previous Period(s) (Maximum 3 periods). This option is available in the following Financial Reports: * Profit and Loss * Cash Flow Statement * Balance Sheet Please feel free to share your feedback.  We are glad to hear from you. Regards, Nithya - Zoho Books Team.
                                                                                                        • Associating Multiple Work Orders with a Single Invoice in Zoho FSM

                                                                                                          Hello Everyone, Is it possible to associate multiple Work Orders with a single Invoice in Zoho FSM? Best Regards, Subhash Kumar
                                                                                                        • Turning off the new UI

                                                                                                          Tried the new 'enhanced' UI and actively dislike it. Anyone know how to revert back?
                                                                                                        • Sent emails not going and showing "Processing"

                                                                                                          Hello Team, Could you please assist with sent emails showing "processing" and not actually going through? Many thanks and regards, Cycology
                                                                                                        • Free Plan mail accounts details

                                                                                                          In the zoho mail pricing there's a free plan that includes: FREE PLAN Up to 25 Users 5GB* /User, 25MB Attachment Limit Webmail access only. Single domain hosting. I need to make sure that I'm able to create multiple email accounts in the form of: name@domain.com
                                                                                                        • Spf cannot verify

                                                                                                          Hello, Thank you for your service. I am not able to configure my SPF. I have follow several times your instructions but it does not work. I cannot verify. My domain is ptjpt.co.id Please help me
                                                                                                        • Custom Function : Copy multilookup field to text field

                                                                                                          Hi, I'm a newbie on function programming, I try to copy text from a multi lookup field named "societe" to a text field named "societe2". I've used this code. In deluge script it seems to work, but when I trigger this function it doesn't work (Societe2
                                                                                                        • Introducing Global Sets for easy management of similar picklists in CRM

                                                                                                          [Update | Sep 2024] We've increased the maximum count limit for global sets. These new limits are now live for AU and JP data centers and will be gradually opened to all. Please check this link for the updated limits. Hello folks, As administrators who
                                                                                                        • Next Page