HACKER Q&A
📣 dhruvkar

GraphQL or REST – What is THE way to implement an API in 2020?


GraphQL or REST – What is THE way to implement an API in 2020?


  👤 mmerlin Accepted Answer ✓
IMO this depends who is the target user of the API.

If you are building an API for yourself or your company (for example, you are building the backend API for a Vue.js front end app to consume) then GraphQL is a very fine choice for reasons like ease/speed of adding new features to your API, concise single-fetches by the client consumer, and even the possibility of client with reactive subscription to a GraphQL query.

On the other hand, if you are publishing an API with the intention of enabling mass consumption by a large number of external customers, then begin by offering them a REST API for it’s ubiquity and familiarity. Once the REST API is built then you consider offering a GraphQL API.

It would be interesting to aggregate statistics from companies who offer both REST and GraphQL API’s and compare the popularity / adoption rates of each option, by their customers.


👤 Nextgrid
REST. It's been around for a long time, is well-understood and simple.

Don't introduce the extra complexity of GraphQL unless its advantages (which heavily depend on your use case) outweigh the drawbacks (the extra complexity is a big one).


👤 shams93
It depends like graphql requires a pretty heavy client library while rest can work with vanilla Js fetch with no client library