Salesforce GraphQL API goes into Beta
twitter social iconlinkedin social iconfacebook social icon

Salesforce GraphQL API goes into Beta

With the Summer '22 release, the Salesforce GraphQL API is going into Beta. This new API allows developers to interact with the Salesforce Platform through GraphQL, providing a new way to create rich and performant applications.

What is GraphQL?

Internally developed by Facebook in 2012 and publicly released in 2015, GraphQL is a standard query language for APIs and a runtime for fulfilling those queries with your data. It allows clients to define the structure of the data required, and the same structure of the data is returned from the server. It differs from a traditional REST API, where you get all the information that a specific endpoint is supposed to provide, and sometimes more information from different endpoints, making multiple roundtrips to the server. With GraphQL you can query the exact information you want from a single endpoint and you only get what you ask for.

What about REST APIs?

While REST APIs have been the gold standard, so to say, there are certain disadvantages to them. The biggest being it does not let you pick and choose your exact data requirement. For example, if you want to look up a user's email address, you might have to call a REST API endpoint that gives you all the data that you have permission to access, about that user. So, you might also receive their phone number, address, their organization's name, etc. In short, everything returned to you that isn't the user's email address is wasted data. With GraphQL, you include all the fields in your query that you're interested in, and receive only the requested data for those fields.
Obviously, it is wasteful to return too much data in a single API request. One option would be to create multiple endpoints that return specific data to limit waste. This, however, would result in too many REST endpoints, which would make it hard for developers to determine which one they need to call. If you want all associated data, you would have to call each endpoint, which would then mean another round trip to the server. As a developer, you want to minimize network trips and unnecessary data transfer to improve performance for your users. A GraphQL API solves this problem by allowing you to retrieve all the data your application needs in one request.
It's often the case that REST APIs have limited or no support for options like field selection and aggregation. This can be a hindrance for developers trying to create the best possible experience for their users. The solution is to have a single REST endpoint whose response has exactly what you need, with nothing extra. Currently this endpoint doesn't exist. As a developer, you can request that a new REST endpoint be created with all of your exact needs, but it's unrealistic to think that a new endpoint will be created for every possible use case. The Salesforce GraphQL API is a single endpoint whose response can be shaped by you, giving the developers more control over the data that is returned.

Salesforce and GraphQL

Originally posted on IdeaExchange in 2017, the request for GraphQL support is currently in Beta with the Summer '22 release and currently supports the UI API, containing concrete representations of Objects and respecting the Field Level Security (FLS) settings of the current user. To learn how to explore the Salesforce GraphQL in practice, check out this Salesforce post.

About the author

Guilherme has been on board as a Salesforce Developer with Appsolutely since 2019. He likes to push the boundaries of tech and innovation as much as he can. As a software developer, he loves the challenge of being given a problem and then having to find his own way to solve it.
Originally from Brazil, he decided to move to The Netherlands a few years ago. Quite a culture shock for this mountain bike enthusiast, since there are practically no steep hills to climb. However, he quickly discovered that even in our little country, you can bike for hours through amazing landscapes and challenge yourself. A perfect counterweight for the heavy coding he’s doing during the week, we dare say!

Guilherme Uhelski

Want to read more from Guilherme? Read for example his blog about Salesforce TrailblazerDX '22 or discover more blogs.

Share this article:
twitter social iconfacebook social iconlinkedin social icon

divider graphic


Product customizability and Overridable flows: Giving the controls to the customer
September 20, 2022

Product customizability and Overridable flows: Giving the controls to the customer

By: Hugo van Krimpen When developing Salesforce products for the AppExchange, we regularly face requ...

Hugo van Krimpen
By Hugo van Krimpen
Partner Event: Future-Proof Service Operations 2022
September 4, 2022

Partner Event: Future-Proof Service Operations 2022

Future-Proof Service Operations How to extend your service operations to sales, marketing, and beyon...

Luuk Timmermans
By Luuk Timmermans
Why you should stop just creating code!
August 10, 2022

Why you should stop just creating code!

By: Rodrigo Dantas Deep dive on Software Best Practices, and what we saw at TDX22 that backs up this ...

Rodrigo Dantas
By Rodrigo Dantas