3

I recently started looking into GraphQL as I have been experimenting with ReactJS. In all my readings I have not really seen anything about GraphQL and Salesforce. I am wondering if there would be any benefit in using GraphQL when developing a visual-force page within SF?

I can't seem to find any articles about that, I was wondering if someone could enlighten me as to the piece of the puzzle I may be missing.

Would having a GraphQL engine between your visual-force page and your apex controller yield any benefit or would it just be unnecessary fluff?

  • what's your actual requirement behind using GraphQL, Are you working on a complex and complicated data layer, which you want to bring on VF? – user2809299 Feb 9 '17 at 4:31
  • I really like the data scheme that GraphQL uses and since I usually end up with data being pulled in a variety of component on my VF pages I was wondering if GraphQL made sense to use in SF. @user2809299 – Tekill Feb 11 '17 at 22:36
2

GraphQL is an open source data query and manipulation language meant to provide a more efficient, powerful and flexible alternative to REST and ad-hoc web service architectures.

In practice it acts as an abstraction layer between a client (web, mobile, etc) and a backend (REST or database). The intent is to unify and abstract all communication between these components.

Exposing Salesforce REST services in GraphQL and querying them from a Javascript client included in VisualForce would only introduce an unnecessary and under-performing layer because you can directly access code from the controller.

But there are other use cases where GraphQL may prove beneficial in conjunction with the Salesforce REST services: - a backend where web or mobile clients need to access both Salesforce REST APIs, a database or other unrelated REST APIs.

You can start using this schema https://github.com/jpmonette/salesforce-graphql and enrich it with your Salesforce objects.

|improve this answer|||||
  • oddly enough, it's actually way faster to build a VF page that uses the REST API (vs VF postback & viewstate) – NSjonas Feb 7 '19 at 7:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.