REST vs GraphQL Simulator
Compare REST and GraphQL API approaches side by side. Make API requests, observe response payloads, and understand the tradeoffs between over-fetching, under-fetching, and query flexibility.
Category: API Design
What You Will Learn
- Compare REST and GraphQL request patterns
- Understand over-fetching and under-fetching
- Learn when to choose REST vs GraphQL
Topics covered: rest, graphql, api, web-development
// simulator
REST API vs GraphQL Simulator
Compare REST and GraphQL side-by-side. Understand over-fetching, under-fetching, the N+1 problem, and when to use each approach with interactive scenarios.
Compare data fetching approaches side-by-side
Scenario: Get basic user profile information
compared to REST
GET /api/users/123query {
user(id: "123") {
id
name
email
avatar
}
}Each HTTP request takes ~100ms for DNS lookup, TCP/TLS handshake, and server processing.
REST requires sequentialrequests. For nested data, request 2 can't start until request 1 finishes.
GraphQL bundles everything into one request. The server resolves all data in a single round-trip.
✅ Advantages
- • Simple and well-understood
- • Great HTTP caching with standard headers
- • Easy to debug with browser tools
- • Stateless architecture
- • Works well for simple CRUD operations
❌ Disadvantages
- • Over-fetching: Getting more data than needed
- • Under-fetching: Multiple requests for related data
- • N+1 problem with nested resources
- • Versioning challenges (v1, v2, etc.)
- • No built-in type system
✅ Advantages
- • Fetch exactly what you need, nothing more
- • Single request for complex nested data
- • Strong type system with schema
- • Self-documenting via introspection
- • No versioning needed - evolve schema
❌ Disadvantages
- • Caching is more complex
- • Query complexity attacks possible
- • Steeper learning curve
- • All requests are POST (harder to cache)
- • Overkill for simple APIs
Use REST when:
- • Building simple CRUD APIs
- • Caching is critical (CDN, browser)
- • Team is familiar with REST
- • Public APIs with many consumers
- • File uploads/downloads
Use GraphQL when:
- • Mobile apps need bandwidth efficiency
- • Complex UIs with nested data
- • Rapidly evolving frontend requirements
- • Multiple clients with different needs
- • Real-time subscriptions needed
Try next
// simulator
Fork Bomb Simulator
Visualize how the infamous :(){ :|:& };: fork bomb works. Watch processes multiply exponentially, exhaust system resources, and learn how to protect against it with ulimit, cgroups, and systemd.
// simulator
AWS VPC Networking Simulator
Learn AWS networking fundamentals with an interactive VPC simulator. Visualize how traffic flows through public and private subnets, understand NAT Gateways, Internet Gateways, and route tables.
// simulator
DNS Resolution Simulator
Learn how DNS works with an interactive step-by-step simulator. Visualize the DNS hierarchy, understand caching at different levels, and see the difference between recursive and iterative queries.