API Style & Pattern Comparisons

Side-by-side trade-offs. Neither column wins — the consumer environment, the data shape and the operational budget decide.

REST vs GraphQL

Server-defined response shapes per endpoint vs a typed graph where each client selects exactly the fields it needs — moving the flexibility, and its cost, from client to server.

Use when

Response shapes are stable per consumer, HTTP caching matters, and you want failures visible in status codes.

Avoid when

You would build one endpoint per screen anyway — a BFF gives the same fit with far less machinery.

Strengths

Simplicity: cache by URL, debug with curl, reason about one endpoint's cost in isolation.

Fails when

Screens need five calls (under-fetching) or drag 80 fields for 3 (over-fetching), and mobile pays the RTT bill.

Operational cost

Endpoint sprawl management: every new client need is a new endpoint or parameter to design, document and version.

Use when

Many client teams with divergent data needs iterate faster than the API team can ship purpose-built endpoints.

Avoid when

A small team runs one first-party client; you inherit resolvers, cost control and authorization complexity for flexibility nobody uses.

Strengths

Typed schema with introspection, one round trip per screen, no client-specific endpoint sprawl.

Fails when

An unanticipated nested query fans out into thousands of resolver calls and nobody bounded its cost.

Operational cost

Resolver batching (dataloaders), query-cost limits, per-field authorization, and caching rebuilt above the HTTP layer.

DimensionRESTGraphQL
Who shapes the responseThe server, per endpointEach client, per query, within the schema
Over/under-fetchingCommon — fixed shapes fit nobody exactlySolved for clients, relocated to resolver efficiency
CachingHTTP-native: URL + Cache-Control + ETagCustom: normalized client caches, persisted queries
Failure surfaceStatus codes intermediaries understand200 with an errors array — monitoring must read bodies
Cost controlPer endpoint, known at design timePer query — needs depth limits and cost analysis at runtime