All articles
165 articles · updated weekly See our Tools
All articles
Comparisons

GraphQL vs REST: when GraphQL is worth it (and when it isn't)

Overfetching, N+1, caching, and operational complexity: why most APIs don't need GraphQL, and when it actually makes sense.

GraphQL vs REST: when GraphQL is worth it (and when it isn't)
COVER · Comparisons

You read the hype, watched the GraphQL conf talks, and now you're convinced your REST API is outdated. Before migrating everything, it's worth understanding why most APIs I've seen — including the ones that scale — still run on REST without trouble. GraphQL solves real problems, but it usually solves problems you don't have yet.

Quick context: GraphQL was born inside Facebook in 2012, for the mobile app, was open-sourced in September 2015 and, since 2018, has been governed by the GraphQL Foundation, under the Linux Foundation. If you need a primer on what an API is before the comparison, start with what an API is. Here's the difference between GraphQL and REST in one table, followed by the reasoning behind each row.

REST GraphQL
Endpoints One per resource (/users/42, /orders) Usually just one (/graphql)
Response shape Defined by the server Defined by the client's query
Overfetching / underfetching Common; solved with ?fields= or per-screen endpoints Solved by the query itself
HTTP caching (CDN, browser) Native on GET Needs GET with the query in the URL, or persisted queries
Versioning /v1, /v2 or a header Schema evolution with @deprecated
Errors HTTP status per response errors in the body; 4xx only for request errors
N+1 Concentrated in the endpoint A trap per resolver; needs DataLoader
Security Rate limit per endpoint Query depth and complexity limits
Learning curve Low Schema, resolvers, its own tooling

What overfetching and underfetching actually mean (and why it matters)

Overfetching is when the endpoint returns more fields than the client needs. Underfetching is when it returns less, and the client has to make multiple requests to build a complete response.

These problems exist. But before assuming GraphQL is the solution, it's worth measuring how much they're actually costing you.

REST overfetching is usually solved with simple query params:

GET /users/42?fields=id,name,email

It's not as elegant as a GraphQL query, but it works, and any developer understands it without reading documentation. If the extra payload is 200 bytes, it probably doesn't justify switching the entire stack.

Underfetching is the more legitimate case for GraphQL. If the frontend needs data from users, orders, and products to render a screen, REST needs three requests or a specific composition endpoint. GraphQL solves this with a single query. That gain is real — especially on mobile with poor connectivity.

The issue is that most applications have screens with reasonably predictable data. If you control both frontend and backend, you can create screen-specific endpoints (BFF — Backend for Frontend) that solve underfetching without GraphQL.

The N+1 problem (and how it shows up on both sides)

The N+1 problem appears when you fetch a list of entities and then make a separate query for each item in the list. It's the nightmare of any poorly configured ORM.

In GraphQL, N+1 is almost a built-in trap. If you have a users resolver that returns 50 users, and each user has an orders resolver, you'll fire 50 order queries — unless you implement DataLoader or some batching strategy.

// Resolver without DataLoader — N+1 guaranteed
const resolvers = {
  User: {
    orders: (user) => db.orders.findAll({ where: { userId: user.id } })
  }
}

In REST, N+1 usually shows up in a poorly implemented composition endpoint, but it's more visible and easier to diagnose because it's concentrated in one place.

DataLoader fixes N+1 in GraphQL, but it's one more thing to implement, test, and maintain. It's complexity that didn't exist before.

Caching: where REST has a clear advantage

This is one of the points where REST wins unambiguously: HTTP's cache model was built for GET requests with static URLs.

A GET /products/42 is cacheable by CDN, by the browser, by a reverse proxy. You configure Cache-Control, ETag, and most infrastructure already knows what to do.

In practice, most GraphQL clients send everything via POST to a single endpoint (/graphql), and POST isn't cached by CDNs or the browser. The GraphQL over HTTP specification allows GET for queries — only mutations can't use GET — and you can combine that with persisted queries to get short, cacheable URLs. It works, but it's work you have to set up; in REST, the Cache-Control and ETag of a GET already handle it. How those headers work is covered in browser cache: Cache-Control and ETag.

If your API serves public content and you want to put a CDN in front of it, GraphQL will require extra work. REST will work naturally.

The complexity nobody mentions in intro posts

GraphQL isn't just "writing more flexible queries". It's an entire system you need to operate:

Schema and mandatory types. You need to define a strongly typed schema before implementing anything. It's good for documentation, but it's real overhead at the start.

Query security. A client can send a deep, circular query that takes down your server:

{
  users {
    friends {
      friends {
        friends {
          friends { id }
        }
      }
    }
  }
}

You need to implement depth limiting, query complexity analysis, and rate limiting by complexity. REST has the same problem in theory, but in practice it's much harder to trigger accidentally.

Monitoring. With REST, you monitor endpoints. GET /users with high latency — you know where to look. With GraphQL, everything goes to /graphql. You need per-operation tracing (the operation name becomes the "endpoint" in your metrics) to understand what's slow. The same goes for tests: instead of testing routes, you test operations against the schema — the playbook for both styles is in how to test APIs automatically.

Errors. Historically, GraphQL servers answer HTTP 200 to almost everything, including when the query partially failed. A field can be null either because it doesn't exist or because the resolver threw an exception. You need to look at the errors field in the response:

{
  "data": { "user": null },
  "errors": [{ "message": "User not found", "path": ["user"] }]
}

This breaks the HTTP status code mental model that every developer already knows. The GraphQL over HTTP specification — still a working draft as of November 2026 — improves this for servers that respond with application/graphql-response+json: invalid JSON or a GraphQL document that fails to parse becomes 400, a query that fails validation becomes 422, a mutation over GET becomes 405. When execution produces both data and errors, the draft recommends a new status, 294 (partial success), instead of 200. In other words: request errors already get 4xx statuses on servers that follow the spec; partial execution errors still require you to read errors.

When GraphQL actually makes sense

I'm not against GraphQL. There are contexts where it's the right choice:

Multiple clients with different needs. If you have a mobile app, a web app, and an external partner, all consuming data in radically different formats, a GraphQL schema with flexible queries can be better than maintaining three versions of REST endpoints.

Product with highly dynamic UI. User-configurable dashboards, report builders, cases where the client genuinely doesn't know in advance which fields it will need. This is the use case where GraphQL's flexibility pays off.

Large team with independent frontends. When the iOS team, Android team, and web team work relatively independently and need to iterate quickly without depending on the backend for each new field.

Microservice federation. GraphQL Federation is genuinely powerful for exposing a unified data graph that lives in distinct services. If you have 10 microservices and need a unified interface for the frontend, Federation is an elegant solution.

When REST is enough (most cases)

If your API has well-defined resources with predictable CRUD operations, REST works. If you control the frontend, you can create endpoints specific to your needs. If the team has no GraphQL experience, the learning and operational cost doesn't pay off quickly.

See the post REST: principles and best practices for a practical guide on structuring a REST API that doesn't turn into a mess over time — before deciding you need GraphQL because your current REST API is poorly designed.

A poorly structured REST API isn't an argument for adopting GraphQL. It's an argument for better structuring the REST API.

Frequently asked questions

Is GraphQL faster than REST?

Not necessarily. On slow networks, a GraphQL query that replaces multiple requests can be more efficient. But on simple requests, REST with CDN caching will be faster than any GraphQL solution. Performance depends on the use case — there's no universal answer.

What are the downsides of GraphQL?

Harder HTTP caching (everything on one endpoint, usually via POST), N+1 per resolver that requires DataLoader, the need to limit query depth and complexity, and monitoring per operation instead of per route. None of them is a blocker, but all of them are work REST doesn't demand.

Can I use GraphQL and REST together in the same application?

Yes, and it's common. An architecture I've seen work well: GraphQL for the product interface (where flexibility matters), REST for external integrations and webhooks (where predictability and caching matter), and gRPC for internal service-to-service communication. There's no obligation to pick a single paradigm.

What about gRPC?

gRPC is the third option, and it shines somewhere else: internal service-to-service communication, with a Protocol Buffers contract, binary payloads and streaming over HTTP/2. In the browser it needs a proxy (gRPC-Web), so it rarely replaces REST or GraphQL in a public API. The common split is gRPC between services and REST or GraphQL at the edge.

REST or GraphQL: the right decision depends on the problem

My position after working with both in production: start with REST. If you're solving one of the specific problems GraphQL was designed for — multiple clients with divergent needs, highly dynamic UI, microservice federation — the investment is worth it. Otherwise, you're adding operational complexity to solve a problem you don't have.

Most APIs that become slow, hard to maintain, or inconsistent didn't get that way because of the paradigm. They got that way because of bad design decisions you can make just as badly in GraphQL or in REST.

If you go with REST, design error responses with the right status from day one — I check the semantics of each code (204 vs 200 with an empty body, 409 vs 422) in HTTP Status Codes before locking the contract.

RD
Author
Rafael Duarte
Backend developer with a background in fintech and B2B SaaS — worked on teams that scaled APIs from zero to millions of requests. Carries enough production scars to hold strong opinions on tools, patterns and architecture decisions. Not an academic: he read the UUID RFC when he had to choose between v4 and v7 for a write-heavy table.
View profile