mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-24 20:33:04 +00:00
docs: add two gql examples
This commit is contained in:
parent
72dcb019f2
commit
d74edcc0b6
4 changed files with 56 additions and 1 deletions
5
graphql/examples/README.md
Normal file
5
graphql/examples/README.md
Normal 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.
|
|
@ -3,7 +3,7 @@ Finds Pokemons in Alola that evolve when you are in a particular location.
|
|||
|
||||
Variables:
|
||||
{
|
||||
"region": "alola"
|
||||
"region": "alola"
|
||||
}
|
||||
"""
|
||||
|
||||
|
|
27
graphql/examples/item_translations.gql
Normal file
27
graphql/examples/item_translations.gql
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
23
graphql/examples/pokemon_stats.gql
Normal file
23
graphql/examples/pokemon_stats.gql
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue