Card 09/ 09
Recap: REST, GraphQL and gRPC
Resources for broad reach, queries for varied screens, procedures for fast typed calls between services.
Each style answers a different question about who shapes the data and who the clients are.
- REST exposes resources at URLs; every client can call it and every HTTP cache understands it.
- GraphQL exposes one endpoint and a schema; the client names the fields and gets exactly those.
- gRPC exposes procedures from a
.protofile, called with generated code over HTTP/2. - Over-fetching and under-fetching are REST's cost for varied screens, and GraphQL's reason to exist.
- Protobuf field numbers are the contract: add new ones, reserve removed ones, never reuse one.
- GraphQL needs cost limits: depth, list sizes and query cost, or one request can ask for everything.
| Decision | REST | GraphQL | gRPC |
|---|---|---|---|
| The clients are | Many and unknown | Your own varied front ends | Your own services |
| The priority is | Reach and caching | Fitting each screen | Speed and typing |
| Browsers call it | Yes | Yes | Only through gRPC-Web |
← → move through sections and cards