Careeroza
GraphQL Overview
Ask for Exactly What You Need
With REST, the product page might call /products/7, /products/7/reviews and /sellers/5. With GraphQL, the client sends one query to one endpoint (/graphql) describing the exact fields it wants.
query ProductPage {
product(id: 7) {
name
price
category { name }
reviews(limit: 2) { rating comment }
}
}| REST | GraphQL | |
|---|---|---|
| Endpoints | Many URLs | One /graphql |
| Shape of response | Fixed by the server | Chosen by the client |
| Over/under-fetching | Common | Avoided |
| HTTP caching | Easy (GET + URL) | Harder (mostly POST) |
| Best for | Public APIs, simple CRUD | Rich UIs with many related objects |