REST or GraphQL?

GraphQL solves a real problem that most products do not have yet. That is the whole decision, and it is usually clearer than the debate suggests.

REST or GraphQL? — Troiana insight cover

In short

Choose REST for most new products: it is simpler, caches at the HTTP layer for free, and every tool understands it. Choose GraphQL when many different clients need different shapes of the same data, when over-fetching across a slow network is a measured problem, or when a large front-end team is blocked waiting on back-end endpoints. The deciding factor is client diversity, not API elegance.

What each one actually is

REST exposes resources at URLs and uses HTTP verbs against them. The server decides what a response contains.

GraphQL exposes a single endpoint and a schema. The client sends a query describing exactly the fields it wants, and receives that shape back.

The difference that matters is who decides the shape of the response. Everything else follows from that.

The problem GraphQL solves

GraphQL came out of a specific situation: many client applications — web, iOS, Android, each at different versions — all needing different subsets of the same data, from a back-end team that could not ship a bespoke endpoint for each.

Without it you get two familiar failures. Over-fetching: the mobile app downloads a 40-field object to display two of them. Under-fetching: rendering one screen takes four sequential round trips because each response lacks something the next needs.

On a slow mobile connection, both are measurable. If that is your situation, GraphQL addresses it directly and well.

What GraphQL costs

The costs are real and land on the team operating it.

HTTP caching mostly stops working. This is the big one. REST responses cache at the CDN, in the browser, and in proxies for free, because a GET to a URL is cacheable by definition. GraphQL typically POSTs to one endpoint, so all of that infrastructure becomes inapplicable and you rebuild caching inside your application.

Query cost becomes an attack surface. A client can request a deeply nested query that is trivial to write and expensive to serve. Production GraphQL needs depth limiting, complexity scoring, and often persisted queries — none of which you need with fixed endpoints.

The N+1 problem is structural. Resolving nested fields naively issues a database query per item. Batching layers exist and work, but you must know about the problem to avoid it, and it recurs each time the schema grows.

Observability is harder. With REST, a slow endpoint appears in your logs as a slow URL. With GraphQL, everything is one URL, and you need tooling that understands operations to know what is actually slow.

Error handling is unfamiliar. GraphQL commonly returns HTTP 200 with errors in the body, including partial successes. Every consumer and monitor has to understand that convention.

When REST is the right answer

For most new products, and specifically when:

  • You have one main client. A web front end you also own gets no benefit from client-specified shapes; you can simply build the endpoint the screen needs.
  • Caching matters. Public, read-heavy data is exactly where free HTTP caching earns its keep.
  • The team is small. REST has less to learn, less to operate, and better default tooling.
  • Third parties will integrate. Most partners expect REST, and it needs no client library to try.

REST also degrades gracefully: an endpoint returning slightly too much data is a minor inefficiency, not an architectural problem.

When GraphQL earns its complexity

  • Many diverse clients, especially mobile apps at versions you cannot force-update.
  • Measured over-fetching on constrained networks — measured, not assumed.
  • A large front-end team blocked on back-end endpoints. This is an organisational benefit and a legitimate one: the schema becomes the contract, and front-end work stops queuing behind endpoint delivery.
  • Genuinely graph-shaped data where clients need to traverse relationships in varied ways.

Notice that three of those four are about team and client structure rather than data. That is the honest pattern: GraphQL is often an organisational solution.

The middle paths

The choice is not binary.

REST with sparse fieldsets — letting clients pass a fields parameter — solves much of the over-fetching problem for a fraction of the cost.

REST with purpose-built endpoints — an endpoint per screen, returning exactly what it needs — is unfashionable and extremely effective when you own both sides.

GraphQL as a gateway over REST services keeps the client benefit while leaving the services simple.

tRPC or typed RPC gives end-to-end type safety without GraphQL's operational cost, when client and server share a language and codebase.

The straight recommendation

Start with REST. For most products it is simpler to build, cheaper to run, easier to cache, and better understood by everyone who will touch it. If over-fetching becomes a measured problem, add sparse fieldsets or a purpose-built endpoint.

Move to GraphQL when you can point at the pain — several client types diverging, a front-end team blocked on endpoints, real bandwidth problems on real devices. Those are good reasons, and when they apply, the cost is worth paying.

What is not a good reason is that GraphQL is more modern. That is the reasoning behind most of the migrations teams later regret, and it belongs in the same bucket as every other boring technology argument.

If you are making this call on a new product and want a second opinion before committing, book a call.

Common questions

Should I use REST or GraphQL for a new project?

REST, in most cases. It is simpler to build and operate, caches at the HTTP layer for free, and every tool and partner already understands it. Move to GraphQL when you can point at a specific problem it solves — several diverging client types, measured over-fetching on constrained networks, or a front-end team blocked waiting on endpoints.

What is the biggest downside of GraphQL?

Losing free HTTP caching. REST responses cache in the browser, at the CDN, and in proxies because a GET to a URL is cacheable by definition. GraphQL usually POSTs to a single endpoint, so that infrastructure no longer applies and you rebuild caching inside your application.

Is GraphQL faster than REST?

Not inherently. It can reduce round trips and payload size, which matters on slow mobile networks, but it also loses HTTP caching and introduces N+1 query risk that can make things slower if unaddressed. The performance answer depends on your clients and network, so measure before assuming.

Can you use REST and GraphQL together?

Yes, and it is a common middle path. A GraphQL gateway over REST services gives clients flexible queries while the underlying services stay simple. You can also solve much of the over-fetching problem within REST using sparse fieldsets or endpoints purpose-built per screen.

Why do teams regret migrating to GraphQL?

Usually because the migration was motivated by GraphQL being more modern rather than by a specific problem. The costs — rebuilt caching, query complexity limits, N+1 handling, harder observability, unfamiliar error semantics — all land on the team operating it, and they are only worth paying when there is real pain being solved.

Have something worth building right?