Adding GraphQL Mutations to the Salesforce API

We talk about the newest big update for GraphSQL — our native GraphQL API extension for Salesforce

Elliott
Elliott
Nov 14 · 3 min read

We always like to keep an ear to the ground on what people are looking for within the Salesforce ecosystem, and there’s no better place that the Salesforce Ideas community.

GraphSQL is one of the many free tools and apps we built inspired by different ideas by people — this one in particular is what first sparked our interest with GraphQL. We had used GraphQL before a few times and found it a really useful tool, and as seasoned Salesforce integrators could see the immediate benefits that a GraphQL-like interface could bring to Salesforce’s own REST API.

Running GraphQL queries via the GraphSQL Playground

When we released GraphSQL it was more to see if it could be done, and we only implemented Queries which allow you to retrieve data. As more and more people started using GraphSQL we found the main thing everyone was after was actually Mutations.


In GraphQL, Mutations allow you to create or edit data in the system. In Salesforce world this would be the same as creating or updating a record in Salesforce. Here’s a basic example:

A basic example to create a new Account called “Test”

One of the first benefits of using Mutations in GraphSQL is you can create or update data, but have completely different fields returned to you. In this example we create an Account called “Test” and returned the Id, Name, and Created Date!

Right off the bat this saves you two different API calls in Salesforce, as normally you’d have to do an update call, then a query call to get the data back for the new record. But we can take this even further using the convenient nested logic that GraphQL uses.


In GraphQL Queries you can nest data to represent child records you want to retrieve. The same applies with Mutations. Through GraphSQL you could insert an Account, related child Contact, and related grandchild Task all in one go — saving multiple API calls back and forth!

A more complex example showing the power of GraphQL Mutations

The example above will insert 3 separate records, automatically linking them together by the correct parent field. Where once we’d need 3 separate calls to the REST API, with GraphSQL we can do the same with just 1.


Mutations have now been added to GraphSQL! (version 1.5+)
If you already have GraphSQL installed you would of already received the update so you won’t need to do anything.

If you want to try out GraphSQL for yourself, you can install it for free from the AppExchange! Not only is it free to use, but the code itself is available publicly on our GitHub.

As with all our apps and tools we’re constantly improving them based on feedback of our users. If you have a suggestion for GraphSQL we’d love to hear it!


At Appitek, our aim is to help make your job easier, by creating simple but effective Salesforce applications that make you more efficient at what you do.

Appitek is a registered Salesforce ISV partner.
Salesforce and Salesforce Lightning are registered trademarks of Salesforce.com

Appitek

We build innovative solutions for business, using the best of modern capabilities and technologies. Behind all that? The power of Salesforce.

Elliott

Written by

Elliott

Multidisciplinary full stack developer, with a history in product & digital design. CTO at Appitek Ltd.

Appitek

Appitek

We build innovative solutions for business, using the best of modern capabilities and technologies. Behind all that? The power of Salesforce.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade