REST or GraphQL: choosing an API style

A row of small separate doors on the left and one single door with branching lines on the right, the branching lines in blue

A decision table for product and engineering leads, with the costs that rarely appear in framework comparisons.

In short

Choose a REST API when you expose stable resources to many consumers, want simple HTTP caching and need broad tool support. Choose GraphQL when several clients, such as web and mobile apps, need different slices of connected data and the frontend team should shape its own queries. Many products use both: REST for partners and integrations, GraphQL behind their own apps.

Choosing between a REST API and GraphQL is one of the first API design decisions in a new product, and one of the hardest to reverse once clients depend on it. This comparison is written by Devies, a Gothenburg-based product and engineering consultancy, for CTOs, architects and product leads who need to decide how their systems and apps should exchange data. It explains both styles, compares them side by side and lists the signals that should tip the choice.

What is the difference between REST and GraphQL?

REST is an architectural style where clients work with resources at separate URLs using standard HTTP methods, while GraphQL is a query language where clients send one query to a single endpoint and get back exactly the fields they asked for. Both usually run over HTTP and JSON; they differ in who decides the shape of the response.

  • REST (Representational State Transfer) was defined by Roy Fielding in his 2000 doctoral dissertation as a set of constraints: client-server, stateless communication, cacheable responses, a uniform interface, a layered system and optional code on demand. In practice, a REST API exposes resources such as /orders/123, uses GET, POST, PUT and DELETE, and is often described with an OpenAPI specification.
  • GraphQL is a query language and runtime for APIs, originally developed at Facebook and now governed by the GraphQL Foundation. The server publishes a typed schema; the client writes a query that names the fields it needs, across related objects, and the server returns that shape.
  • API design is the work of deciding what an API exposes, how it is named, versioned, secured and documented. It matters more than the style you choose.
A phone sending three arrows to three boxes on one side, and one arrow to a single box returning a combined shape on the other

A simple example shows the difference. To show an order with its customer and products, a REST client might call three endpoints, or one endpoint designed for that screen. A GraphQL client sends one query that asks for the order, the customer's name and each product's title, and gets nothing else.

REST API or GraphQL: a decision table

The right choice depends on who consumes the API, how varied their data needs are, how important HTTP caching is and what your team already knows. Use the table to compare the two against your situation.

Criterion

REST

GraphQL

Who shapes the response

REST

Server, per endpoint

GraphQL

Client, per query

Endpoints

REST

Many, one per resource or use case

GraphQL

Usually one

Over-fetching and under-fetching

REST

Common unless endpoints are tailored

GraphQL

Largely avoided

HTTP caching and CDNs

REST

Works out of the box with GET

GraphQL

Needs GET requests or persisted queries

Versioning

REST

Often explicit versions such as /v2

GraphQL

Schema evolves by adding and deprecating fields

Tooling and familiarity

REST

Universal, every platform and partner knows it

GraphQL

Strong ecosystem, but fewer partners expect it

Performance risks

REST

Many round trips for complex screens

GraphQL

Expensive nested queries, the N+1 problem

Security work

REST

Per-endpoint authorisation, rate limits

GraphQL

Field-level authorisation, query depth and cost limits

Best fit

REST

Public and partner APIs, integrations, simple CRUD

GraphQL

Own web and mobile apps with varied, connected data

Choose REST when

  • external partners, customers or integration platforms will consume the API, and they expect standard HTTP behaviour;
  • responses can be cached by browsers, proxies or a CDN, which saves cost and speeds up reads;
  • the resources are fairly stable and each client needs roughly the same data;
  • you want the simplest possible operations, monitoring and security model.

Choose GraphQL when

  • several clients, such as a web app, an iOS app and an Android app, need different subsets of the same data;
  • screens combine data from many related objects, and round trips make the app slow;
  • the frontend team should be able to change what it fetches without waiting for backend changes;
  • you are putting one coherent API in front of several backend services.

What does each style cost to run well?

Each API style moves complexity to a different place: REST pushes it into endpoint design and the number of calls, while GraphQL pushes it into the server, where queries must be controlled. Neither is free to operate at scale.

