GraphQL vs REST: Which Should You Use?
On this page
GraphQL vs REST is not a contest
GraphQL isn't "the new REST", and REST isn't outdated. They make different trade-offs. Many companies run both: REST for public and partner APIs, GraphQL as the layer their own apps talk to.
GraphQL vs REST compared side by side
| REST | GraphQL | |
|---|---|---|
| Data shape | Fixed per endpoint, chosen by the server | Chosen per query by the client |
| Round trips for a complex screen | Often several | Usually one |
| HTTP caching and CDNs | Natural: GET by URL | Needs persisted queries or client-side caches |
| Errors | HTTP status codes | Usually 200 with an errors array; partial success possible |
| Contract | OpenAPI (optional) | Schema (required), with introspection |
| Versioning | Often /v1, /v2 | Usually continuous evolution with deprecations |
| Rate limiting | Per request | Per query cost |
| File uploads, streaming downloads | Simple | Awkward; often a separate REST endpoint |
| Security surface | Per route | Per field and object, plus query cost |
| Learning curve | Lower; any HTTP client works | Higher; schema, resolvers, tooling |
Three scenarios: which API style fits?
A public payments API for thousands of developers. Integrators use every language and tool; HTTP caching, simple webhooks and clear status codes matter; the operations are stable (create a charge, refund). REST, with OpenAPI docs and SDKs generated from them. Stripe made this choice.
A product with web, iOS and Android apps, each screen combining data from users, orders, recommendations and inventory services. Screens change every sprint; mobile networks are slow. GraphQL as the client-facing layer, with resolvers calling the services. Clients fetch exactly what each screen needs in one request, and frontend teams ship without waiting for backend endpoints.
Internal service-to-service calls with high throughput. Neither is ideal: gRPC with Protocol Buffers gives typed contracts, efficient binary encoding and streaming (see the gRPC course). REST is fine when simplicity matters more than efficiency.
Using REST and GraphQL together
A common, effective architecture:
- Domain services expose REST or gRPC internally.
- A GraphQL layer (or a backend-for-frontend, Day 21) composes them for the company's own apps.
- Public partners get a REST API with stable, versioned endpoints and webhooks (Day 25).
- Large organizations use GraphQL federation (Apollo Federation, GraphQL Mesh, WunderGraph Cosmo) to let each team own part of one combined graph.
Four questions to decide between REST and GraphQL
- Who are the clients? Many external developers favor REST; your own varied apps favor GraphQL.
- How varied are the data needs? Fixed, simple operations suit REST; many screens with different shapes suit GraphQL.
- How important is HTTP caching? Public, cacheable content leans REST.
- Can the team operate it? GraphQL needs schema governance, query-cost limits and resolver performance work.
Check yourself
Every language and tool supports it, HTTP caching and status codes work naturally, and fixed endpoints are easy to document and version.
Each screen fetches exactly the fields it needs across several sources in one request, saving round trips on slow networks.
HTTP caching, since queries usually go by POST to one URL; cost-based rate limiting, since one request can be cheap or enormous; file uploads; and monitoring, since errors often arrive with a 200 status.
Yes. Many companies offer REST for public partners and webhooks, and GraphQL for their own apps, both backed by the same services.
Who the clients are, how varied their data needs are, how important HTTP caching is, and what the team already knows how to run.