One of the advantages of GraphQL is that you can choose which parameters are returned. It is a good way to reduce the size of the data that's received from an API and speed up how it's rendered for the user. The list of available parameters is defined in the GraphQL schema; we will look at this in more detail later in this chapter. A valid query can be written like so:
{
viewer {
id
login
}
}
This query will return the id and login information of the viewer. The result of this query is the following JSON:
{
"data": {
"viewer": {
"id": "MDQ6VXNlcjEwMzU2NjE4",
"login": "stellasia"
}
}
}
This query is quite simple, especially because it doesn't involve parameters. However, most of the time, the API response depends on some parameters: the user ID, the maximum number of elements to be returned (for pagination), and so on. It is worth focusing on this feature since it...