Did someone try developing a GraphQL instead of RESTful API? Can someone give real life (not only theoretical) pros and cons. Basically from my research I found that the GraphQL power is to get exactly what you need nothing more. Where with REST APIs, you often have to make a series of requests and you can easily get back more information than you really needed.
Is it worth the time spent on researching and learning GraphQL? Any bugs or showstoppers that get your attention?
As previously mentioned, GraphQL does not replace REST. Despite their differences, GraphQL and REST also have similarities: They can both be fetched by an HTTP GET request with a URL and return the request in JSON data.
GraphQL stability are less error prone, automatic validation and type checking and Rest are better choice for complex queries. GraphQL use cases are multiple microservices, mobile apps and Rest are simple apps, resource-driven apps.
GraphQL is gaining popularity because of its ability to develop APIs more efficiently, powerful, and flexible as compared to REST. We all know REST is the traditional method to work with APIs but after the launch of GraphQL in 2015 it has really taken off with developers.
This question is primarily opinion-based.
But from my experience: Multiple requests on a RESTful-API for just one thing often indicates a lack in the API design, namely the needed resource was not available and therefore stuff needs to be gathered from different resources to compensate for this.
A REST-API that could be easily replaced by GraphQL indicates, that the API was in fact a CRUD-HTTP-API, what is considered an Anti-Pattern among REST-Evangelists.
Also worth noting is, that GraphQL puts responsibilty on the client, because the backing API is reduced to be a datastore that just needs to be queried. REST on the other hand enforces the behaviour of the client and therefore reduces responsibility on it. The client gets reduced to be something similar to a browser.
There are cases the one or the other approach would yield better results, but that greatly depends on your situation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With