What Is GraphQL?
GraphQL flips the usual API model: instead of the server deciding what a response contains, the client asks for exactly the fields it needs.
What Is GraphQL?
GraphQL is a query language for APIs, along with a runtime for executing those queries against your data. Instead of calling multiple fixed REST endpoints and getting back whatever fields each one returns, a client sends a single GraphQL query describing exactly the fields it wants -- across potentially multiple related resources -- and the server returns exactly that shape, nothing more.
REST vs. GraphQL
| REST | GraphQL |
|---|---|
| Multiple endpoints, one per resource | Typically one endpoint for all queries |
| Server decides response shape | Client decides response shape per request |
| Over-fetching/under-fetching is common | Fetch exactly the fields you need |
| Simple to cache with standard HTTP caching | Caching requires more deliberate setup |
| Simpler to learn and debug | More powerful for complex, nested data needs |
When GraphQL Makes Sense
GraphQL tends to earn its complexity when a frontend needs to pull deeply nested, related data in one round trip (a mobile app screen combining a user profile, their recent orders, and related recommendations, for example), or when many different clients need different slices of the same underlying data. For simpler CRUD-style APIs, plain REST is usually easier to build, cache, and reason about.