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 Name | Arguments | Return type | Description |
---|---|---|---|
description | -- | String | Returns the Pokédex entry for the requested Pokémon |
game | -- | Game | Returns a Game type for the game that this Pokédex entry is from |
Example
1{2 pokemon(id: 4) {3 name4 pokedex_entries {5 description6 }7 }8}
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 Name | Arguments | Return type | Description |
---|---|---|---|
original | -- | String | Returns a string of the rgb value of the Pokémon's dominant color (i.e. "rgb(232, 208, 217)") |
light | -- | String | Returns a string of a lightened hex code version of the original color value (i.e. "#ffffff") |
dark | -- | String | Returns a string of a darkened hex code version of the original color value (i.e. "#ac949d") |
r | -- | Integer | Returns an integer of the r color value of the original rgb color |
g | -- | Integer | Returns an integer of the g color value of the original rgb color |
b | -- | Integer | Returns an integer of the b color value of the original rgb color |
Example
1{2 pokemon(id: 4) {3 name4 dominant_color {5 original6 light7 dark8 r9 g10 b11 }12 }13}
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": 9012 }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 Name | Arguments | Return type | Description |
---|---|---|---|
hp | -- | Integer | Returns the base hp stat of the Pokémon |
attack | -- | Integer | Returns the base attack stat of the Pokémon |
defense | -- | Integer | Returns the base defense stat of the Pokémon |
special_attack | -- | Integer | Returns the base special attack stat of the Pokémon |
special_defense | -- | Integer | Returns the base special defense stat of the Pokémon |
speed | -- | Integer | Returns the base speed stat of the Pokémon |
Example
1{2 pokemon(id: 4) {3 name4 base_stats {5 hp6 attack7 defense8 special_attack9 special_defense10 speed11 }12 }13}
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": 7012 }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 Name | Arguments | Return type | Description |
---|---|---|---|
method | -- | String | Returns the name of the method by which the Pokémon learns the move (i.e. machine, tutor, level-up) |
level_learned_at | -- | Integer | Returns the level the Pokémon learns the move if method is "level-up" |
games | -- | Game | Returns an array of Game objects for the games in which the Pokémon learns the move |
Example
1{2 pokemon(id: 5) {3 name4 moves(game: "red") {5 name6 learn_methods {7 method8 level_learned_at9 }10 }11 }12}
1// shortened `moves` array shortened for brevity2{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": 013 }14 ]15 },16 {17 "name": "Scratch",18 "learn_methods": [19 {20 "method": "level-up",21 "level_learned_at": 122 }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 Name | Arguments | Return type | Description |
---|---|---|---|
id | -- | String | Returns the id of the gender |
name | -- | String | Returns the name of the gender |
evolution_criteria_name | -- | String | Returns the name of the evolution criteria that must be met for the Pokémon to evolve |
OtherEvolutionCriteria
Field Name | Arguments | Return type | Description |
---|---|---|---|
value | -- | String | Returns the evolution criteria value (i.e. "night" if it must be nighttime for the Pokémon to evolve) |
evolution_criteria_name | -- | String | Returns 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.
1{2 pokemon(id: 4) {3 name4 evolution_criteria {5 ... on Move {6 evolution_criteria_name7 name8 }9 ... on Item {10 id11 evolution_criteria_name12 name13 }14 ... on Type {15 evolution_criteria_name16 name17 }18 ... on Location {19 evolution_criteria_name20 name21 }22 ... on Gender {23 evolution_criteria_name24 name25 }26 ... on OtherEvolutionCriteria {27 evolution_criteria_name28 value29 }30 }31 }32}
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}