Hacker News new | ask | show | jobs
by chx 2458 days ago
After https://stackoverflow.com/a/57247614/308851 I am at a complete loss of why I would I want GraphQL. A client uses it , so I obey but I do not see the point. To quote the linked answer to save you a click:

> GraphQL does not provide any built-in mechanisms for filtering, sorting, pagination or other arbitrary transformations of the response

2 comments

You wouldn't want to let people filter by an unindexed field, sort huge large result sets, or make your server store a huge result set because they stop making requests after getting the first few pages. GraphQL lets you express what is permitted, without allowing more than your underlying data store can support.

For example, from the GitHub GraphQL API you can in a single request get all open pull requests on a repository and the last 10 comments on each one. You can't get the last 10 comments on all of GitHub or the last 10 comments made by a particular user, because they haven't exposed or even stored the data that way.

In a REST API that would be dozens of separate requests, or the endpoint would just not exist because they have never had the need for that exact combination of records to be queryable.

GraphQL the language does not specify those features in a rigid way, many GraphQL implementations have those features. It's best to look at the spec as the minimum to expect not the maximum you can get from GraphQL.