Skip to content

Commit 5665e3c

Browse files
committed
refactor: move to separate directory
1 parent 550b0d8 commit 5665e3c

373 files changed

Lines changed: 5111 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
File renamed without changes.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""
2+
Finds Pokemons in Alola that evolve when you are in a particular location.
3+
4+
Variables:
5+
{
6+
"region": "alola"
7+
}
8+
"""
9+
10+
query location_evolutions_in_alola($region: String) {
11+
region: pokemon_v2_region(where: {name: {_eq: $region}}) {
12+
name
13+
location: pokemon_v2_locations_aggregate(where: {pokemon_v2_pokemonevolutions: {id: {_is_null: false}}}) {
14+
nodes {
15+
name
16+
evolutions: pokemon_v2_pokemonevolutions_aggregate {
17+
nodes {
18+
species: pokemon_v2_pokemonspecy {
19+
name
20+
}
21+
}
22+
}
23+
}
24+
}
25+
}
26+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""
2+
Returns the strongest 3 grass and poison pokemon. It uses thier stats to compute their strenght.
3+
"""
4+
5+
query best_grass_poison_pokemons {
6+
pokemon: pokemon_v2_pokemon(
7+
where: {
8+
_and: [
9+
{
10+
pokemon_v2_pokemontypes: {
11+
pokemon_v2_type: { name: { _eq: "grass" } }
12+
}
13+
}
14+
{
15+
pokemon_v2_pokemontypes: {
16+
pokemon_v2_type: { name: { _eq: "poison" } }
17+
}
18+
}
19+
]
20+
}
21+
order_by: {
22+
pokemon_v2_pokemonstats_aggregate: { sum: { base_stat: desc } }
23+
}
24+
limit: 3
25+
) {
26+
name
27+
stats: pokemon_v2_pokemonstats_aggregate(order_by: {}) {
28+
aggregate {
29+
sum {
30+
base_stat
31+
}
32+
}
33+
}
34+
}
35+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
query samplePokeAPIquery {
2+
# Gets all the pokemon belonging to generation 3
3+
gen3_species: pokemon_v2_pokemonspecies(where: {pokemon_v2_generation: {name: {_eq: "generation-iii"}}}, order_by: {id: asc}) {
4+
name
5+
id
6+
}
7+
# You can run multiple queries at the same time
8+
# Counts how many pokemon where release for each generation
9+
generations: pokemon_v2_generation {
10+
name
11+
pokemon_species: pokemon_v2_pokemonspecies_aggregate {
12+
aggregate {
13+
count
14+
}
15+
}
16+
}
17+
}
File renamed without changes.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
package main
2+
3+
import (
4+
"bytes"
5+
"encoding/json"
6+
"fmt"
7+
"io/ioutil"
8+
"log"
9+
"net/http"
10+
)
11+
12+
type Operation struct {
13+
Query string `json:"query"`
14+
Variables map[string]interface{} `json:"variables"`
15+
OperationName string `json:"operationName"`
16+
}
17+
18+
var (
19+
pokemonDetails = Operation{
20+
OperationName: "pokemon_details",
21+
Variables: map[string]interface{}{
22+
"name": "staryu",
23+
},
24+
Query: `
25+
query pokemon_details($name: String) {
26+
species: pokemon_v2_pokemonspecies(where: {name: {_eq: $name}}) {
27+
name
28+
base_happiness
29+
is_legendary
30+
is_mythical
31+
generation: pokemon_v2_generation {
32+
name
33+
}
34+
habitat: pokemon_v2_pokemonhabitat {
35+
name
36+
}
37+
pokemon: pokemon_v2_pokemons_aggregate(limit: 1) {
38+
nodes {
39+
height
40+
name
41+
id
42+
weight
43+
abilities: pokemon_v2_pokemonabilities_aggregate {
44+
nodes {
45+
ability: pokemon_v2_ability {
46+
name
47+
}
48+
}
49+
}
50+
stats: pokemon_v2_pokemonstats {
51+
base_stat
52+
stat: pokemon_v2_stat {
53+
name
54+
}
55+
}
56+
types: pokemon_v2_pokemontypes {
57+
slot
58+
type: pokemon_v2_type {
59+
name
60+
}
61+
}
62+
levelUpMoves: pokemon_v2_pokemonmoves_aggregate(where: {pokemon_v2_movelearnmethod: {name: {_eq: "level-up"}}}, distinct_on: move_id) {
63+
nodes {
64+
move: pokemon_v2_move {
65+
name
66+
}
67+
level
68+
}
69+
}
70+
foundInAsManyPlaces: pokemon_v2_encounters_aggregate {
71+
aggregate {
72+
count
73+
}
74+
}
75+
fireRedItems: pokemon_v2_pokemonitems(where: {pokemon_v2_version: {name: {_eq: "firered"}}}) {
76+
pokemon_v2_item {
77+
name
78+
cost
79+
}
80+
rarity
81+
}
82+
}
83+
}
84+
flavorText: pokemon_v2_pokemonspeciesflavortexts(where: {pokemon_v2_language: {name: {_eq: "en"}}, pokemon_v2_version: {name: {_eq: "firered"}}}) {
85+
flavor_text
86+
}
87+
}
88+
}
89+
`,
90+
}
91+
)
92+
93+
func main() {
94+
url := "https://beta.pokeapi.co/graphql/v1beta"
95+
body, err := json.Marshal(pokemonDetails)
96+
if err != nil {
97+
log.Fatal(err)
98+
}
99+
100+
resp, err := http.Post(url, "", bytes.NewReader(body))
101+
if err != nil {
102+
log.Fatal(err)
103+
}
104+
defer resp.Body.Close()
105+
body, err = ioutil.ReadAll(resp.Body)
106+
if err != nil {
107+
log.Fatal(err)
108+
}
109+
fmt.Println(string(body))
110+
}
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 its 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+
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)