GraphQL — query language, single endpoint, client picks fields, typed schema. Cures REST over-fetch/waterfall; bill = hard cache + N+1 + DoS surface.
Разбор
REST — many endpoints, fixed server shape. GraphQL — onePOST /graphql, client query = response shape 1:1.
# One request replaces GET /user + GET /user/orders + GET /orders/:id/items
query {
user(id: 7) {
name # ← ask for exactly these fields
orders(last: 3) { # ← traverse relationships in ONE round trip
total
items { sku, qty } # ← no over-fetch, no waterfall
}
}
}
Mental unlock: graph traversal, not endpoints. Schema = typed contract.
Итог
GraphQL = client-controlled shape in one round trip; server must add DataLoader + query guards.