Skip to main content

Technical Decisions

GraphQL

GraphQL lets a client ask for exactly the data it needs in one request. Elegant for complex clients, and additional machinery for a straightforward application.

Definition

GraphQL is a way of building an API where the client specifies exactly what data it wants, in one request, and receives precisely that.

What It Actually Means

The contrast is with the conventional approach, where the server defines fixed responses at fixed addresses. Fetching a customer, their orders and each order’s items might mean three or more separate requests, several of which return more data than was needed.

GraphQL replaces that with a single request describing the whole shape required.

The Problems It Genuinely Solves

Too many requests. Particularly on mobile, where each round trip costs latency. Collapsing several into one is a real improvement.

Too much data. A conventional endpoint returns everything it returns. A mobile client needing three fields receives forty. On constrained connections that matters.

Different clients needing different things. A web app, a mobile app and a partner integration all wanting different shapes. Without GraphQL, either everyone gets the largest response or the API accumulates variants.

Changing needs. Front-end changes that would otherwise require a back-end change and a release can often be made client-side.

Those are real benefits, and they are concentrated in a particular situation: several sophisticated clients, evolving quickly, over networks where request count matters.

What It Costs

More machinery. A schema, resolvers, and a query layer that has to be maintained.

Harder caching. Conventional APIs cache well because a given address returns a given result. Arbitrary queries do not cache the same way, which removes a straightforward performance tool.

Performance traps. A naive implementation can turn one query into hundreds of database calls without anybody noticing until load rises. Avoiding it requires deliberate work that is easy to skip.

Security surface. Clients can request deeply nested data, and a query designed to be expensive can be used to exhaust a server. Depth and complexity limits are required rather than optional.

Less familiarity. More developers know conventional APIs, which matters for hiring and handover.

The Honest Test

Do you have several different clients with different data needs?

If yes, GraphQL earns its complexity.

If you have one web application talking to one back end, a conventional API is simpler, better understood, easier to cache and easier to secure. Adding GraphQL there is machinery in exchange for flexibility nobody needs.

What To Ask

  • How many clients consume this, and do their needs differ? The question that decides it.
  • How are expensive queries prevented? There should be depth and complexity limits.
  • How is the repeated-query problem handled? A real answer involves batching. No answer means a performance problem waiting for traffic.
  • How do we cache? Harder here, and it needs a plan rather than an assumption.
  • Who else could maintain this? Relevant for handover.

The Practical Position

GraphQL is a good answer to a specific problem, and the problem is having many clients with divergent needs.

For a single application, or an integration between two systems, a straightforward API remains the sensible choice, and choosing otherwise usually reflects what is interesting to build rather than what the situation requires.

More terms are in the glossary.

Portrait of Alexander De Sousa, founder of Digital Royalty
Founder-led
“I’ve put everything I know into how this company works — the standards, the method, the care on every project. It runs through the whole team, and I hold us all to it.”

Alexander De Sousa · Founder LinkedIn

Featured on BBC Radio Solent

Get started

Tell us what you need

A few quick questions, then a straight answer from a real person — usually within a few hours.

What happens next

  1. 1 We reply A real person reads your answers and gets back to you, usually within a few hours.
  2. 2 Questions or a short call If anything isn't clear, we ask by email or book a short call. Before any call we audit your website and make the quick fixes it finds, free.
  3. 3 Your fixed quote A clear, fixed price in writing, within 48 hours of any call. There is no obligation to go ahead.

Tell us what you're working on

Whether it's a new site, a platform, or a process that shouldn't be manual any more — we'll tell you honestly if we can help.