Professional Documents
Culture Documents
REST is often the right choice when you need your data access to align
tightly to HTTP. For example, if you rely heavily on HTTP-level caching,
or if you need to represent data spread across many different domain
services which use URLs to reference other data.
GraphQL is often the right choice when network speed and latency is
the primary concern and data isn't spread across different domains
but is instead centralized to one product. In this case a single network
request can load many different kinds of resources at once, and selectively
include only what that client needs. Particularly on mobile network
connections, this can be a dramatic performance improvement. However
caching data may require more sophisticated techniques.
Below are some of the usecases (problems that it solves) for GraphQL :
Here you can see that we have multiple UI points that require data from different
resources, all needing to be displayed co-located. These types of problems are
where GraphQL really shines.
Coursera’s journey to GraphQL, and highlight a few of our successes and failures
along the way
https://blog.apollographql.com/courseras-journey-to-graphql-a5ad3b77f39a
(1) fetch all data in a single roundtrip
(2) providing structured documentation for our APIs.
/users/posts?sortBy=date&fields=title,description&likes_above=3
If you, on the other hand completely control the API consumer (e.g. your own SPA or
mobile app) + the requests look more like:
/users/posts/2
and the consumer will use allmost all fields returned by this request,
—————————————————————————————————————
I was asking myself the same question for our backend services. ..
Something upfront:
We use all the new stuff on the frontend of our SPA. (React.js, ES6, Mobx State Tree
etc.) But on the backend we decided not to use GraphQL and go with REST.
The data needs of your client will change constantly maybe on a daily or
weekly basis -and this is by design!
You use Node.js on the backend. (The best and proven GraphQL
implementation is still on Javascript). Others are mostly not well enough
tested or are changing to often.
If you aren’t using Node.js, you are ready to write low level stuff like batch
loaders yourself.
You are willing to accept inapt or lacking documentation.
You are developing in an extreme form of continuous deployment,
changing and “breaking” the API on a daily or weekly basis.
For most cases: I would stay with REST.