GraphQL vs REST API: Architecture Comparison, Payload Size, and Trade-Offs
Compare GraphQL and REST APIs. Analyze over-fetching, under-fetching, N+1 query problems, HTTP caching, and payload sizes with practical examples.
By Cometflow API Engineering Team • Updated 2026-10-06
Choosing between a resource-oriented REST API and a schema-driven GraphQL API involves trading HTTP edge caching simplicity against flexible client field selection.
1. Architectural Trade-Offs
- Field Selection (Over-Fetching): GraphQL allows mobile clients to request strictly
{ user { id name } }, whereas REST endpoints typically return the full resource object unless sparse fieldsets are implemented. - HTTP Edge Caching: REST
GETendpoints work natively with CDN caches and browserETagheaders. GraphQL sends queries viaPOST /graphql, requiring persisted queries or normalized client caches. - The N+1 Resolver Problem: Naive GraphQL resolvers execute a separate SQL query for each item in a list unless batched using the
DataLoaderpattern.
Frequently Asked Questions (FAQ)
How does GraphQL report partial errors?
Unlike REST (which uses HTTP 4xx/5xx status codes per resource), GraphQL often returns HTTP 200 OK with both a partial "data" object and an "errors" array detailing which specific field resolvers failed.