REST, GraphQL and RPC

Play this lesson

Same question, three styles

The phone app needs garden 7 and its plants. There are three popular styles for asking a server, and each asks differently.

REST, GraphQL and RPC

Quick check

Which style lets the phone ask for exactly the fields it needs in one request?

  1. GraphQL
  2. REST
  3. None of them
Show the answer

GraphQL

GraphQL's site says it lets you "request exactly the data you need". REST returns each URL's whole shape, which can take several requests.

Read the query

garden.graphql
query {  garden(id: 7) {    name    plants { kind health }  }}

What comes back?

  1. The garden's name and each plant's kind and health, nothing else
  2. Every field the garden has
  3. Only the plants
Show the answer

The garden's name and each plant's kind and health, nothing else

A GraphQL answer has the same shape as the query. Fields the query does not name are not sent.

The trade-offs

REST is simple, and each URL can be cached by a CDN. GraphQL saves round trips, but a GraphQL server "operates on a single URL/endpoint, usually /graphql", so caching and rate limits need more thought. gRPC's typed binary messages are compact, a good fit for calls between servers.

Quick check

A GraphQL API usually answers every query at one URL.

Show the answer

True

GraphQL's own guide says a server operates on a single endpoint, usually ending in /graphql, and every request goes there.

Shard Garden's choice

REST for public things many players read, like garden pages and the leaderboard, because a CDN can cache them. gRPC between the studio's own servers, like a match server reporting a result to the save service. Remy records the choice in a decision record.

Pick the style

The leaderboard is read by millions and changes once a minute. Which style should Remy pick so a CDN can cache it?

  1. REST: GET /leaderboard is one URL a CDN can keep a copy of
  2. GraphQL: one endpoint for every query
  3. gRPC: compact binary messages
Show the answer

REST: GET /leaderboard is one URL a CDN can keep a copy of

A CDN caches by URL. One stable URL with the same answer for everyone is exactly what a CDN is good at.

Not every job needs an answer now

Some work, like emailing every player, is too slow to do while a player waits for an answer.

Bolt says: Next: queues and background jobs.

Fact-checked 12 October 2026