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
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
@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