⬡ GraphQL Beginner

What is over-fetching and under-fetching in REST and how does GraphQL solve them?

Answer

Over-fetching occurs when a REST endpoint returns more data than the client needs — e.g., a /users/{id} endpoint returning 20 fields when the mobile app only displays 3. This wastes bandwidth. Under-fetching occurs when a single endpoint does not return enough data, requiring the client to make additional requests — e.g., fetching a user then separately fetching their posts (N+1 HTTP requests). GraphQL solves both: the client requests exactly the fields it needs (no over-fetching), and nested queries fetch related data in one round trip (no under-fetching). This is especially valuable for mobile clients on slow or metered connections.