Dex Docs

Nested Query Types

Nested Query Types

Some fields that can be requested can only be queried when they're nested inside of a base query.

All code snippet examples purposely query few fields for brevity's sake. For a more hands visual of the query outputs, head on over to the GraphQL Playground!

Fields for the Pokemon type

DexEntry

When querying for a Pokemon type, requesting the field pokedex_entries returns an array of DexEntry objects.

Field NameArgumentsReturn typeDescription
description--StringReturns the Pokédex entry for the requested Pokémon
game--GameReturns a Game type for the game that this Pokédex entry is from

Example

query
1{
2 pokemon(id: 4) {
3 name
4 pokedex_entries {
5 description
6 }
7 }
8}
result
1{
2 "data": {
3 "pokemon": {
4 "name": "charmander",
5 "pokedex_entries": [
6 {
7 "description": "Obviously prefers hot places. When it rains, steam is said to spout from the tip of its tail."
8 }
9 ]
10 }
11 }
12}

Dominant_Color

When querying for a Pokemon type, requesting the field dominant_color returns a Dominant_Color object.The dominant color is computed using the ColorThief library and the official artwork images of the Pokémon.

Field NameArgumentsReturn typeDescription
original--StringReturns a string of the rgb value of the Pokémon's dominant color (i.e. "rgb(232, 208, 217)")
light--StringReturns a string of a lightened hex code version of the original color value (i.e. "#ffffff")
dark--StringReturns a string of a darkened hex code version of the original color value (i.e. "#ac949d")
r--IntegerReturns an integer of the r color value of the original rgb color
g--IntegerReturns an integer of the g color value of the original rgb color
b--IntegerReturns an integer of the b color value of the original rgb color

Example

query
1{
2 pokemon(id: 4) {
3 name
4 dominant_color {
5 original
6 light
7 dark
8 r
9 g
10 b
11 }
12 }
13}
result
1{
2 "data": {
3 "pokemon": {
4 "name": "pyroar",
5 "dominant_color": {
6 "original": "rgb(214, 169, 90)",
7 "light": "#ffe596",
8 "dark": "#9a6d1e",
9 "r": 214,
10 "g": 169,
11 "b": 90
12 }
13 }
14 }
15}

EvolutionCriteria

When querying for a Pokemon type, requesting the field evolution_criteria returns an EvolutionCriteria object. EvolutionCriteria is a union of the following different types:

See Fields for the EvolutionCriteria type for more details.

Stats

When querying for a Pokemon type, requesting the field base_stats returns a Stats object.

Field NameArgumentsReturn typeDescription
hp--IntegerReturns the base hp stat of the Pokémon
attack--IntegerReturns the base attack stat of the Pokémon
defense--IntegerReturns the base defense stat of the Pokémon
special_attack--IntegerReturns the base special attack stat of the Pokémon
special_defense--IntegerReturns the base special defense stat of the Pokémon
speed--IntegerReturns the base speed stat of the Pokémon

Example

query
1{
2 pokemon(id: 4) {
3 name
4 base_stats {
5 hp
6 attack
7 defense
8 special_attack
9 special_defense
10 speed
11 }
12 }
13}
result
1{
2 "data": {
3 "pokemon": {
4 "name": "dragonair",
5 "base_stats": {
6 "hp": 61,
7 "attack": 84,
8 "defense": 65,
9 "special_attack": 70,
10 "special_defense": 70,
11 "speed": 70
12 }
13 }
14 }
15}

Fields for the Move type

MoveLearnMethod

When querying for a Pokemon type and requesting the field moves, requesting the field learn_methods returns an array of MoveLearnMethod objects.

Field NameArgumentsReturn typeDescription
method--StringReturns the name of the method by which the Pokémon learns the move (i.e. machine, tutor, level-up)
level_learned_at--IntegerReturns the level the Pokémon learns the move if method is "level-up"
games--GameReturns an array of Game objects for the games in which the Pokémon learns the move

Example

query
1{
2 pokemon(id: 5) {
3 name
4 moves(game: "red") {
5 name
6 learn_methods {
7 method
8 level_learned_at
9 }
10 }
11 }
12}
result
1// shortened `moves` array shortened for brevity
2{
3 "data": {
4 "pokemon": {
5 "name": "charmeleon",
6 "moves": [
7 {
8 "name": "Mega Punch",
9 "learn_methods": [
10 {
11 "method": "machine",
12 "level_learned_at": 0
13 }
14 ]
15 },
16 {
17 "name": "Scratch",
18 "learn_methods": [
19 {
20 "method": "level-up",
21 "level_learned_at": 1
22 }
23 ]
24 }
25 ]
26 }
27 }
28}

Fields for the EvolutionCriteria type

EvolutionCriteria is a union of the following different types:

Each of these types has a field evolution_criteria_name that only has meaning for EvolutionCriteria since the information is pertinent only to the specific Pokémon that was requested. Gender and OtherEvolutionCriteria are types that are only used in an EvolutionCriteria query. The rest can also be retrieved with a base query and have been excluded here.

Gender

Field NameArgumentsReturn typeDescription
id--StringReturns the id of the gender
name--StringReturns the name of the gender
evolution_criteria_name--StringReturns the name of the evolution criteria that must be met for the Pokémon to evolve

OtherEvolutionCriteria

Field NameArgumentsReturn typeDescription
value--StringReturns the evolution criteria value (i.e. "night" if it must be nighttime for the Pokémon to evolve)
evolution_criteria_name--StringReturns the name of the evolution criteria that must be met for the Pokémon to evolve (i.e. "time_of_day" if there is a certain time of day that the Pokémon needs to evolve during)

Example

The structure for the EvolutionCriteria query is a bit different since it is a union. We used a union here because depending on the Pokémon, their criteria for evolving are very different. For example, with the Eevee line, Vaporeon needs an item, Sylveon needs to know a Fairy type move, and Glaceon needs to be at a location with an Icy Rock. To handle all of these differences, we used a union to take advantage of the different types we had already created.

query
1{
2 pokemon(id: 4) {
3 name
4 evolution_criteria {
5 ... on Move {
6 evolution_criteria_name
7 name
8 }
9 ... on Item {
10 id
11 evolution_criteria_name
12 name
13 }
14 ... on Type {
15 evolution_criteria_name
16 name
17 }
18 ... on Location {
19 evolution_criteria_name
20 name
21 }
22 ... on Gender {
23 evolution_criteria_name
24 name
25 }
26 ... on OtherEvolutionCriteria {
27 evolution_criteria_name
28 value
29 }
30 }
31 }
32}
result
1{
2 "data": {
3 "pokemon": {
4 "name": "sylveon",
5 "evolution_criteria": [
6 {
7 "evolution_criteria_name": "min_affection",
8 "value": "2"
9 },
10 {
11 "evolution_criteria_name": "known_move_type",
12 "name": "Fairy"
13 }
14 ]
15 }
16 }
17}
Edit this page on GitHub