Dark navy diagram of several REST resources on the left and one GraphQL query selecting fields on the right
REST vs GraphQLGraphQLREST APIAPI designsoftware engineeringbackend

REST vs GraphQL: How to Choose an API

REST vs GraphQL for product APIs: REST when the resource and the cache are obvious, GraphQL when one screen needs many shapes, and a hybrid when partners and the product disagree.

Swati ChaudharyFounder, Myrafy

REST vs GraphQL is usually asked one sprint before the mobile app, the web app, and a partner integration all want different shapes of the same order.

REST models resources and uses HTTP the way caches, gateways, and status codes already understand. GraphQL models a query: the client names the fields it wants, often across related objects, in one request. Neither one is the modern choice. The wrong one is the one that fights the way your clients actually read data.

This is a choice about contracts, caching, and who feels pain when the schema changes. It is not a personality test for the backend team.

REST vs GraphQL at a Glance

REST as separate resource calls beside a single GraphQL query that picks fields from related objects
REST is a resource contract. GraphQL is a field contract.

REST GraphQL
Unit A resource and an HTTP method A query, mutation, or subscription against a schema
Client control The server decides the body The client names the fields
Caching URL, method, and headers. CDNs already know how You design cache keys. POST-by-default fools a lot of proxies
Versioning /v2 or careful evolution of fields The schema evolves; old fields stay until you deprecate them
Over-fetching Common. One endpoint returns the kitchen sink Rare, if the client is disciplined
Under-fetching Common. A screen calls five endpoints Rare. One query can span types
Public partners Easy to document, mock, and limit per route Possible, and easier to abuse if limits are naive
Failure HTTP status means something HTTP 200 with an errors array is normal. Clients must read it

REST answers: "Here is the order. Here is the invoice. Here is the customer." GraphQL answers: "Give me these six fields of the order, the customer's name, and the latest shipment status."

Choose REST When the Resource Is the Product

REST is the default for a reason. HTTP already gives you verbs, status codes, caching, and a story your gateway understands.

Choose REST when

  • Partners, webhooks, and other servers are the main clients
  • Each screen maps cleanly to one or two resources
  • You want a CDN or a browser to cache GET responses
  • You need obvious rate limits per route. See API rate limiting
  • The team is small and the domain is still moving

A public integration should look boring: a resource, an idempotency key on writes, a status you can alert on, and a page of docs a stranger can follow. GraphQL can do this. REST makes the boring path the default.

REST gets expensive when a single screen needs an order, a customer, three line items, and a shipment, and you either ship a custom "screen endpoint" or let the client fan out. Custom screen endpoints are fine. They are also how a REST API quietly becomes a pile of one-off DTOs. Name them on purpose, or stop pretending every call is a pure resource.

Choose GraphQL When the Screen Is the Product

GraphQL earns its place when many clients need many shapes, and you are tired of shipping a new endpoint for each one.

Choose GraphQL when

  • Web, mobile, and an internal admin disagree on fields
  • The graph is real: orders, accounts, documents, people, and the links between them
  • You will invest in a schema, a deprecation habit, and query cost limits
  • You already have a BFF (backend for frontend) problem and you want the schema to be that BFF

Do not choose GraphQL when

  • You have one client and ten resources
  • Nobody will own the schema
  • You expect HTTP status codes alone to explain failures
  • You need file upload, or a partner who will only call a webhook. Keep those on HTTP. Webhooks you can operate stay REST-shaped even if the product API is a graph

The hidden work is authorization per field, query depth limits, and a persisted-query or complexity budget so one client cannot ask for the entire graph. "We will add limits later" is how a GraphQL endpoint becomes an outage.

A Hybrid Is a Normal Outcome

A resource document, a field graph, and a data store on one line
One domain underneath both contracts

Most products we see after the first year are not pure.

Surface Contract
Partner API, webhooks, billing callbacks REST, versioned, rate-limited per key
Web and mobile product GraphQL or a small BFF, if the screens diverge
Service-to-service inside your system Whatever the team will actually operate. Often plain HTTP or a queue, not a second graph
File upload HTTP. Do not push bytes through a query string

The mistake is two public contracts that drift. If both exist, generate or review them from one domain model, and write down which one is allowed to change first.

What Breaks in Production

N+1 queries. GraphQL resolvers that each hit the database will melt a screen that "only" asked for fifty orders and their customers. Batch the loads or the graph is a demo.

Cache confusion. A GraphQL POST that is actually a read will not be cached by a CDN. If the read is hot, persist the query and cache that document, or keep the hot read on GET.

Authorization in the resolver by accident. A field that forgets the tenant check leaks across customers. Test the schema with two tenants, not with one happy admin.

Version sprawl on REST. /v3 that still calls /v1 tables, with no owner, is not a strategy. Evolve by adding fields and keeping old ones until a date you publish.

Error semantics. Clients that only check HTTP 200 will treat a partial GraphQL failure as success. Agree on the error shape before the first mobile release.

For live updates, do not jump to GraphQL subscriptions by reflex. WebSockets vs server-sent events is an independent choice. A subscription is a transport problem wearing a schema.

A Short Way to Decide

  1. List the clients for the next two quarters: web, mobile, partner, internal, webhook.
  2. List the screens or calls that need more than one resource.
  3. If partners and webhooks dominate, start with REST.
  4. If three clients each need a different slice of the same graph, budget a GraphQL schema and limits, or a BFF you are willing to maintain.
  5. Write the auth rule next to the contract. Resource-level for REST. Field-level for GraphQL.
  6. Put the contract in the SOW: what is public, what is internal, and who signs a change. See what belongs in a software SOW.

FAQ

Is GraphQL faster? Sometimes, because one round trip replaces five. Sometimes it is slower, because one query does the work of five and the database was not ready. Measure the screen, not the slogan.

Can I migrate later? Yes. Keep the domain model clean and put a new contract in front of it. A rewrite of every client at once is the expensive version. Strangle one screen at a time.

Do I need both on day one? No. One public contract. Add the second when a real client cannot be served without a custom pile of endpoints, or without a graph.

Where do rate limits live? On REST, per route and per key. On GraphQL, per query cost, depth, and key. A single "100 requests a minute" cap is too crude for a graph and too vague for a partner.

The Bottom Line

REST vs GraphQL is a client problem. Use REST when resources, caches, and partners should stay obvious. Use GraphQL when many screens need many shapes and you will pay for schema discipline. A hybrid is healthy when each contract has an owner. Two undocumented styles is not a hybrid. It is drift.


Designing the API in front of a product, not a framework debate? See software development or contact us for an estimate.

Share
𝕏in
Contact us