REST, GraphQL and gRPC

Topics in this section
1 cards

Three styles, three trade-offs

REST over HTTP + JSON uses URLs and methods as in this course. Strengths: every language and tool speaks it, HTTP caching works, easy to debug with curl. Weakness: clients may need several requests to build one screen, or get more fields than they need.

GraphQL exposes one endpoint and a typed schema; the client sends a query naming exactly the fields it wants, across related objects, in one round trip. Strength: flexible clients, especially mobile apps with many screens. Costs: HTTP caching mostly doesn't apply (queries are POSTs), and the server needs limits on query depth and cost, or one query can ask for the whole database.

gRPC sends compact binary Protocol Buffers over HTTP/2, with code generated from a .proto contract and built-in streaming. Strength: fast, strictly typed service-to-service calls. Cost: browsers can't call it directly without a proxy, and payloads aren't human-readable.

REST, GraphQL and gRPC side by side with their typical callers and strengths
In real life

A common split: gRPC between internal microservices, a public REST API for partners, and sometimes GraphQL as a gateway for the company's own mobile and web apps.

Check yourself

Which pairings of situation and style make sense? (Choose two.)

Select 2, then check.