REST vs GraphQL: Multiple Endpoints vs Single Query Language

Overview REST structures an API as a fixed set of endpoints, each returning a predetermined shape of data tied to a resource. GraphQL exposes a single endpoint driven by a client-specified query, letting callers request exactly the fields they need across related resources in one round trip. Comparison Diagram RESTGraphQLClient/users/1/users/1/posts/posts/1/comments3 requests, fixed shapesResponse 1: full user objectResponse 2: full posts arraymay over- or under-fetch fieldsClient/graphql{ user(id:1){name posts{ title }} }1 request, client-shapedSingle JSON responsematches requested fields Comparison Table Aspect REST GraphQL Request entry point Multiple resource-based URLs (e.g. /users, /posts) Single endpoint (e.g. /graphql) for all operations Query specification Server defines response shape per endpoint Client defines response shape via query document Fetching related data Requires multiple round trips or ad-hoc nested routes Nested relations resolved in one request via resolvers Over/under-fetching Common — fixed payloads return unused or missing fields Minimized — client requests exactly the fields it needs Caching Leverages HTTP caching (ETags, CDNs, cache-control) Requires custom client-side or persisted-query caching Versioning strategy New versions (/v2/) or new endpoints for breaking changes Schema evolves additively; fields deprecated in place Error handling HTTP status codes signal success/failure per request 200 OK typical even on partial errors; errors array in body Tooling and discovery Relies on external docs (OpenAPI/Swagger) for contracts Self-describing schema with built-in introspection Key Differences REST models an API around resources and HTTP verbs; GraphQL models it around a typed schema and queries. REST responses have a shape fixed by the server; GraphQL responses are shaped by the client query itself. REST benefits from standard HTTP caching infrastructure; GraphQL typically needs bespoke caching layers. Fetching nested or related data usually takes REST multiple round trips, while GraphQL resolves it in a single request. REST signals failures through HTTP status codes; GraphQL usually returns 200 with errors embedded in the payload. When to Use Each REST ...

September 6, 2026 · 3 min · 428 words · jeonck

REST vs GraphQL: API Query Model

Overview REST and GraphQL are both HTTP-based API paradigms that differ fundamentally in how clients request data. REST exposes multiple URLs with server-defined response shapes; GraphQL exposes a single endpoint where the client’s query body dictates exactly which fields and relationships to return. The distinction drives decisions around over-fetching, N+1 latency, HTTP cacheability, and schema contracts. Comparison Diagram RESTmultiple endpoints, fixed shapeClientGET /usersGET /postsGET /comments3 requestsEach response = full object:{ id, name, email, avatarUrl, createdAt, role, prefs }only name+email needed → over-fetchRelated data → N+1 round-tripsBreaking change → new URL, e.g. /v2/GET · cacheable · status codesGraphQLone endpoint, client-declared shapeClientPOST /graphql1 requestquery (client-authored)query { user(id: 1) { name email } posts { title }}SDL schema (server)type User { name: String! email: String posts: [Post]}Response: exactly what was declared{ user: { name, email }, posts: [{ title }] }Schema evolves via @deprecated, no versioningPOST · typed schema · introspectable Comparison Table Aspect REST GraphQL Endpoints One URL per resource type — GET /users, POST /orders, etc. Single URL (POST /graphql); resource selection is in the query body Response shape Fixed by the server; client receives all fields the endpoint defines Declared by the client per query; only the requested fields are returned Over/under-fetching Chronic: server returns full objects; client discards unused fields or must make extra requests for missing ones Eliminated by design: resolvers return only fields the query specifies HTTP caching Native: GET responses cache at CDN and browser level by URL + headers Non-trivial: queries are POST bodies; requires persisted queries or APQ for cache-key stability Type system Optional — enforced only if you add OpenAPI/JSON Schema; not validated at runtime by default Mandatory SDL schema; all queries are parsed and validated against it before execution Versioning Breaking changes typically require new URL paths (/v1/, /v2/) or custom Accept headers Additive schema evolution with @deprecated directives; a single endpoint surface stays stable Error handling HTTP status codes carry semantic meaning: 200, 404, 422, 500, etc. Always 200 OK; errors surface in an errors[] array alongside any partial data Introspection / discoverability Requires an external spec (OpenAPI/Swagger); not built into the protocol Built-in: query __schema or __type to get the full type graph at runtime Key Differences REST has one endpoint per resource; GraphQL has one endpoint for the entire API, and the query body — not the URL — determines what data comes back. REST responses return all server-defined fields for a resource (over-fetch), and fetching related data requires additional round-trips (N+1 problem). A single GraphQL query can traverse multiple types and return exactly the fields requested. REST uses standard HTTP verbs and status codes, making GET-based CDN and browser caching trivially available. GraphQL queries travel as POST bodies, breaking HTTP cache semantics by default and requiring explicit workarounds. GraphQL’s SDL provides a mandatory, introspectable type contract enforced at parse time. REST type contracts are optional add-ons (OpenAPI); the server can return anything without violating the protocol. REST breaking changes typically force a new URL version (/v2/); GraphQL prefers additive schema evolution with @deprecated, keeping a single endpoint surface over the API’s lifetime. When to Use Each REST ...

August 2, 2026 · 4 min · 726 words · jeonck