GraphQL is an open-source database query and manipulation language, developed by the GraphQL Foundation. At it’s core a GraphQL query let’s you specify exactly what data is required, and in the structure and format that you want back.

With our new package, GraphSQL you can add GraphQL support to Salesforce, allowing your integrations to be more efficient by being able to get data from several objects in a single request!

What Are GraphQL Queries?

To give you an example, let’s take the following Salesforce SOQL query:

SELECT Id, Name FROM Account LIMIT 10
In GraphQL this becomes:
{
  Account(limit:10) {
    Id
    Name
  }
}
This JSON-like structure is the format all GraphQL queries use, and one of the benefits of this is that you get back data from GraphQL in the exact same format.

This might not seem more useful right now, but let’s say you have a more complex scenario and you want to get all the Opportunities and Contacts for a specific Account, plus all the Tasks related to those contacts.

In SOQL you’d have to run multiple queries as you wouldn’t be able to nest that many relationships, but in GraphQL you can do it in a single request:
{
  Account(limit:1) {
    Id
    Name
    Opportunity {
      Id
      Name
      Amount
    }
    Contact {
      Id
      FirstName
      Task {
        Subject
        DueDate
      }
    }
  }
}
You can see we’ve simply nested each of the child objects as a separate JSON-like object, with all the fields. This would retrieve us all the data we need in one request!

(If you want to test it out, you can head over to the Test Drive, open the GraphSQL Playground tab, and copy in this query!)

GraphSQL Playground

To make things even easier, the package also adds a playground into Salesforce, which is a page where you can test out different GraphQL queries without writing any code.

Test out GraphQL queries in real-time on your live Salesforce data

This makes it really easy to test out your queries on the platform before then adding them into your third party integrations.

Get started today for free

GraphSQL is free to use and publicly available on the AppExchange!

(If you want to use GraphSQL in a scratch org, the Package Id is 04t4J000001O4O1)

We’ve also got a Test Drive available so you can go and use the playground without having to install anything.

Try it out today for free!

We’re always improving our free products and trying to make them as useful as possible for the Salesforce ecosystem, so we’d love to hear your feedback on it. You can reach out to us below or through our feedback form.