docs: add two gql examples

This commit is contained in:
Alessandro Pezzè 2021-04-10 21:02:28 +02:00
parent 72dcb019f2
commit d74edcc0b6
4 changed files with 56 additions and 1 deletions

View file

@ -0,0 +1,5 @@
# GraphQL examples
You can use all the `.gql` examples in our console at https://beta.pokeapi.co/graphql/console/.
Inside the folders you find GraphQL queries implemented in different languages, frameworks and libraries.

View file

@ -3,7 +3,7 @@ Finds Pokemons in Alola that evolve when you are in a particular location.
Variables:
{
"region": "alola"
"region": "alola"
}
"""

View file

@ -0,0 +1,27 @@
# for each language, list all items and the relative English translation
query getItemsTranslation1 {
pokemon_v2_language {
name
iso639
iso3166
items: pokemon_v2_itemnames {
name
englishName: pokemon_v2_item {
name
}
}
}
}
# for each item, show the English name and get all it's translations
query getItemsTranslation2 {
items: pokemon_v2_item {
name
translations: pokemon_v2_itemnames {
foreignName: name
language: pokemon_v2_language {
name
}
}
}
}

View file

@ -0,0 +1,23 @@
query tallest {
pokemon: pokemon_v2_pokemon(order_by: {height: desc}, limit: 3, where: {is_default: {_eq: true}}) {
name
height
}
}
query fattest {
pokemon: pokemon_v2_pokemon(order_by: {weight: desc}, limit: 3, where: {is_default: {_eq: true}}) {
name
weight
}
}
query avgHappiness {
species: pokemon_v2_pokemonspecies_aggregate {
aggregate {
avg {
base_happiness
}
}
}
}