REST to klasyczne API:
GET /users/1
GET /users/1/posts👉 wiele endpointów
👉 overfetching / underfetching
⚡ GraphQL
{
user(id: 1) {
name
posts {
title
}
}
}👉 jedno zapytanie
👉 dokładnie te dane, które chcesz
⚖️ Porównanie
| REST | GraphQL |
|---|---|
| prosty | bardziej złożony |
| cache łatwy | cache trudniejszy |
| wiele endpointów | jeden endpoint |
💡 Kiedy co?
✔ REST → prosty system / MVP
✔ GraphQL → skomplikowane fronty / mobile