5 ms·
Again, the problems you describe with REST are a limitation of your implementation, not of REST itself. GraphQL itself is built on top of REST via a single GET/
by mpetrovich 9y ago
Again, the problems you describe with REST are a limitation of your implementation, not of REST itself. GraphQL itself is built on top of REST via a single GET/POST query endpoint.
The difference between it and typical REST implementations is that the resource identifier and fields to return have been moved into a novel query syntax. However, the same result can be achieved with a typical REST endpoint combined with a sparse fieldset query parameter [1]:
/users/123?fields=name,email,work.name,work.address
where "work" is a sub-resource in the same vein as GraphQL. The difference between this and GraphQL is purely syntactic:
user({ "id": 123 }) {
name,
email,
work {
name,
address
}
}
[1] http://jsonapi.org/format/#fetching-sparse-fieldsets http://jsonapi.org/format/#fetching-sparse-fieldsets
- Touche 9y agoGraphQL uses a single endpoint for the entire API. It would be a POST to /graphql, there would be no /users/123 resource. GraphQL is a form of RPC, it's not REST.
- m12k 9y agoWhen you say that GraphQL is built on top of REST, are you sure you're not mixing up REST and HTTP? Replace the hierarchical URI structure from REST with a 'novel query syntax' and all that's left is pretty much just the fact that both are ways of fetching data using HTTP methods.