DEV Community

Pieter Humphrey
Pieter Humphrey

Posted on

Is GraphQL a REST API?

Is it right to consider GraphQL API a specific form of a REST API? What I read here and know about REST makes me think, yes, but I'd love to hear others' views on the topic. This is not a query for is-one-better-than-the-other arguments.

Discussion (3)

Collapse
alainvanhout profile image
Alain Van Hout

No I don't think you can consider GraphQL to be a kind of REST, since it doesn't follow the precepts of REST:

  • it doesn't use http verbs/methods in a semantic was
  • it doesn't supply different resources at different URLs
  • it doesn't use uniform interface for the URLs (i.e. that the path follows conventions like /users/:id)
  • it doesn't leverage (or even care about) media types (e.g. getting the same resource as JSON, XML, or something else entirely)

The only real overlap is that GraphQL typically uses http (though it doesn't really require that, conceptually) and a JSON-like syntax (just as actual JSON tends to be the preferred REST body syntax).

Collapse
patarapolw profile image
Pacharapol Withayasakpunt • Edited on

You might be interested in this, as I used to.

  • REST API has its maturity levels and doesn't necessarily use JSON. Most aren't that mature, I believe.
  • GraphQL always doesn't use JSON. Instead, it uses a different specification. Also, it doesn't necessarily send over HTTP. It usually exposes only a single endpoint.
  • Yes, most REST API vs GraphQL comparisons miss the point. It's Apple vs Orange.