Native GraphQL support for Salesforce

Dragan Vujnovic
Sep 28, 2020 · 4 min read

This article is about native GraphQL support on Salesforce platform (without mediations). More about GraphQL and Salesforce in general can be found on respective resources.

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 the 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: the 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 can 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
  • Introspection: 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. 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)
  • The 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 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

We’d love to hear from you — feel free to reach out on the Maven Mule Contact Form

A Maven Mule is a professional services company and Salesforce ISV partner company. We’re a team of Salesforce architects, versatile developers, and project managers.

Maven Mule

Disruptive innovation for Salesforce