Salesforce Asked by Tekill on November 25, 2021
I recently started looking into GraphQL as I have been experimenting with ReactJS. In all my readings I have not really seen anything about GraphQL and Salesforce. I am wondering if there would be any benefit in using GraphQL when developing a visual-force page within SF?
I can’t seem to find any articles about that, I was wondering if someone could enlighten me as to the piece of the puzzle I may be missing.
Would having a GraphQL engine between your visual-force page and your apex controller yield any benefit or would it just be unnecessary fluff?
Yes, there are many benefits to use GraphQL on Salesforce. Some of the benefits are summarised in this reply (and could apply also on VisualForce development but they depend on the specific use case).
Note: this detailed answer is about native GraphQL support on the Salesforce platform (with no mediations). More about GraphQL and Salesforce, in general, can be found on respective resources. The author of the answer is in direct relation to the described product as a developer.
Introduction
GraphQL is a query language for APIs, developed by Facebook and used since 2012., which provides a complete and understandable description of the data in the underlying system. GraphQL specification is open from 2015. and can be found at GraphQL Foundation web This disruptive technology provides the clients with a more efficient way to query the required data in a single request. Accessible on a single endpoint a GraphQL offers to the clients a way to select a specific kind of required data, aggregated in a defined structure, and deep as much as needed. GraphQL is providing great business benefits like:
With some of the known advantages for developers:
How does GraphQL execution work?
For starters, GraphQL uses a simple concept for how it changes its queries into results. It traverses the query field by field, executing ‘resolvers’ for each field. If a parent resolver function is required by a child, the parent query will resolve first and pass its result to the child for use in its own query. Finally, once the execution algorithm is done, it forms all the data into the correct shape and returns it.
Why GraphQL on the Salesforce?
Salesforce is a big and great platform with a vast of different API options (like REST API, Bulk API, Streaming API, SOAP API, and so on). All these options are good to use in specific use cases and exist by purpose, but Salesforce is a cloud platform and as such it has different limits (like a number of allowed API calls) to prevent rogue scripts to use dedicated resources and to protect the customer instances. So optimizing queries seems also not just a benefit for different trusted data consumers but also it is a benefit for the server, a Salesforce Org (and might have a direct implication on the commercials, as depending on available licenses different limits apply).
Maven Integration Platform (with native GraphQL support)
With a Maven Integration Platform (MIP) a GraphQL language with Queries and standard Salesforce object schema are natively supported and available directly on a Salesforce via existing REST API, exposed on the dedicated endpoint. Currently, MIP is the only fully native package that has a full complaint GraphQL parser available in AppExchange. Because the MIP is a native package it doesn't require any other mediation service, it is queried directly as any other standard Salesforce REST API endpoint (or via Apex API). More about setup and querying can be found at official MIP documentation. Let us summarise some of the benefits of native GraphQL support on the Salesforce platform:
Answered by Dragan Vujnovic on November 25, 2021
GraphQL is an open source data query and manipulation language meant to provide a more efficient, powerful and flexible alternative to REST and ad-hoc web service architectures.
In practice it acts as an abstraction layer between a client (web, mobile, etc) and a backend (REST or database). The intent is to unify and abstract all communication between these components.
Exposing Salesforce REST services in GraphQL and querying them from a Javascript client included in VisualForce would only introduce an unnecessary and under-performing layer because you can directly access code from the controller.
But there are other use cases where GraphQL may prove beneficial in conjunction with the Salesforce REST services: - a backend where web or mobile clients need to access both Salesforce REST APIs, a database or other unrelated REST APIs.
You can start using this schema https://github.com/jpmonette/salesforce-graphql and enrich it with your Salesforce objects.
Answered by Marius Toth on November 25, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP