Skip to main content

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.

Supported byBecome a sponsor
BitriseAtomsizedDigitalOceanDevDojoSMTPfastQuizAPI
REST API vs GraphQL

Compare data fetching approaches side-by-side

Scenario: Get basic user profile information

HTTP Requests
1
REST
1
GraphQL
Payload
2.0 KB
REST
256 B
GraphQL
Time
-
REST
-
GraphQL
Bandwidth Saved
88%
less data downloaded
compared to REST
REST API
1 request(s)
GET/api/users/123
Over-fetched fields:
created_atupdated_atlast_loginsettingspreferences
GET /api/users/123
GraphQL
1 request
POST/graphql
Single request fetches exactly what you need
Requested fields (exact):
idnameemailavatar
query {
  user(id: "123") {
    id
    name
    email
    avatar
  }
}
Understanding the Comparison
Network Round-Trip

Each HTTP request takes ~100ms for DNS lookup, TCP/TLS handshake, and server processing.

REST Waterfall

REST requires sequential requests. For nested data, request 2 can't start until request 1 finishes.

GraphQL Batching

GraphQL bundles everything into one request. The server resolves all data in a single round-trip.

REST API

✅ 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
GraphQL

✅ 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
💡 When to Use Each

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

Overview

REST and GraphQL are two ways to design an API, and the difference shows up most clearly when a screen needs data from several places. This simulator runs the same data needs against both styles and shows the requests that travel and the data that comes back. In a simple fetch the two look much alike. With nested data, such as a user and their posts, REST needs a second request. With related data, such as the comments on each post, the number of REST requests grows with every post, the N+1 problem, while one GraphQL query asks for exactly the nested fields. REST also tends to over-fetch, returning whole objects when the screen needs two fields. GraphQL avoids both by letting the client describe the shape of the response. The trade-offs run the other way too: GraphQL moves complexity to the server, makes HTTP caching harder and needs limits on query depth, while REST stays simple to cache and reason about. The goal is to pick the right tool for each API rather than a winner.

Try this

  1. Run "Simple Fetch" in both styles and compare the requests and payloads.
  2. Switch to "Related Data" and count the REST requests, one more for every post, compared with a single GraphQL query.
  3. Use "Multiple Resources" to see over-fetching in REST responses next to the fields GraphQL returns.

Frequently asked questions

What is over-fetching?
Getting more data than the client needs, such as a full user object when the screen only shows a name. It wastes bandwidth and is common with fixed REST endpoints.
Is GraphQL faster than REST?
Not inherently. GraphQL can reduce round trips and payload size, but a complex query can be expensive to resolve on the server, and REST responses are easier to cache over HTTP.
When should I choose REST over GraphQL?
When the API is resource oriented, clients are simple or public, and HTTP caching matters. GraphQL fits best when many clients need different shapes of the same related data.

Try next

Sponsored
Carbon Ads
$ cd /games
// share