REST vs GraphQL Tradeoffs
Compare REST and GraphQL for a product API. When is GraphQL worth the complexity?
Answers use simple, clear English.
Quick interview answer
REST: simple caching, HTTP semantics, many endpoints. GraphQL: clients ask for exact fields, fewer round-trips for nested UIs, but caching, authz per field, and query cost controls are harder. Choose GraphQL when many clients need different shapes; otherwise well-designed REST/BFF may win.
Detailed answer
REST: simple caching, HTTP semantics, many endpoints. GraphQL: clients ask for exact fields, fewer round-trips for nested UIs, but caching, authz per field, and query cost controls are harder. Choose GraphQL when many clients need different shapes; otherwise well-designed REST/BFF may win.
Real example & use case
Mobile app with nested feeds uses GraphQL to avoid overfetch; public webhook integrations stay REST.
Pros & cons
Pros of GraphQL: flexible queries. Cons: N+1 resolvers, complexity. REST: simpler ops.