What is GraphQL
Published: (March 15, 2026 at 07:20 AM EDT)
3 min read
Source: Dev.to
Source: Dev.to
Overview
- Developed by Facebook
- A query language for APIs
- User‑friendly because the data format of API requests and responses are similar
- REST is an architecture (design), while GraphQL is a language (DSL)
REST Example
Send requests to endpoints using HTTP verbs:
curl https://api.bmf-tech.com/v1/configs[
{
"id": 1,
"name": "title",
"alias_name": "Title",
"value": "bmf-tech",
"created_at": "2017-09-25 23:08:23",
"deleted_at": null
}
]GraphQL Example
Send queries to a single endpoint:
curl https://api.bmf-tech.com/api{
configs {
id
name
alias_name
value
created_at
updated_at
deleted_at
}
}[
{
"id": 1,
"name": "title",
"alias_name": "Title",
"value": "bmf-tech",
"created_at": "2017-09-25 23:08:23",
"deleted_at": null
}
]Comparison Summary
| Feature | REST | GraphQL |
|---|---|---|
| Endpoints | Multiple | Single |
| HTTP Verbs | Dependent | Independent |
| Type System | None | Available |
| Versioning Required | Yes | No |
| Documentation Required | Yes | No (API definition serves as docs) |
| Resource Limitation | Mainly call count | Handled according to resource amount |
| Response Flexibility | Fixed response per endpoint | Client specifies desired fields |
| Performance | May need multiple requests | Fewer requests, larger payloads |
| Monitoring | Per‑endpoint monitoring possible | Requires custom measures for queries |
| Caching | Can use HTTP cache | Cannot rely on HTTP cache |
Practical Considerations
- Load Calculation: With GraphQL you often need methods for load calculation (e.g., based on the number of objects returned).
- Documentation: GraphQL’s schema acts as a self‑documenting API; explicit external docs are less critical.
- Libraries: Implementations typically require libraries for parsing queries.
- Performance: Not inherently faster than REST; benefits come from reduced round‑trips.
- Data Volume: Both approaches need pagination or field selection to control payload size.
- Monitoring: Since GraphQL uses a single endpoint, additional tooling may be needed to track query‑level performance.
- Caching: Standard HTTP caching is not applicable; alternative caching strategies should be explored.
When to Consider GraphQL
- Applications with many components and complex UIs where the number of requests becomes a bottleneck.
- Situations where clients need to fetch varied data shapes without multiple round‑trips.
Resources
- graphql.org – Official GraphQL documentation
- facebook/graphql RFCs – Specification and proposals
- “A small rebuttal to What is GraphQL suitable for” – Discussion on use‑cases
- “Memo when implementing GraphQL API in a Rails app” – Practical implementation notes
- “Explaining GraphQL from a beginner’s perspective” – Introductory guide comparing REST and GraphQL