Question presented to candidate:
"Our mobile app makes six or seven REST calls to draw its profile screen, and someone has proposed moving to GraphQL. Explain how REST and GraphQL differ, what GraphQL would actually fix for us, and what new problems it would bring."
What a strong answer should cover:
REST models resources at URLs with HTTP methods and status codes; GraphQL exposes one typed schema at one endpoint and the client sends a query naming exactly the fields it wants
What GraphQL fixes: over-fetching, under-fetching and extra round trips, one schema as a contract across many clients; quantified with a worked example
What it costs: HTTP caching by URL no longer works by default (POST to one URL), so you need persisted queries or client caches; errors arrive inside a 200 response
Server-side risks: the N+1 problem in resolvers (fixed with batching such as DataLoader), expensive or deeply nested queries (depth limits, query cost analysis, rate limits by cost)
When each fits: REST for public, cacheable, simple resource APIs and file transfer; GraphQL for many clients with different data needs over a rich, connected domain; both can live behind the same gateway
Code / implementation expected: Optional โ sketching a query and its resolvers helps; the example counts requests, bytes and resolver calls for one screen.
api
rest
2
Try it yourself
Sketch your approach before you read the solution. That is what the interview tests.
Stuck? Get a hint.
A short nudge toward the approach. It will not give the answer away.
3
Solution
Target Audience: Beginners to system design โ you have called an HTTP API; no GraphQL experience assumed.
Difficulty: Medium
Verified with: Node 22.22 and Python 3.12 (both print identical output).
How to read this doc: Every idea is explained in plain language first, then tagged with ๐ Interview term: so you also learn the exact words an interviewer expects. Request counts and byte sizes come from running the example; the Verified section quotes the full output.
1. Why This Even Matters โ A Story First
Two ways to shop for a recipe.
The supermarket with fixed aisles (REST). Every product has its own shelf with a clear label. You go to the dairy aisle for milk, the bakery for bread, the produce section for lemons. Each trip is simple and the store can stock popular shelves near the door. But for one recipe you walk to five aisles, and the eggs only com
The solution is hidden so you can try first
12 min read ยท 11 sections
4
Read the code
One screen via REST vs GraphQL: requests, bytes, and N+1 resolvers vs batching