All posts
Web Development · 9 min read · May 28, 2026

REST vs GraphQL: when to use each

Comparison of REST and GraphQL API styles

REST and GraphQL are the two most common approaches to designing web APIs today. Both are mature, widely supported, and capable of powering large systems. The question is rarely which one is better in the abstract - it is which one fits the problem in front of you. Understanding their core differences makes that choice straightforward.

How REST works

REST models your system as a set of resources, each addressed by a URL and manipulated with standard HTTP methods. A client fetches or modifies resources by hitting predictable endpoints.

http
GET    /users/42          # fetch one user
GET    /users/42/orders   # fetch that user's orders
POST   /orders            # create an order
DELETE /orders/99         # remove an order
REST maps HTTP methods onto resources at predictable URLs.

REST is simple, cacheable through standard HTTP mechanisms, and easy to reason about. Its main limitation is that the server decides the shape of each response, which can lead to over-fetching (receiving more data than you need) or under-fetching (needing several requests to assemble one screen).

How GraphQL works

GraphQL exposes a single endpoint and a typed schema. The client sends a query describing exactly the data it wants, and the server returns precisely that - no more, no less.

graphql
query {
  user(id: 42) {
    name
    orders {
      id
      total
    }
  }
}
One query fetches a user and their orders in a single round trip.

This solves over-fetching and under-fetching elegantly and lets the frontend evolve without new backend endpoints. The cost is added complexity: caching is harder than with REST, queries can become expensive if unbounded, and the server needs resolvers and schema management.

Side-by-side comparison

AspectRESTGraphQL
EndpointsMany, one per resourceUsually a single endpoint
Data shapeDefined by the serverDefined by the client query
Over/under-fetchingCommonLargely eliminated
CachingSimple (HTTP caching)Harder, needs tooling
Learning curveLowHigher
VersioningOften via URL versionsSchema evolves, fields deprecated

When to choose REST

  • Your API maps cleanly to resources with simple, predictable access patterns.
  • You rely heavily on HTTP caching, CDNs, or proxies.
  • You want the lowest possible barrier for consumers and tooling.
  • Public APIs where simplicity and broad compatibility matter most.

When to choose GraphQL

  • Clients need flexible, varied views of the same underlying data.
  • You are aggregating data from multiple services or sources behind one API.
  • Mobile clients benefit from minimizing payload size and round trips.
  • Frontend teams need to iterate quickly without waiting for new endpoints.

Conclusion

REST and GraphQL are not rivals so much as different tools. REST shines when your domain is resource-oriented and you want simplicity and strong caching. GraphQL shines when clients need flexibility and you want to avoid endpoint sprawl. Many real systems even use both - REST for simple public surfaces and GraphQL for rich, client-driven experiences. Choose based on your data access patterns, not on hype.

Contact

Let’s connect

Have a Liferay or Backend project you’d like to talk through? Fill in the form and I’ll get back to you.

Book Calendar