REST models the world as resources (URLs) and uses HTTP methods to act on them. GraphQL exposes a single endpoint and lets the client request exactly the fields and shape of data it needs in one query.
Each resource has its own URL. The server decides the response shape. To get a user and their posts you might call two endpoints (or a custom “compound” endpoint).
One POST to /graphql with a query. The client specifies fields (e.g. user + nested posts). Server resolves and returns only what was asked.
| Aspect | REST | GraphQL |
|---|---|---|
| Endpoints | Many (per resource) | One (or few) |
| Response shape | Server-defined | Client-defined |
| Over-fetching | Possible | Avoided by design |
| Under-fetching | Multiple round-trips possible | One query for related data |
| Caching | HTTP cache (URL = key) | More complex (normalized caches) |
| Learning curve | Simpler | Query language + schema |
When to use REST: Simple CRUD, strong HTTP caching, broad tooling. When to use GraphQL: Complex UIs needing flexible shapes, many clients with different needs, reducing over/under-fetching.