DEV Community

Discussion on: REST API OR GraphQL

Collapse
 
rhymes profile image
rhymes

As the others said, it depends on requirements and needs.

Taking from GraphQL vs REST: Overview:

  • Most of us don't do REST, we do RESTish (the hypermedia part is left out in many, many, APIs, mine included)
  • If you are not using hypermedia then GraphQL is a good alternative
  • File uploading is easier in REST than in GraphQL
  • Deprecation is easier in GraphQL
  • GraphQL is better for asking only a subset of a full resource (because you can ask only the fields you need)
  • REST plays better with caching at all levels (proxies and all). GraphQL transfers caching to the client and cannot use HTTP caching headers.
  • GraphQL is better at introspection (you don't have to design the schema of the API, it's implicit in the definition)
  • Filtering is hard in both
  • Sending different responses for different clients is way easier in GraphQL (which is one of the reasons Github migrated to it)

I don't think they can be pitted against in every case, it really depends on what you need. You can also use both as it's suggested in the article :)