GraphQL API Support - Ideas - Salesforce Trailblazer Community

All Ideas

Idea Details

Post an Idea
1,300  Points
Open
Idea has been posted. Give it an upvote or downvote.

GraphQL API Support

API

It would be great to see GraphQL supported as a standard API language to access Salesforce Data
  • This is an emerging standard in the way of requesting data over http (like REST and SOAP that Salesforce supports today). And I would like to suggest Salesforce looks into it.
  • Benefits:
    • You only get back only what you ask for, instead of all fields on the object, reducing the size of the response
    • You can get back more than one object in a single standard request call which would reduce the impact on limits because you would be able to get back a slew of data from several objects with a single call rather than several calls, one for each object
  • There are people who have written support for it in many languages, including Java --thinking APEX there (http://graphql.org/code/#java).
  • I can see how this spec would translate very easily into SOQL.
 
  • Example

    Given the following SOQL:
    SELECT Account.Name, Account.Custom_Field_1__c,(SELECT Contact.Name, Contact.Custom_Field_2__c FROM Contacts) FROM Account Where Account.Id = 'xxxxxxxxxxxxxx'



    this is what a GraphQL request might look like:
{
      Account(Id: "xxxxxxxxxxxxxxx") {
            Name,
            Custom_Field_1__c,
            Contacts: {
                  Name,
                  Custom_Field_2__c
            }
      }
}

And this is what the response would look like (it comes back in nearly the same structure as specified by the request. You’ll notice Id was not requested but I know it is always returned by Salesforce so I added it in):
{
      Account: {
            Id: "xxxxxxxxxxxxxxx",
            Name: "Berkshire Hathaway Travel Protection",
            Custom_Field_1__c: "Some value",
            Contacts: [
                {
                        Id: "cccccccccccccc1",
                        Name: "Scott Gerstl",
                        Custom_Field_2__c: "some other value"
                },
                {
                        Id: "cccccccccccccc2"
                        Name: "Jakub Hanson",
                        Custom_Field_2__c: "jhsdlgkjhsdlg"
                }
           ]
      }
}

Merge Idea · Flag

  • Upvotes
  • Downvotes

Ideas

Apps

from AppExchange

Questions

Help us to keep IdeaExchange clean by pointing out overlapping ideas. We'll investigate your suggestion and merge the ideas if it makes sense.



 

 

Thanks for your merge suggestion. We will review it shortly and merge the ideas if applicable.

Salesforce takes abuse situations very seriously. Examples of abuse include but are not limited to posting of offensive language or fraudulent statements. To help us process your request as quickly as possible, please fill out the form below describing the situation. For privacy and security reasons, the final outcome of an abuse case may not be revealed to the person who reported it.


 

Thank you for your feedback. We take abuse seriously and will investigate this issue and take appropriate action.