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.
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:
- Less Code
- need for less code as developers can get only what they need (in required and available structure)
- Rapid Development
- developers can make changes on the client-side without impacting server
- Less Total Cost of Ownership
- less code implies less maintenance
- Shorter Time to Market
- quicker development reduces initial costs and time required for go-live
- Visibility on Available Data Structure / Strong Type
- with Introspection capability developers can see what they are able to use
- Fewer Requests
- A huge benefit for cloud-based systems (usually having various API limits)
- Reduced Data Fetching Time
- batching requests saves time spent on roundtrips and data bulkification improves performance
With some of the known advantages for developers:
- Dynamic Field Selection
- Developers can dynamically select the exact fields needed by their component
- Query Aggregation
- Single query removes the need for multiple API calls
- Client-Defined Filtration
- Expressive filtering that eliminates the need to supply record IDs
- Programmatic discovery of the Salesforce graph through introspection
- Raw performance
- Several orders of magnitude faster than traditional REST
- Development speed
- Configuration friendly, easily customizable, virtually no initial setup and maintenance cost
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:
- Built natively on Salesforce
- no additional systems or services required
- Extends existing Salesforce API
- Extends native and well-known Salesforce capabilities
- Dynamic Salesforce schema resolution
- All queries are resolved on the fly and existing Salesforce schema is used (including standard, managed, or custom objects)
- Standard Salesforce security model is enforced
- Standard Salesforce security model capabilities are used and consumer connection permissions are enforced
- Easy setup
- Less initial setup and maintenance cost (as standard Salesforce Admins and Developers can do the whole work)
- Plug and Play approach
- core functionalities are ready immediately after deployment / no configuration
- Introspection of standard Salesforce schema
- GraphQL introspection is supported