mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2026-09-24 15:00:31 +08:00
649 B
649 B
GraphQL is a query language for APIs that allows clients to request exactly the data they need, reducing over-fetching or under-fetching.
Main differences with REST:
Data Fetching:
- REST: Fixed endpoints return predefined data
- GraphQL: Single endpoint with flexible queries
Batching:
- GraphQL can fetch related data in one request (nested queries)
- REST often requires multiple endpoints for related data
Versioning:
- REST may need new versions for API changes
- GraphQL avoids versioning by evolving schemas
Example GraphQL Query:
query {
user(id: 1) {
name
posts {
title
}
}
}