Skip to content
Web Design & Development

GraphQL APIs: What Actually Works

A query language for APIs that lets clients request exactly the data they need in a single request, defined by a typed schema.

MediaScaleUp Editorial Team 2 min read 13 views
GraphQL APIs: What Actually Works

At a glance

  • Schema types and fields define what can be queried
  • Single endpoint queries are usually sent to one URL
  • Over-fetching clients request only the fields they need
  • Security query depth and complexity limits prevent abuse

Why it matters

Why it matters: GraphQL can simplify front-end data fetching, but it introduces its own performance, caching and security considerations.

Best practice

  • Design the schema around client needs
  • Limit query depth and complexity
  • Batch database calls to avoid N+1 problems
  • Apply authorization per field where needed
  • Monitor slow queries
What to do and what to avoid with GraphQL APIs, side by side
Good practice against the usual mistakes, from the sources listed below.

Common pitfalls

Watch out for:

  • Exposing the whole database as a schema
  • Unlimited query complexity
  • Ignoring caching strategy
  • Authorization only at the endpoint level

When to call in a specialist

Bottom line Bring in help when choosing between REST and GraphQL or when GraphQL APIs slow down.

Where this comes from

  • OWASP — GraphQL Cheat Sheet
  • OWASP — Denial of Service Cheat Sheet

The figures and practices above come from the sources listed.

Working on something like this?

We take on Web Design & Development work for teams who want it done once, properly. Tell us what you are building and we will tell you honestly whether we are the right studio for it. Start a project.

Where to go next

Spotted something wrong? Report an error on this page. We correct on the page and say what changed.

All services

The work behind this article, and what it costs.

MediaScaleUp Editorial Team

Articles here are researched, written and checked by the MediaScaleUp studio team before they are published, and dated when they are reviewed.

Keep reading

More in Web Design & Development