For GraphQL, the official guidance on performance names three issues to plan for. HTTP caching needs GET requests, which hit URL length limits for large queries, so many teams use persisted queries that send a hash instead of the full query. The N+1 problem, where one request fans out into many database calls, is usually solved by batching with a tool such as DataLoader. And because clients can write very expensive queries, by accident or on purpose, servers need demand control such as pagination, depth and breadth limits and query cost analysis.

For a REST API, the typical costs are different. Teams end up building screen-specific endpoints to avoid many round trips, version numbers multiply, and documentation drifts unless it is generated from an OpenAPI description. None of this is hard, but it needs discipline.

Devies saw how much the API layer matters to the user experience when modernising iHelm for Cetasol, a marine company. According to the case, a new data API built in Python FastAPI fetches data asynchronously from an AWS data lake to reduce the risk of timeouts, and includes data usage tracking and rate limiting.

Can you combine REST and GraphQL?

Yes, and many mature products do: a REST API for external partners and system integrations, and a GraphQL layer that serves the company's own apps. The two styles solve different problems and can sit over the same services.

A common pattern is a GraphQL gateway in front of internal services, which may themselves be REST. The apps get one flexible API, while partners and integration tools get stable, cacheable REST endpoints. This fits well with a service architecture; our comparison of microservices and a monolith covers when splitting the backend is worth it. For connecting ERP, CRM and finance systems, REST and event-based integration remain the norm, as our guide to system integration explains.

Whatever you choose, a few API design rules apply to both:

  1. Design from the consumer's needs, not from the database tables.
  2. Write the contract first, as an OpenAPI description or a GraphQL schema, and review it before building.
  3. Plan for change: deprecate before removing, and communicate changes to every consumer.
  4. Secure every field and endpoint, with authorisation checked on the server, not only in the app.
  5. Measure real usage, so you know which endpoints or fields can be retired.

The API style also shapes who you need on the team. GraphQL gives frontend developers more control, while REST design leans on backend experience; see our comparison of frontend, backend and full-stack developers.

Devies

Want a second opinion?

Devies, a Gothenburg-based product and engineering consultancy, works on questions like this with Nordic product and IT teams. Tell us where you are and we will suggest a sensible first step.

Talk to Devies

Frequently asked questions

Is GraphQL replacing REST?

No. GraphQL has become a common choice for APIs that serve a company's own web and mobile apps, but REST remains the default for public APIs, partner integrations and most system-to-system communication. The two are complementary: many companies run GraphQL for their apps and REST for everything that leaves the organisation, sometimes over the same backend services.

Is GraphQL faster than a REST API?

Not automatically. GraphQL can make apps faster by replacing several round trips with one query and by returning only the fields needed. But a badly controlled GraphQL server can be slower, because nested queries can trigger many database calls. A well-designed REST API with caching often serves simple reads faster. Performance depends on design, caching and data access more than on the style.

Is GraphQL less secure than REST?

GraphQL is not less secure by nature, but it needs different controls. Because clients can compose their own queries, servers must enforce authorisation for each field, limit query depth and complexity, and paginate lists. REST APIs need authorisation per endpoint and rate limiting. In both cases, most security problems come from missing server-side authorisation rather than from the API style.

Which API style is easier for partners to integrate with?

REST is usually easier for partners, because almost every platform, integration tool and developer already knows how to call HTTP endpoints, and an OpenAPI description can generate client code and documentation. GraphQL requires partners to learn the schema and query language, which is worthwhile for rich data access but adds friction for simple integrations such as sending orders or reading statuses.

Sources

Here’s more

Join Our Newsletter

We handle your data according to our privacy policy.

Shopping Cart

We use cookies

We use cookies to improve your experience on this website. You may choose which types of cookies to allow and change your preferences at any time. Disabling cookies may impact your experience on this website. You can learn more by viewing our Cookie Policy.

Check out

Contact Form text

We will contact you text

We handle your data according to our privacy policy.