Christian Alt-Wibbing Christian Alt-Wibbing - 10 months ago 63
reST (reStructuredText) Question

Difference between GraphQL and Embedding

I'm just playing a little with graphql and can not yet recognize the difference between graphql and REST with embedding and partial response.

Partial Response is used by TeamCity since years and it works as "Restful" Service

Answer Source

REST is an architectural style, not a format or a query language (like GraphQL is). It is possible to build an API which supports partial resources or a hierarchy of resources (other examples would include JSON patch or JSON Graph), but such approaches are not a conceptual part of REST. On the other hand, they are a conceptual part of GraphQL. You picked examples which bear some similarity with GraphQL, but this is not due to the fact that they are RESTful services.

On the other hand, REST is based on a few approaches that do not conform with GraphQL (or vice versa). An incomplete list includes:

  • HTTP is a building block of REST. The GraphQL specs speaks of “client” and “server”, but I didn’t read that it requires HTTP.
  • REST is based on HTTP verbs. As it seems like GraphQL doesn’t require HTTP, it can’t require HTTP verbs. This wouldn’t work, anyway, as GraphQL allows you to mix operations in one query: you can execute a mutation plus a query in one request – which would not be REST-compatible, as the query would have to be a GET, while the mutation would have to be a POST or PUT.
  • The semantics of HTTP status code are missing from GraphQL.