This is a fairly broad question, but I will try to answer my own experience.
REST provides access to a specific resource, for example. user or product. The query result may be an assumption about what data you want or use, i.e. Probably all about this resource, regardless of whether you use all the data or not.
There is also the problem of N + 1. As an example, we take that the user has and belongs to many scenarios of relations; with the RESTful API you should make a request to the user, for example. /users/:id then query all of their relationships, e.g. /users/:id/relationships , so there are already two requests. It can be assumed that the relationship endpoint should include both the relationship (friend, family member, etc.) and the user in the resulting array, but if the API does not make this assumption, you will need to query each user endpoint to receive data for each user in every respect.
This example may go deeper; What if you want all the relationships of the second level (for example, friends of friends)?
GraphQL solves this by letting you specifically ask what you need. You can build a query to return data to depth:
query myQuery($userId: ID!) { user(id: $userID) { id name relationships { id type user { id name relationships { id type user { id name } } } } } }
Fragments can clean this up a bit and there may be recursive problems, but you should get this idea; one request will deliver you all the nested data that you need.
Unless you have a great need for such nested or interconnected result sets, GraphQL may not offer many advantages between advantages and complexity.
However, one of the biggest advantages that I have found with GraphQL is its extensibility and self-documentation.
Marc greenstock
source share