Skip to main content
Communicationchapter 1 of 4 · 4 lessons

REST vs GraphQL vs gRPC

Three API styles with very different trade-offs in performance, flexibility, and tooling.

One screen in your mobile app shows a user, their last five orders, and the items in each order.

Built the ordinary way, that screen makes three trips to your server, one after another, because each answer tells the phone what to ask for next. On a train, at 80 milliseconds a trip, the screen sits empty for a quarter of a second before it draws anything. Two of those trips also returned forty fields to display two.

Somebody suggests a second endpoint shaped exactly for this screen. That works, and eleven screens later you have eleven endpoints and nobody remembers which app still uses which.

There are three answers to this, and they are not competing on one axis. Each is tuned for a different caller: strangers on the public internet, your own frontend teams, and your services talking to each other.

Lessons

4 in this chapter
  1. REST and Its LimitsResources, verbs, and HTTP semantics. Boring, cacheable, and everywhere, until the round trips add up.2 min
  2. GraphQLThe client declares the exact shape it needs, and one request returns exactly that.3 min
  3. gRPCBinary protobuf over HTTP/2 with generated clients, built for service-to-service traffic.3 min
  4. Choosing Per BoundaryPick the style based on who the caller is, not on which one is newest.2 min