Order #981
Home · Indiranagar, BLR-07
Your items
- Order
- Rider
- Catalog
- Store
Order #981
Home · Indiranagar, BLR-07
Your items
Order #981
Home · Indiranagar, BLR-07
Your items
One Zepto tracking screen, fetched two ways: a call per resource, or one query for the whole screen. Then the screen changes, and a thousand shoppers arrive. Illustrative sizes and times: a round trip over the mobile network is about 150 ms.
REST for simple resources and anything a CDN should cache: public APIs, files, webhooks. GraphQL when many screens need different slices of the same data — one round trip, exactly the fields. Plenty of companies run both.
| Difference | REST | GraphQL |
|---|---|---|
| One screen | One call per resource: 3 round trips | One query: 1 round trip |
| What comes back | Whole resources, used or not | Exactly the fields asked for |
| A new field on screen | Another call, or a new endpoint | One more line in the query |
| CDN caching | Built in: a GET has an address | Needs persisted queries |
| Errors | HTTP status codes | A 200, with an errors list |
| Best for | Public APIs, files, webhooks | Apps with many screens and clients |
One Zepto shopper opens the tracking screen: the order, its items, and the rider bringing it. On the left, REST: the app calls one address for each thing it needs. On the right, GraphQL: the app sends one query that describes the whole screen. Let’s put both through three situations.
First, loading the screen. With REST, the app asks for the order, and gets all of it back, including the rider’s ID.
Only then can it ask for the rider, and then for the items.
Three round trips over the mobile network, and thirteen kilobytes, for a screen that shows nine fields.
With GraphQL, the app sends one query naming those nine fields.
The GraphQL server fetches from the order, rider and catalog services, short hops inside the data centre, and sends back one answer with exactly those fields.
One round trip, under a kilobyte.
Next, the screen changes: the team adds the store’s name.
The order doesn’t include it, so the app makes a fourth call, to the store.
Or the backend team builds a new endpoint for this screen, and the app waits for it.
With GraphQL, the app adds one line to its query: the store’s name.
The server already knows how to fetch a store, so nothing changes there, and it’s still one round trip.
Finally, a thousand shoppers open the same deals list.
A REST request is a plain GET with an address, so the CDN keeps the answer: the first request reaches the server, and the other nine hundred and ninety-nine are answered at the edge.
GraphQL sends every query as a POST to the same address, with the question inside.
The CDN can’t tell them apart, so all thousand reach the GraphQL server.
Persisted queries fix this, by sending a short ID as a GET, but that’s extra work to set up.
So which should you pick? REST for simple resources and anything a CDN should cache, like public APIs and files. GraphQL when many screens need different slices of the same data: one round trip, exactly the fields, and screens change without new endpoints. Plenty of companies run both.