GraphQL vs REST: An Honest Comparison From Production

D
Dick Edidiong Bassey
·

GraphQL is excellent when: your API serves many client types with different data requirements (mobile app, desktop web, third-party integrations), your data is deeply hierarchical with complex relationships, and you have the tooling discipline to manage schema evolution and resolver performance.

REST is excellent when: your API has simple, well-defined resource boundaries, your client types have consistent data requirements, and your team is more comfortable with the explicit, cacheable semantics of HTTP.

Where GraphQL causes problems: the N+1 resolver problem (without DataLoader, a list query will issue one resolver per result), schema versioning complexity, and the difficulty of HTTP caching (most GraphQL APIs run over POST, which is not cacheable by default).

SellTrove's public API is REST — consistent client requirements and excellent HTTP caching via CloudFront. The internal data aggregation service is GraphQL — diverse consumer requirements and complex relationships.

Use GraphQL where it solves a real problem. Use REST where it does not create one.

— Dick Bassey | DevDick | 2024