QA
Beginner LevelREST APIs & Web Services

What are the main differences and trade-offs between REST and GraphQL?

❓ Interview Prompt: Compare REST APIs (multiple endpoints, fixed schemas, HTTP caching) vs GraphQL (single endpoint, flexible queries, over/under-fetching fixes).

REST and GraphQL represent fundamental web API paradigm choices:

| Feature | REST APIs | GraphQL |

|---|---|---|

| Endpoints | Multiple URIs ('/users', '/orders') | Single endpoint ('/graphql') |

| Data Fetching | Server determines fixed JSON payload shape | Client queries exact required fields |

| Over/Under-Fetching | Common issue requiring multiple API calls | Solved completely by client query schemas |

| Caching | Native HTTP/CDN URL caching out of the box | Complex client-side normalized caching |

| Tooling & Standards | Universal HTTP verbs, status codes, OpenAPI | Strongly-typed schema definition language (SDL) |

Code Implementation Example

json
// GraphQL Client Query requesting exact fields:
// query { user(id: 42) { name email orders { id amount } } }

// Returns exactly what was requested (No over-fetching!):
{
  "data": {
    "user": {
      "name": "Alice",
      "email": "alice@example.com",
      "orders": [{ "id": 101, "amount": 49.99 }]
    }
  }
}
💡GraphQL precise payload query execution avoiding over-fetching.
🎯 Interview Key Takeaway

REST leverages native HTTP caching and standard URIs; GraphQL eliminates over/under-fetching via single-endpoint query schemas.

#GraphQL vs REST#API Paradigms#Architecture#Beginner
Back to all REST APIs & Web Services Questions→

More REST APIs & Web Services Interview Questions

Beginner LevelREST APIs & Web Services

What is HTTP Method Idempotency and how do you implement Idempotency Keys for REST APIs?

Beginner LevelREST APIs & Web Services

What are standard HTTP Status Codes (200, 201, 204, 400, 401, 403, 404, 409, 429, 500, 503)?

Beginner LevelREST APIs & Web Services

What are HTTP Verbs (GET, POST, PUT, PATCH, DELETE) and when to use PUT vs PATCH?