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.
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: api, rest, graphql, educational, interactive, backend
// 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
How Docker Works Under the Hood
Watch what really happens when you run docker run -p 8080:80 nginx, one layer at a time. Step down the whole stack: the CLI, the daemon, the registry pull, containerd, the OCI runtime bundle, runc, the running container, and the shared Linux kernel. Every stage shows the real low-level command you can run yourself, so it doubles as a tour of the primitives that make a container: namespaces, cgroups, and runc. A container is not a small VM, and this shows you why.
// simulator
Webhook Delivery Simulator
Send a webhook through a production-style delivery flow. Change endpoint responses, watch retries and backoff, inspect real HMAC-SHA256 signatures, and redeliver the same message to see receiver-side deduplication.
// simulator
Bounce Triage Simulator
Read a real SMTP bounce and decide what it is and what to do about it. Twelve genuine failures from Gmail, Outlook, Postfix and Proofpoint: hard bounces, soft bounces, content blocks, rate limits and spam complaints. Learn why the 4xx and 5xx class digit is a hint rather than the answer, which bounces to suppress permanently, which to retry, and what each mistake costs you in lost subscribers or lost sending reputation.