Working with GraphQL?

GraphQL API slow, leaky or drifting? We fix it.

Most GraphQL APIs that reach us look fine in the playground and fall over under real traffic, usually because a resolver is firing hundreds of times per request. We find the resolvers that are actually doing the damage and fix them, without redesigning the whole schema.

  • Since 2015Fixing technology
  • FreeEstimates
  • US teamReal engineers

apollo.log

still failing

What it is

GraphQL at a glance

GraphQL is a query language and runtime for APIs, developed internally at Facebook from 2012 and released publicly in 2015. It is now stewarded by the GraphQL Foundation under a neutral open specification.

Clients send a query written against a typed schema, and server resolvers produce the data for each field. Transports are usually HTTP POST for normal queries and WebSockets through graphql-ws for subscriptions. Implementations exist for every major language, including Apollo Server, Yoga, Hot Chocolate, Graphene, Juniper and gqlgen.

Common architectures are a single schema per service, Apollo Federation for joining several services into one graph, and tools like Hasura or Postgraphile that generate a schema straight from a database.

Type
API query language and runtime
First released
2015 as a public specification
License
MIT for reference implementations, open standard for the spec
Maintained by
The GraphQL Foundation
Typically used for
Mobile and web app APIs, aggregating multiple back-end services, CMS content APIs, internal data gateways

The honest version

GraphQL pros and cons

No technology is all upside. This is where GraphQL earns its place and where it tends to cause trouble.

Where GraphQL is strong

  • The schema is a contractA typed schema both the client and server agree on, so breaking changes show up at build time rather than in production support tickets.
  • Clients ask for what they needA single endpoint returns exactly the fields the caller requested, which cuts the number of round trips and the size of each response.
  • Tooling is unusually goodGraphiQL, Apollo Studio, Hasura and Postgraphile give you a usable API console, metrics and generated code almost for free.
  • Federation across servicesApollo Federation lets several teams own their own subgraphs while clients see one unified graph, which fits larger engineering groups well.
  • Real-time without a second stackSubscriptions over WebSockets let the same schema serve live updates, which is a fair fit for dashboards and mobile apps.
  • Code generation from the schemaTyped clients, hooks and server stubs can be generated directly from the schema, which keeps the two sides from drifting apart.

Where GraphQL bites

  • N+1 queries hide inside resolversA field resolver that looks innocent can fire once per parent row and quietly hammer the database. Without DataLoader or batched SQL it is almost guaranteed to happen.
  • Authorisation is per resolverThere is no single route to protect, so object-level permissions have to be checked on every field that returns sensitive data. It is very easy to miss one.
  • HTTP caching does not really applyBecause every query hits the same POST endpoint, normal CDN and browser caching is awkward, and teams end up building response caching inside the server.
  • Introspection leaks your APILeft on in production, introspection hands an attacker a full map of your schema, including fields you forgot were still there.
  • Abuse needs real limitsWithout query complexity and depth limits, a single deeply nested query can tie up the server for seconds at a time.
  • The ecosystem keeps shiftingApollo Server 3 to 4, the move from subscriptions-transport-ws to graphql-ws, and federation v1 to v2 have all broken middleware and plugins that previously worked.
  • Schema drift between servicesWhen several teams publish their own subgraphs, names and types diverge over time unless somebody is actively curating the combined schema.

Sound familiar?

Common GraphQL problems we fix

The GraphQL problems that bring people to us, and what you have once each one is fixed.

N+1 query: Author.books resolver fired 212 times

The API is slow under real load

A nested resolver firing once per parent row, usually because DataLoader is missing or the query is not batched at the database.

Batched with DataLoader, measured

GraphQLError: field returned null, should be non-null

Resolvers return data they shouldn't

Authorisation lives on each resolver, and one or two fields were never checked, so users see records that belong to someone else.

Object-level checks on every field

Federation: subgraph 'users' timed out

The federated graph falls over

One subgraph is slow or down and the gateway waits on it, so every client request stalls even for fields it does not need.

Timeouts, retries and clean degradation

Complexity limit exceeded: 142 (limit 100)

A single query can take the server down

No depth or complexity limits, so a nested query from one client ties up CPU and database connections for everyone else.

Depth and cost limits in place

Introspection enabled in production

The full schema is exposed to the internet

Introspection left on in production, sometimes together with GraphiQL, hands attackers a complete map of the API.

Introspection off, playground gated

Apollo Server 3 -> 4 breaking changes

The upgrade broke middleware

The plugin and cache APIs changed between major versions, and custom auth or logging plugins stopped loading after the bump.

Ported to the new plugin API

schema diff: 41 fields changed

Services have drifted apart

Several teams publish their own subgraphs and nobody owns the combined view, so field names and types no longer line up.

One curated, reviewed schema

What we do

GraphQL help, from rescue to upkeep

Call us for one slow query, or hand us the whole graph.

Rescue
APIs timing out, resolvers crashing, or a federated gateway stuck behind a slow subgraph. We get it responding first and find the cause second.
Performance
DataLoader, batched SQL, persisted queries and sensible caching, measured on real traffic rather than on the playground.
Security and authorisation
Object-level permissions on every resolver, introspection and playground locked down, depth and complexity limits enforced.
Federation
Setting up or fixing Apollo Federation across several services, with contract tests so one subgraph cannot break the others.
Upgrades
Apollo Server major version bumps, moving off subscriptions-transport-ws, and federation v1 to v2 migrations rehearsed first.
Managed Tech
Monitoring, schema review, and a team to call when a resolver starts misbehaving at three in the morning.

How it works

From first message to fixed

  1. Look Free estimate

    Tell us what's going wrong. We look at it, then tell you plainly what's wrong and what it will cost.

  2. Fix

    We fix the cause, not the symptom. If something is down, getting it back up comes first.

  3. Harden

    Backups, monitoring, updates and access, so the same problem can't quietly come back.

  4. Hand back or stay on

    You get a plain-language write-up. Or we stay on for hosting, upkeep and new work.

Often found together

Running GraphQL alongside something else?

We work on the whole stack, so the problem can be wherever it actually is.

Questions

GraphQL questions

Something else? Call+1 737 727 7327

Can you take over a GraphQL API from a previous developer?

Yes. We read the schema, walk through the resolvers, work out which fields are actually used by clients, and document what is there before changing anything. In most cases the API can be stabilised in place without a rewrite.

Why are our GraphQL queries slow with N+1 patterns?

A field resolver that looks up related records fires once for every parent row, so a query that returns fifty authors runs the books lookup fifty times. The fix is usually DataLoader for batching inside the request, or pushing the join down into a single database query.

How do we add proper authentication and authorization to GraphQL resolvers?

Authentication belongs in middleware that runs before any resolver and puts the user on the context. Authorisation belongs on each resolver or type, often with directives or a shared helper, so object-level permissions are checked for every field that returns sensitive data.

Should we use GraphQL or stick with REST for our API?

If several clients need different shapes of the same data, or a mobile app wants fewer round trips, GraphQL earns its keep. For simple server-to-server APIs with stable payloads, REST is often less work to run.

Can you set up Apollo Federation across our microservices?

Yes. We design the subgraph boundaries, set up the gateway with timeouts and retries, add contract tests so one team cannot break another, and put schema review in place so the combined graph does not drift.

How much does GraphQL help cost?

Estimates are free. Describe what the API is doing and you get a price before any work begins.

Free estimate

GraphQL giving you trouble?

Tell us what you're running and what's going wrong. A person reads it and comes back with an estimate.

  • No charge to find out what it will take
  • If it's urgent, say so

Replies come from a person. By sending, you authorize us to email you back. No marketing.