- The GraphQL Promise
- The Hidden Costs of GraphQL
- When REST Wins
- When GraphQL Wins
- The Decision Framework
In 2015, Facebook open-sourced GraphQL, and many predicted REST APIs were dead. Nearly a decade later, REST is still the default for most applications. Why didn't GraphQL take over?
The GraphQL Promise
Ask for exactly what you need, get exactly that—nothing more, nothing less.
With REST, you hit /users/1 and get the entire user object—50 fields when you only needed 3. With GraphQL, you specify exactly what you want:
query {
user(id: 1) {
name
email
avatar
}
}
GraphQL's Core Advantages
- No over-fetching: Request only the fields you need
- No under-fetching: Get related data in one request (no N+1 client calls)
- Strongly typed schema: Self-documenting API with introspection
- Client autonomy: Frontend teams evolve without backend changes
The Hidden Costs of GraphQL
GraphQL shifts complexity from the client to the server. This trade-off isn't always worth it.
| Challenge | Why It Matters |
|---|---|
| N+1 Problem (Server) | Naive resolvers make N database queries per item |
| Caching Complexity | POST requests don't cache like GET; need Apollo/Relay |
| Security Surface | Query depth, introspection exposure, rate limiting are harder |
| Tooling Requirements | Need DataLoader, schema stitching, persisted queries |
A simple GraphQL query for "users with their posts" can generate 100+ database queries if you don't use DataLoader or similar batching.
When REST Wins
- Simple CRUD applications: REST's resource model is natural and predictable
- Public APIs: REST is universally understood, cacheable, and rate-limitable
- Microservices: Service-to-service communication doesn't need GraphQL's flexibility
- Small teams: Less infrastructure overhead, faster to ship
Modern REST uses JSON:API or OpenAPI specs, field filtering (?fields=name,email), and HATEOAS links. It's more flexible than "textbook REST."
When GraphQL Wins
- Multiple clients with different needs: Mobile needs less data than web; GraphQL handles both
- Rapidly evolving frontends: Frontend teams can move without waiting for backend endpoints
- Complex, interconnected data: Social graphs, e-commerce catalogs, content management
- BFF (Backend for Frontend) patterns: GraphQL as an aggregation layer over REST services
The Decision Framework
| Scenario | Recommendation |
|---|---|
| Simple CRUD app, single client | REST |
| Public API for third parties | REST |
| Mobile + Web + TV clients, same backend | GraphQL |
| Microservices communication | REST or gRPC |
| Aggregating multiple REST services | GraphQL (BFF) |
| Real-time subscriptions needed | GraphQL |
- GraphQL solves over-fetching and under-fetching, but adds backend complexity
- REST is simpler, more cacheable, and still the right choice for most apps
- GraphQL shines when you have multiple clients with different data needs
- Consider GraphQL as a BFF layer over existing REST services
- Don't use GraphQL just because it's trendy—evaluate the trade-offs