What is GraphQL?
GraphQL is a query language and runtime for executing queries against your data. It provides:- Single endpoint - All queries and mutations go through one endpoint
- Flexible queries - Request only the fields you need
- Strong typing - Schema defines all available data and operations
- Introspection - Explore the API schema directly
Basic concepts
Queries
Queries are used to fetch data. They are read-only operations:Mutations
Mutations are used to modify data (create, update, delete):Fields
Fields represent the data you want to retrieve. You can request nested fields:GraphQL vs REST
| Feature | REST | GraphQL |
|---|---|---|
| Endpoints | Multiple endpoints | Single endpoint |
| Data fetching | Fixed structure | Flexible queries |
| Over-fetching | Common | Avoided |
| Under-fetching | Common | Avoided |
| Versioning | URL-based | Schema-based |
Next steps
- Learn about forming calls with GraphQL
- Explore variables and fragments
- Understand pagination
- See using GraphQL clients