After learning about Graphql, I have understood that it has many advantages over Rest API, one of which most commonly mentioned is to do with convenience.
But does Graphql actually offer any performance increase over Rest API though?
This is a very general question, and therefor the general answer - it depends.
It depends on your use case, if you have nested objects that require multiple calls in a 'standard' REST architecture like @RAVI_SINGH answered, than yes, graphql can decrease the number of calls requires and thus increased performance. But this really depends on your use case.
On the other hand, if you don't have such cases, and don't need the 'power to the client' capabilities graphql provides, than you do pay something in performance, when doing all the selection set calculation for example.
So like almost everything, there's good and bad in graphql, and it can improve the performance or not, depending on your model and how you implement and use it
Yup definitely. If you just google GraphQL vs. REST you will get many answers but I will give you one example which will explain everything.
Let’s suppose you want to get some books' details with their respective reviews from your REST server which has separate endpoints -- for example, /books and /reviews
/reviews endpoint. This way you end up making n+1 calls.Using Data Loader you can optimize your GraphQL server even more.
Refer to this link to learn more.
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