What is the GraphQL API?
GraphQL is a new way to address many pain points for application developers; all GraphQL servers adhere to a specification, which features patterns that make it easier to build complex experiences across a wide variety of platforms and devices.
Salesforce GraphQL API is available in Enterprise, Performance, Unlimited, and Developer Editions. It adheres to the June 2018 version of the spec.
The following benefits are available for Salesforce developers, including:
- Field selection
- Resource aggregation
- Schema introspection
The first of these patterns is field selection, which requires the client generating the GraphQL query to explicitly declare which fields they would like to receive in the response. This technique reduces the size of the payload, as the client only receives fields that were included in the query.
The second pattern is aggregation, which allows the client to specify a traversal across the fields in the GraphQL schema. Aggregations reduce round trips between the client and server, returning a set of related resources within a single response.
The final pattern is introspection, which is the ability to send a query to the GraphQL server to ask questions about the types, fields, and their relationships within the schema. When all these patterns are combined, it results in more responsive, higher-quality applications.
The GraphQL API adds even more features:
Concrete representations of your UI API Enabled sObjects, honoring the object-level security and field-Level security of the current user. Therefore, two different users can have two different views of the GraphQL schema based on their access permissions.
Adherence to the Relay Connection Specification when working with paged resources.
For more information on getting started with the GraphQL API, we recommend the following resources in the Salesforce Developers' Blog.