Skip to content

Commit d74edcc

Browse files
committed
docs: add two gql examples
1 parent 72dcb01 commit d74edcc

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

graphql/examples/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# GraphQL examples
2+
3+
You can use all the `.gql` examples in our console at https://beta.pokeapi.co/graphql/console/.
4+
5+
Inside the folders you find GraphQL queries implemented in different languages, frameworks and libraries.

graphql/examples/alola_road_encounters.gql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Finds Pokemons in Alola that evolve when you are in a particular location.
33
44
Variables:
55
{
6-
"region": "alola"
6+
"region": "alola"
77
}
88
"""
99

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# for each language, list all items and the relative English translation
2+
query getItemsTranslation1 {
3+
pokemon_v2_language {
4+
name
5+
iso639
6+
iso3166
7+
items: pokemon_v2_itemnames {
8+
name
9+
englishName: pokemon_v2_item {
10+
name
11+
}
12+
}
13+
}
14+
}
15+
16+
# for each item, show the English name and get all it's translations
17+
query getItemsTranslation2 {
18+
items: pokemon_v2_item {
19+
name
20+
translations: pokemon_v2_itemnames {
21+
foreignName: name
22+
language: pokemon_v2_language {
23+
name
24+
}
25+
}
26+
}
27+
}

graphql/examples/pokemon_stats.gql

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
query tallest {
2+
pokemon: pokemon_v2_pokemon(order_by: {height: desc}, limit: 3, where: {is_default: {_eq: true}}) {
3+
name
4+
height
5+
}
6+
}
7+
8+
query fattest {
9+
pokemon: pokemon_v2_pokemon(order_by: {weight: desc}, limit: 3, where: {is_default: {_eq: true}}) {
10+
name
11+
weight
12+
}
13+
}
14+
15+
query avgHappiness {
16+
species: pokemon_v2_pokemonspecies_aggregate {
17+
aggregate {
18+
avg {
19+
base_happiness
20+
}
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)