Skip to main content Join us at TDX in San Francisco or on Salesforce+ on March 5-6 for the Developer Conference for the AI Agent Era. Register now.

Hello everyone, 

 

 I have only used Lightning Data Service and Apex in the past when I needed to retrieve data. I'm considering using GraphQL for an upcoming use case, but I'm unsure what are the pros and cons of using Apex vs. GraphQL. I haven't been able to find a good comparison of each approach. Could anyone provide some examples of considerations when deciding between using Apex and GraphQL? Thank you!

2 answers
  1. Jan 15, 12:29 AM

    As a Dev, on top of what Kirsten listed

    Pros for GraphQL:

    • No Apex Test coverage
    • No Apex class to provide permissions for
    • Object and field permissions require read access min

    Cons for GraphQL:

    • Missing object/field access can cause errors that are harder to handle gracefully or override
  2. Jan 14, 12:05 AM

    @Jordan Cousins for complex operations, data transformations or bulk processing, Apex will be more appropriate but for flexible, client driven querying especially when dealing with related data in a single request GraphQL might be the better choice

0/9000