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

                                                                                                  • Why wont Zoho Support Grammarly!! --- PLEASE VOTE FOR THIS to show Zoho we need this

                                                                                                    The spell check and grammar in ZOHO are so buggy and a waste of time. Please support Grammarly! I'm sure I'm not the only one — there are other CRMs that support this. If you're not planning to add this feature, Please let others know before accepting
                                                                                                  • Tracking Agent Diligence in Updating Records

                                                                                                    Our organization mainly focus on B2B. While we've implemented automations like pushing info from web forms into CRM, we often get info from events and individual networks. The complete/updated info relies in the agents who directly interacts with them,
                                                                                                  • Automating Custom Web Link Messages to Customers via Instant Messaging in Zoho Desk

                                                                                                    Hello, I am looking for assistance with Zoho Desk's Instant Messaging feature. Is there a way to automate the sending of a custom web link to customers every day at 6:30 PM? Any guidance or suggestions on how to achieve this would be greatly appreciated.
                                                                                                  • Categorise Attachments

                                                                                                    We take ID, proof of address, right to work documentation and more.  I can upload a single file in to field, but we often receive multiple files for each category e.g. someone may send a separate file for the front and back of their national ID card.  My team don't have time to manipulate the files in order to upload them as a single file. The options, as far as I can tell, would be to create additional fields on attachments in order to categorise what the file is, or to be able to upload single
                                                                                                  • How to autorespond for inactive users?

                                                                                                    Hi, we have a few inactive users that we would like to set up an autorespond to the sender telling that the email addresses are no longer active. How can we do that?
                                                                                                  • Mass Action Button Script

                                                                                                    Hi all, I've been trying to search a lot of places for a solution on how to do a button placed at the "Mass Action Menu" and thus only updating multiple CHOSEN records at once. After finding no success whatsoever, I decided to just run and test whatever
                                                                                                  • Error 553

                                                                                                    Hello how are you? I'm having trouble sending email. This message appears whenever I try to send an email. I'm receiving emails normally, but I just can't send them
                                                                                                  • Implement Regex in Layout and Validation rules

                                                                                                    Hello all, We are excited to announce that users can now implement Regular Expressions (Regex) in our layout and validation rules. This new functionality allows for more flexible rules to be created when designing and validating forms. What is Regex?
                                                                                                  • Zoho Desk Validation Rule Using Custom Function

                                                                                                    Hi all, I tried to find the way to validate fields using custom function just like in Zoho CRM but to no avail. Is there a way to do this?
                                                                                                  • Confirmation prompt before a custom button action is triggered

                                                                                                    Have you ever created a custom button and just hoped that you/your users are prompted first to confirm the action? Well, Zoho knows this concept. For example, in blueprint, whenever we want to advance to the next state by clicking the transition, it is
                                                                                                  • How do we add Google Analytics code to Zoho Bookings scheduling pages or the thank you page?

                                                                                                    We need to track user activity on individual Bookings' pages and/or the thank you pages? How do we do this?
                                                                                                  • Zoho Sheets working offline

                                                                                                    Hi,  I am looking for the ability to work offline in Zoho Sheets, but currently I cannot find the process to complete this.  Does someone have any ideas or steps I might have missed?  Also does Zoho Sheets have the "Format as Tables" function as is currently in MS Excel 2016??  Many thanks. 
                                                                                                  • Field Updated based off Call Status

                                                                                                    I'm trying to create a Field Update where: When Call Status is Completed Lead/Contact/Account Description field with the information in the "Outcome Of Outgoing Call" Description field. Once our sales team finishes their calls and they add a description
                                                                                                  • Repeating Sections in Writer

                                                                                                    I am wondering if it's possible to create repeating sections or text boxes of a document based on a merged subform fields coming from Zoho Forms. We are currently using excel to dynamically create a legal PDF document based on input fields in another
                                                                                                  • Important update in Zoho Forms: Enhancements for improved email deliverability

                                                                                                    Hello, form builders! We would like to inform you about some changes we're making in Zoho Forms to ensure the deliverability of your outbound emails. Changes to Gmail policies Gmail has updated its DMARC policy which quarantines emails sent with gmail.com
                                                                                                  • Error 403: Forbidden When Updating Email Signature via API

                                                                                                    Hi Zoho Desk team, First, congratulations again on the excellent Zoho API. But, I’m encountering an issue while attempting to update an email signature via the API. Whenever I make a request to update the signature, the response returns an HTTP 403 Forbidden
                                                                                                  • Why hasn't Zoho CRM For Everyone been rolled out?

                                                                                                    I don't understand the point of rolling out new features so slowly after a big fanfare launch 8 months ago. I've signed up for 'early access' and also contacted my point of contact, but nothing. Not even an auto reply. Would you say that this is good
                                                                                                  • Canva Integration

                                                                                                    Hello! As many marketing departments are streamlining their teams, many have begun utilizing Canva for all design mockups and approvals prior to its integration into Marketing automation software. While Zoho Social has this integration already accomplished,
                                                                                                  • Can I print a set of record templates as a single pdf?

                                                                                                    I have a record template formatted as a gift certificate. I can email a single gift certificate to each recipient, but I also need to print the whole batch for the organiser, and they won't want 40 separate files. The layout needs to be identical, so
                                                                                                  • Time Zone Sending in Marketing Automation

                                                                                                    Good day...can anyone share if they have been able to get sending via Time Zones to actually work? Our data is 99% perfect, with all the time zone criteria met, yet the results are completely off target when we try to use it. We've had varied results
                                                                                                  • Combine Small Pie Slices in Pie Chart

                                                                                                    Hello, I am trying to make a pie chart showing our sales in each of our product categories. The problem is that we have over 80 product categories, and not that much room from which to look at it. I am wondering if there is a way to combine the smallest
                                                                                                  • Which are the IP addresses to use for 'split delivery' with Office 365? (Zoho mail inbound gateway)

                                                                                                    Hi, I'm trying to set up 'split delivery' (email routing) with Office 365. I'm following the instructions to set up Office 365 as the primary server (https://www.zoho.com/mail/help/adminconsole/coexistence-with-office365.html) One of the prerequisites
                                                                                                  • Zoho Desk Onboarding Assistance - How to do bulk taging

                                                                                                    Hi How to apply a particular tag to multiple tickets in one go.
                                                                                                  • Round robin not processing backlog tickets

                                                                                                    We set up a round-robin for one of our departments which initially worked, but something seems to have broken during the 'tweaking' process as it will no longer assign backlogged tickets of any kind. (I've included images of the settings.) Based on the
                                                                                                  • Merge Tickets Directly from Contact Page in Zoho Desk

                                                                                                    Dear Zoho Desk Support Team, We are writing to request a new feature that would allow users to easily merge tickets directly from the contact page in Zoho Desk. Currently, the only option to merge tickets is from the Tickets list view page, which can
                                                                                                  • Text snippet

                                                                                                    There is a nice feature in Zoho Desk called Text Snippet. It allows you to insert a bit of text anywhere in a reply that you are typing. That would be nice to have that option in Zoho CRM as well when we compose an email.
                                                                                                  • when I open my sheet ,it always start at "A1" despite I left it at "N234"

                                                                                                    when I open my sheet ,it always start at "A1" despite I left it at "N234"  Is it possible to make the sheet open where I left it? 
                                                                                                  • Leistungsdatum in Rechnungen (Zoho Books)

                                                                                                    Hallo, ist es irgendwie möglich den Leistungszeitraum in der Rechnung aufzuführen? Beste Grüße Aleks
                                                                                                  • Why is this an Invalid Collection String Error?

                                                                                                    Here's the code snippet: Enddate = EventEnd.toDate("yyyy-MM-dd"); EventCollection = Collection(); EventCollection = zoho.crm.searchRecords("Events", "(End_DateTime:starts_with:"+Enddate+")"); for each eventday in EventCollection { //create a list of events
                                                                                                  • Not possible to remove mandatory system fields?

                                                                                                    Is there no way to make things like under Calls "Call Duration" or "Call Start Time" or under Potentials "Close Date" not mandatory? These fields are useless for my organization and waste time but the box is grayed out to not make them mandatory. It's
                                                                                                  • how to create a company without an assigned owner

                                                                                                    In my company we are reassigning accounts and we need to leave some companies without an owner to review their potential and then assign them, but the options that appear in owner require that they be assigned to a seller, how to leave them without an
                                                                                                  • ZDC Hackathon 2024 Category-wise Winners !

                                                                                                    Zoho CRM Client Script Hey everyone! After rigorous evaluation by our 14 expert judges, we’re beyond excited to announce that two incredible teams have won the Zoho CRM Client Script – Product Category award for their outstanding innovations! Team 1:
                                                                                                  • What does "Tickets for Review" do?

                                                                                                    What is the purpose of the va nilla view " Tickets for Review?"
                                                                                                  • Firebase Functions integration

                                                                                                    Hello Zoho Team, Please advise how I can configure SMTP in my account to facilitate Firebase-triggered email functions. Please note that I desire to send an email with a JSON object collected from Firebase Firestore and included in my mail to forward
                                                                                                  • How to provide recommended KB articles in the welcome message

                                                                                                    I'm new to Zoho and am looking to replicate something I did for a previous employer. I want all newly created tickets to receive an automated welcome message that includes a few recommended articles from our knowledge base. Ideally there would be a way
                                                                                                  • Zoho Desk View Open Tickets and Open Shared Tickets

                                                                                                    Hi, I would like to create a custom view so that an agent can view all the open tickets he has access to, including the shared tickets created by a different department. Currently my team has to swich between two views (Open Tickets and Shared Open Tickets).
                                                                                                  • No more IMAP/POP/SMTP on free plans even on referrals with NO NOTICE

                                                                                                    Outraged. Just referred a colleague to use her domain (not posting it publicly here) to Zoho, just as I have other colleagues, clients, friends. Expected the exact same free plan features as I have and as everyone else I ever referred got. I was helping
                                                                                                  • Join us at the Canada ZUG Meetup: What’s New in Zoho CRM

                                                                                                    Hello Zoho Community! Start your year with fresh insights into Zoho CRM’s latest updates and tools. Whether you're a CRM beginner or a experienced user, this meetup is crafted to help you optimise your processes and leverage new features. Explore practical
                                                                                                  • So many tools...

                                                                                                    As a low- to no-code user and no funds to budget, there are so many options to choose to get my work done and when I start thinking about workflows for people other than myself, I get confused about the most streamlined way to move forward if I can get
                                                                                                  • Pull Price Book and Product info in a single report

                                                                                                    i want to be able to produce price books for my engineers. If i could produce a report with the retail price as an option that would be great. This seems to be an old issue to please what are the plans. Moderation Update (16th Feb 2024): The option to
                                                                                                  • Next Page