GraphQL
Introduction
What is GraphQL:
- Specification for API Server + Query Language - Facebook 2015
- Single endpoint for all the resources, that can be aggregated
- Requests only the necessary data
- Schema-driven, enabling introspection - metadata friendly
- Widely adopted through a fast growing community
Useful resources:
- GraphQL Foundation
- Landscape
- Salesforce doc
- soql-to-graphql
- Full stack Tutorial
- SF Community group
- annual survey results
Usage with SF Explorer
GraphQL offers very interesting use cases for salesforce. A number of tools are available in the community and SF Explorer ships with a built in version of GraphiQL with the following advantages:
- No need to authenticate - as easy as it should be
- SOQL transition tool
- Sample queries to get you started
- LWC Generation with the graphql
wire
adapter
To give it a try navigate to Code and then select GraphQL:
SOQL transition tool
If you are not familiar with graphQL but you are a SOQL ninja 🥷🏿, you can use the SOQL transition tool:
- Write your query with auto completion and the syntax you know
- Generate the graphQL equivalent
Playground
Variables
TLDR: Refer the variables with traditional SOQL Apex Binding ie :varname
Query
Loading...
info
Beware that graphQL is case sensitive compared to SOQL
Provided examples
If you open the history button you will find a number of queries to help you get started:
- Search Accounts and their opportunities
- QueryAccountsWithCriteria
- QueryCasesWithCriteria
- Object info for Account and Case