Comparison
REST-style APIs and GraphQL
REST describes architectural constraints commonly used to organize resource-oriented HTTP APIs.
At a glance
- REST-style emphasis
- Resources and HTTP interactions
- GraphQL emphasis
- A typed schema and client-selected fields
Overview
REST describes architectural constraints commonly used to organize resource-oriented HTTP APIs. GraphQL defines a query language and execution model with a typed schema. The comparison concerns how clients request data and how a service exposes its contract, not a universal ranking of API quality.
What differs
A resource-oriented API exposes operations through its documented resource interfaces. GraphQL lets a client select fields against a schema, and the server resolves that selection under the service's rules.
Choose by the task
Consider the consumers' data needs, caching approach, operational tooling, and permission model. A schema or endpoint style cannot by itself ensure that expensive requests are bounded or that data access is authorized.
Common confusion
GraphQL does not remove backend work, and an HTTP API is not automatically RESTful. Judge the actual contract and implementation rather than inferring guarantees from a style label.
Sources and review
MOOR's explanatory text is supported by the following source links.
- REST glossary — MDN Web Docs
- Learn GraphQL — GraphQL Foundation