Backend & Node.js · APIs, data and failure

How do you choose between REST and GraphQL?

Mediumrestgraphqlapi designUpdated Oct 2026
Quiz this track

Short answer

REST exposes resources over HTTP and is simple to cache and operate. GraphQL lets clients request exactly the fields they need through one endpoint, which helps varied clients but adds query complexity, caching and N+1 challenges.

The decision is about client needs and operational cost, not about which is newer. REST maps well to resource-oriented CRUD, public APIs and HTTP caching. GraphQL is useful when many clients need different shapes of the same data and over-fetching or multiple round trips are a real problem.

graphql
query OrderSummary {
  user(id: "42") {
    name
    orders(first: 5) {
      id
      total
    }
  }
}
One GraphQL request can fetch a nested shape that might take several REST calls.

Trade-offs

  • REST uses HTTP status codes and URLs as a natural cache key
  • GraphQL usually returns 200 with an errors array, so clients need explicit error handling
  • GraphQL resolvers can cause N+1 queries without batching and caching
  • REST is easier to rate limit per endpoint; GraphQL needs query cost analysis
  • GraphQL schemas are strongly typed and great for tooling, but schema evolution still needs discipline
  • File uploads, streaming and long-running operations are usually simpler in REST

A common production pattern is REST for public integrations and internal CRUD, plus GraphQL for a product UI with many screens and nested data. The reverse also works. What matters is that the team can operate the choice: observability, authorization per field, pagination rules, depth limits and persisted queries all need design.

Do not adopt GraphQL only to avoid versioning. It shifts the problem to schema evolution and client coordination; breaking changes still exist.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1How does caching differ between REST and GraphQL?
  2. 2What causes N+1 queries in GraphQL?
  3. 3How do you rate limit a GraphQL endpoint?
  4. 4When is REST the better choice?

Say it in the interview

I choose REST when the domain maps cleanly to resources and HTTP caching, status codes and per-endpoint rate limits matter. I choose GraphQL when clients need different nested shapes and over-fetching or round trips are a real cost. GraphQL moves complexity into resolvers, query cost limits and authorization rather than removing it. In practice, many systems use both for different consumers.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Backend & Node.js mock interview and get scored feedback on depth, clarity and confidence.