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. 

Notes
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.

Idea
Further Reading.                                                                                                                                



    Access your files securely from anywhere


            Zoho FSM Video Tutorials


                  All-in-one knowledge management and training platform for your employees and customers.






                                        Zoho Developer Community




                                                              • Desk Community Learning Series


                                                              • Digest


                                                              • Functions


                                                              • Meetups


                                                              • Kbase


                                                              • Resources


                                                              • Glossary


                                                              • Desk Marketplace


                                                              • MVP Corner


                                                              • Word of the Day


                                                              • Ask the Experts



                                                                        • Sticky Posts

                                                                        • Announcing the new SKILL.md for Zoho CRM and the updated OAS repository!

                                                                          We are introducing a new zoho-crm skill to make working with Zoho CRM Developer tools (like APIs, functions, widgets, client scripts, queries etc) easier and faster, with the help of AI in your preferred AI harness like Claude Code, Codex, Cursor, VSCode
                                                                        • Kaizen #261 : Using Zoho CRM Skill to generate complex COQL queries

                                                                          Hello everyone, In the previous Kaizen posts, we introduced the zoho-crm SKILL.md and discussed how it can help you when you are working with Zoho CRM APIs and Client Script. In this Kaizen, we will focus on using the Zoho CRM `SKILL.md` with GitHub Copilot
                                                                        • Kaizen #256 - Build an Arrival Readiness Web Tab in Zoho CRM

                                                                          Hi everyone! Welcome back to the Kaizen series! In the post, we discuss a use case in hospitality industry: how an Arrival Readiness web tab widget can be used to let reception staff identify and resolve issues before arrival of guests. Use case In the
                                                                        • Kaizen #198: Using Client Script for Custom Validation in Blueprint

                                                                          Nearing 200th Kaizen Post – 1 More to the Big Two-Oh-Oh! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
                                                                        • Kaizen #226: Using ZRC in Client Script

                                                                          Hello everyone! Welcome to another week of Kaizen. In today's post, lets see what is ZRC (Zoho Request Client) and how we can use ZRC methods in Client Script to get inputs from a Salesperson and update the Lead status with a single button click. In this


                                                                        Manage your brands on social media



                                                                              Zoho TeamInbox Resources



                                                                                  Zoho CRM Plus Resources

                                                                                    Zoho Books Resources


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

                                                                                                          Get Started. Write Away!

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

                                                                                                            Zoho CRM コンテンツ


                                                                                                              Nederlandse Hulpbronnen


                                                                                                                  ご検討中の方




                                                                                                                            • Recent Topics

                                                                                                                            • Bills import rejects the Account column (The account does not exist), although the accounts exist in the Chart of Accounts

                                                                                                                              Hello Zoho Books Team, I am unable to import bills into my Zoho Books. The import keeps rejecting the Account column, even though the accounts exist and work when I create a bill manually. What I am doing Bills > Import Bills, CSV/XLSX file, 145 rows,
                                                                                                                            • How do I reorder the item table columns in my invoice template?

                                                                                                                              There must be a way I just cannot find it. Anyone?
                                                                                                                            • Zoho Desk API returning 403 SCOPE_MISMATCH for Ticket Search API

                                                                                                                              Hello Zoho Support Team, We are experiencing an authorization issue with the Zoho Desk Ticket Search API. Our integration was working correctly yesterday, but we are now receiving the following error when calling the Search Tickets endpoint: API: GET
                                                                                                                            • Free webinar: Zoho Sign in Q3 2026

                                                                                                                              Hi there! From smarter signing on your Apple devices to new ways to verify and personalize your documents, Zoho Sign had a busy Q3—and we're bringing it all together in one session. Join us for a complete walkthrough of everything new this quarter, plus
                                                                                                                            • Zoho Desk - Delete an email conversation

                                                                                                                              When using Zoho support desk I see an option to delete and edit conversations that are comments, BUT if the conversation was automatically added as a conversation from an email, then the option to delete it seems not to be available. Is there a way to
                                                                                                                            • Messages do not open and I cannot reply to messages in Zohodesk

                                                                                                                              Hi, this is an unusual behaviour. I cannot reply to messages: Accessing a draft message - runs endlessly. Sending Emails fail:
                                                                                                                            • Link item in purchase order to Customer

                                                                                                                              Is it possible to link each item in purchase order to a customer which would create an associated list, so I can easily find where, when and what my customer have order from us. Thanks!
                                                                                                                            • Passing the CRM

                                                                                                                              Hi, I am hoping someone can help. I have a zoho form that has a CRM lookup field. I was hoping to send this to my publicly to clients via a text message and the form then attaches the signed form back to the custom module. This work absolutely fine when
                                                                                                                            • I want to test some payment subscription with a test credit card from stripe

                                                                                                                              I have a test customer and place https://stripe.com/docs/testing#international-cards test credit card number to the Add New Card in subscription.zoho customer page. After I added, the test card was declined. Am I missing something?
                                                                                                                            • This user is not allowed to add in Zoho. Please contact support-as@zohocorp.com for further details

                                                                                                                              Hello, Just signed up to ZOHO on a friend's recommendation. Got the TXT part (verified my domain), but whenever I try to add ANY user, I get the error: This user is not allowed to add in Zoho. Please contact support-as@zohocorp.com for further details I have emailed as well and writing here as well because when I searched, I saw many people faced the same issue and instead of email, they got a faster response here. My domain is: raisingreaderspk . com Hope this can be resolved.  Thank you
                                                                                                                            • Strengthen your account security with Password Policy

                                                                                                                              Still using the same password for all your accounts? Or perhaps your password is easy to guess or follows a predictable pattern? If so, your account could be at risk. Once someone gets hold of a password that you reuse, they could potentially gain access
                                                                                                                            • Expanding sales, marketing, and support capabilities in Zoho CRM Plus 3.0

                                                                                                                              Hey everyone, It's been more than 10 years since we launched Zoho CRM Plus back in 2014. This is quite a milestone, and we've come a long way in empowering you with everything you need to offer an exceptional customer experience. On that note, we expanded
                                                                                                                            • Introducing PRM: Build, manage, and scale your partner ecosystem

                                                                                                                              Growing a partner ecosystem is a good problem to have. What starts as a handful of partners can quickly turn into a maze of spreadsheets, emails, and disconnected processes. More partners mean more opportunities, greater reach, and new ways to grow
                                                                                                                            • Live connection to DS files in Zoho Creator / ChatGPT

                                                                                                                              As an idea, we are using ChatGPT to build with Zoho Creator (outside of Zia), which is works brilliantly to assist write deluge, provide test suggesitons etc. Currently we are uploading the DS files which are very point in time, it would be great to have
                                                                                                                            • Zoho Forms - Feature Request - Embed iFrame or Dynaic URLs in Description fields

                                                                                                                              Hi Zoho Forms team, I'm working with a client who uses Zoho Forms internally to collect information over the phone from potential work placement candidates. At the end of the form, the candidate needs to be booked in for an induction, which we've configured
                                                                                                                            • New in Office Integrator: Add text, diagrams, and drawings to your spreadsheet

                                                                                                                              Hi users, We are pleased to introduce the Shapes feature in Zoho Office Integrator's spreadsheet editor. It lets users create visual elements; including simple shapes, text boxes, freehand drawings, and structured diagrams; directly within the spreadsheet.
                                                                                                                            • Highlight what matters, erase what doesn’t in PDFs

                                                                                                                              When reviewing PDFs or preparing them for sharing, two things often come up: you want to draw attention to what’s important, and you want to hide what isn’t. Zoho PDF Editor gives you both capabilities in one place with its highlight and erase tools.
                                                                                                                            • WorkDrive Desktop Sync Is Being Deprecated: Move to WorkDrive TrueSync for a Smarter Experience

                                                                                                                              Hi everyone, We are excited to share a better, smarter way to access and manage your files directly from your computer! We’re transitioning from our legacy Desktop Sync app to WorkDrive TrueSync, designed to give you faster performance,greater flexibility,
                                                                                                                            • Set connection link name from variable in invokeurl

                                                                                                                              Hi, guys. How to set in parameter "connection" a variable, instead of a string. connectionLinkName = manager.get('connectionLinkName').toString(); response = invokeurl [ url :"https://www.googleapis.com/calendar/v3/freeBusy" type :POST parameters:requestParams.toString()
                                                                                                                            • Introducing the Zoho Campaigns MCP server

                                                                                                                              Hello everyone, We are pleased to announce that Zoho Campaigns is now available in Zoho MCP. You can now connect your Zoho Campaigns organization to AI tools such as Claude, ChatGPT, GitHub Copilot in VS Code, and Cursor, and manage your email marketing
                                                                                                                            • SubForm Custom Sort - Deluge Workflows

                                                                                                                              I have been experimenting with the Custom Order function of Subforms, it works beautifully within the subform itself and retains the sorting order. However, I need to be able to iterate through the records in Deluge using the sort order (The usage case
                                                                                                                            • Bank feeds automation is broken - requires manual intervention and authentication

                                                                                                                              Yodlee supports Australian Open Banking CDR protocols natively, but Zoho Books' implementation is still triggering legacy screen-scraping MFA blocks on CBA and other business banking accounts. When will Zoho update its Australian bank feed pipeline to
                                                                                                                            • Cannot Access Subform Display Order in Deluge

                                                                                                                              As highlighted in this community post, we still have to deal with the significant limitation of not being able to access the user-sorted order of subform rows through Deluge. This creates a major disconnect between the UI capabilities and backend automation,
                                                                                                                            • Process FOR loop for subform items in the order of the manual sorting

                                                                                                                              Hi Guys, I have searched everywhere and tried everything, but I still not able to resolve one particular challenge. I have a subform in my Invoice with rows for each item. I made it so that we can change the order of the items manually. I need to be able
                                                                                                                            • Augmenting subform capabilities

                                                                                                                              Greetings, everyone! Finally, the day has come for us to announce some of the most anticipated, requested, and exciting updates to subforms in Zoho Creator. As you're aware, subforms are an integral part of Creator forms, as they help in establishing
                                                                                                                            • Build appointment scheduling into your vibe-coded apps with Zoho Bookings

                                                                                                                              Exploring vibe coding? Wondering how an app built with AI can handle appointment scheduling? Join our upcoming live webinar to discover how Zoho Bookings APIs can help connect applications to scheduling capabilities. Here's what we'll explore: • Show
                                                                                                                            • Is there a way to make Reason For Loss field mandatory at Closed Lost stage?

                                                                                                                              Hi guys, Reason For Loss system picklist appears on Verify Details page but it is not mandatory so as a result, AEs tend to omit it (leave at default value -None-). Is there a way to make it mandatory at Closed Lost? I tried layout rule but this field
                                                                                                                            • How to customize the displayed name of contacts in Trident?

                                                                                                                              Hello, For work purposes, I sort different customers into different folders, and I also change their display names in Contacts so I can easily recognize them later. However, Trident doesn’t seem to support this. Even after I edit a contact’s name in Contacts,
                                                                                                                            • User and mailbox reports in Zoho Mail: Review account status, storage, and login activity of users

                                                                                                                              Administrators often need answers to questions such as which users have never logged in, whose storage is almost full, or which mailboxes are accessed through POP or IMAP. The User and Mailbox reports in the Zoho Mail Admin Console provide these details
                                                                                                                            • ZOHO CRM APP - SALESINBOX

                                                                                                                              Is it possible to access SALESINBOX in the CRM MOBILE APP
                                                                                                                            • Unbundle feature for composite items

                                                                                                                              We receive composite items from our vendors and sell them either individually or create other composite items out of them. So, there is a lot of bundling and unbundling involved with our composite items. Previously, this feature was supported in form
                                                                                                                            • Zoho mail always free not showing up for me

                                                                                                                              Im in the Australian data centre region
                                                                                                                            • Tip #96 – See more of the remote screen with Virtual Monitor – 'Insider Insights'

                                                                                                                              Hello Zoho Assist Community! Say you're supporting a device that has no monitor attached, like a server in a closet or a kiosk PC. You connect, and the screen is tiny, blurry, or distorted. Text overlaps and windows end up in odd places. Troubleshooting
                                                                                                                            • Understanding transactional channels in Zoho CPaaS

                                                                                                                              Every interaction with a business creates an opportunity to communicate.Whether it's welcoming a new user, confirming a payment, sharing an order update, or verifying a login, timely communication keeps users informed and connected. But how do businesses
                                                                                                                            • Autoscan Settings

                                                                                                                              I saw that autoscan is now included in my plan which is great however when I import pdf invoices from my main supplier which contain inventory lines and some also include shipping charges the autoscan doesn't match any of the items and also misses the
                                                                                                                            • How to resubscribe to email after using unsubscribe link in Zoho

                                                                                                                              I was testing the unsubscribe link feature from our contacts module in ZohoCRM and I sent my personal email a version of an email template with the default embedded unsubscribe link to see if it would utilize the "Email Opt Out" field to track un-subscription.
                                                                                                                            • WhatsApp Calling Integration via Zoho Desk

                                                                                                                              Dear Zoho Desk Team, I would like to request a feature that allows users to call WhatsApp numbers directly via Zoho Desk. This integration would enable sending and receiving calls to and from WhatsApp numbers over the internet, without the need for traditional
                                                                                                                            • [ZohoDesk] Improve Status View with a new editeble kanban view

                                                                                                                              A kanban view with more information about the ticket and the contact who created the ticket would be valueble. I would like to edit the fields with the ones i like to see at one glance. Like in CRM where you can edit the canvas view, i would like to edit
                                                                                                                            • No access to contact categories in Zoho Mail Apps

                                                                                                                              I have set up a number of contact categories for my organization. When I compose an email using a web browser these categories are visible. When I compose an email using your Android or iOS Apps no contact categories are visible. Is this expected? If
                                                                                                                            • Zoho Plug In

                                                                                                                              Is there anyone out there who is able to use it? I have seen lots of problems posted, unable to get any satisfactory suppport at the moment!  I would be really appreciate hearing from users that have it installed and working, my team are loosing belief it will ever work. Be great to hear from those that have a more positive experience
                                                                                                                            • Next Page