API Design: REST vs GraphQL — When to Choose Which
A pragmatic guide to choosing between REST and GraphQL for your API. Covers performance, developer experience, caching, and real-world trade-offs.
Author
Robert Baker
Published
Read time
3 min read
REST and GraphQL are both mature, battle-tested approaches to API design. The right choice depends on your specific use case, team, and constraints.
REST: The Default Choice
REST is simple, well-understood, and works with every HTTP client ever made. For most applications, it’s the right starting point.
REST Strengths
- Caching is trivial. HTTP caching, CDN caching, browser caching — they all work out of the box with GET requests.
- Tooling is universal. Every language, every framework, every monitoring tool understands REST.
- Easy to reason about. One endpoint, one resource, predictable behavior.
// Clean REST endpoint
GET /api/projects // List projects
GET /api/projects/:id // Get one project
POST /api/projects // Create project
PUT /api/projects/:id // Update project
DELETE /api/projects/:id // Delete project
REST Weaknesses
- Over-fetching. The
/api/usersendpoint returns everything about a user, even if you only need the name. - Under-fetching. Displaying a dashboard might require 5 separate API calls.
- Versioning overhead. API changes often require
/v2/endpoints or breaking changes.
GraphQL: When You Need Flexibility
GraphQL solves the fetching problem by letting the client specify exactly what data it needs.
GraphQL Strengths
- Precise data fetching. Request only the fields you need.
- Single request. Fetch related data across multiple resources in one query.
- Strongly typed schema. The schema is self-documenting and enables powerful tooling.
# One query, exact data needed
query DashboardData {
currentUser {
name
avatar
}
projects(limit: 5) {
id
title
status
lastActivity
}
notifications(unread: true) {
id
message
}
}
GraphQL Weaknesses
- Caching is hard. No HTTP-level caching for POST-based queries. You need a client-side cache (Apollo, urql).
- Complexity overhead. Schema definition, resolvers, dataloaders — there’s more code to maintain.
- N+1 query problem. Without dataloaders, nested queries can hammer your database.
- File uploads are awkward. GraphQL wasn’t designed for multipart uploads.
Decision Framework
Choose REST When
- Your API is resource-oriented (CRUD operations)
- Caching is important for performance
- Your team is small and wants simplicity
- You’re building a public API for third-party developers
- Your clients are diverse (mobile, web, CLI, IoT)
Choose GraphQL When
- Your frontend needs vary significantly across views
- You have deeply nested or related data
- Multiple frontend teams consume the same API
- You’re building a complex dashboard with many data requirements
- You want a strongly typed contract between frontend and backend
The Pragmatic Middle Ground
Many successful applications use both:
- REST for simple CRUD — user management, file uploads, webhooks
- GraphQL for complex reads — dashboards, search, data exploration
You can also get most of GraphQL’s benefits in REST by supporting sparse fieldsets and compound documents (JSON:API style), or by using tRPC for type-safe APIs without the GraphQL overhead.
Our Take
Start with REST. Move specific endpoints to GraphQL only when the over-fetching or under-fetching pain becomes real. Premature GraphQL adoption is one of the most common sources of unnecessary complexity in modern web applications.
Share this article
Get expert development help fast
Our engineering team turns complex ideas into production-ready software tailored to your business.
Post essentials
- Published on June 20, 2025 with real-world implementation examples.
- Designed for fast implementation with 3 min read worth of guidance.
- Validated by Robert Baker team.
Expert contributor
Robert Baker
Robert Baker cares deeply about reliable, well-architected solutions. Every guide we publish is battle-tested in real projects before it reaches the blog.
Browse more articlesShare article
Help your peers level up — share this article with colleagues who'd find it useful.
Email this articleContinue leveling up your engineering skills
Dive deeper with related guides chosen to complement this topic and accelerate your next project.
Field-tested Building Design Systems and Component Libraries
How to create reusable UI component libraries that scale across projects. Covers architecture decisions, documentation, testing, and versioning.
Field-tested Choosing the Right Tech Stack for Your Project
A framework for evaluating technologies and making informed stack decisions. Avoid hype-driven development and pick tools that match your actual requirements.
Field-tested Building a SaaS App with Astro and Cloudflare
A practical guide to building production SaaS applications using Astro, Cloudflare Workers, D1 database, and R2 storage — the modern edge-first stack.
Get engineering insights every week
Subscribe for framework updates, architecture patterns, and deep dives tailored to busy engineering teams.
Subscribe to Our Newsletter
Get tech tips, special offers, and updates delivered to your inbox.