Adding GraphQL Mutations to the Salesforce API
We talk about the newest big update for GraphSQL — our native GraphQL API extension for Salesforce
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.
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.
Adding GraphQL 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:
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.
Created Multiple Related Records
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!
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.
Try out the new features today!
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.
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