I have built this query to request data from the Pokeapi graphQL server here https://beta.pokeapi.co/graphql/console/
query getOrderedPokemon (
$sortOrder: order_by,
) {
pokemon_v2_pokemon(
limit: 20,
order_by: {
name : $sortOrder
}
) {
id
name
height
weight
}
}
With this request, I can modify the order of returned items by changing the variable $sortOrder
to either 'asc' or 'desc'. What can I do if I want to sort the returned items by a different property, like height or weight? Do I have to create a new query?
If the server does not accept a variable for specifying which field to sort by, is it impossible to create a flexible query that can be sorted by variable properties?
From what I can tell, it does look like this server doesn't have any variables I can use to specify which field to sort by.
Thank you