One Endpoint That Returns Exactly the Fields You Asked For
System Design

One Endpoint That Returns Exactly the Fields You Asked For

Subtitle: One schema, many backends, one shape.

Left column - REST: many endpoints:

One URL per resource Fixed shape, fixed fields Need three things? Three trips Unused fields ride along Client waits on chained calls

Right column - GraphQL: one endpoint:

One typed schema up front You name the fields you want Every field has a resolver One query fans out to DB, fn, API One shaped response comes back

Simple difference:

REST = server picks the shape. GraphQL = client picks the shape.

Resolvers - where the fan-out lives:

A field is a small function Reads a DB row, a function, an API Server joins them into one tree

Subscriptions - realtime in the schema:

Server holds a websocket per client A mutation pushes to subscribers Realtime is a field, not a service

Sticky note - The N+1 does not vanish:

It moves into the resolvers. Twenty items with a child field means twenty backend calls. The client sees one clean query, so the cost is invisible.