|
1 |
| -import dedent from 'dedent'; |
| 1 | +export const defaultQuery = ` |
| 2 | +# This is sample query with @_ directives which change the shape of response |
| 3 | +# Run this query to see the resutls! |
| 4 | +# More examples are hidden under Saved Queries dropdown above |
| 5 | +{ |
| 6 | + genderStats: allPeople @_(get: "people") { |
| 7 | + people @_(countBy: "gender") { |
| 8 | + gender |
| 9 | + } |
| 10 | + } |
| 11 | +}`.trim(); |
2 | 12 |
|
3 |
| -export const defaultQuery = dedent`# This is sample query with @_ directives which change the shape of response |
4 |
| - # Run this query to see the resutls! |
5 |
| - # More examples are hidden under Saved Queries dropdown above |
6 |
| - { |
7 |
| - genderStats: allPeople @_(get: "people") { |
8 |
| - people @_(countBy: "gender") { |
9 |
| - gender |
10 |
| - } |
11 |
| - } |
12 |
| - }`; |
| 13 | +const maxPopulationQuery = ` |
| 14 | +# Planet With Max Population |
| 15 | +{ |
| 16 | + planetWithMaxPopulation: allPlanets @_(get: "planets") { |
| 17 | + planets @_(maxBy: "population") { |
| 18 | + name |
| 19 | + population |
| 20 | + } |
| 21 | + } |
| 22 | +}`.trim(); |
13 | 23 |
|
14 |
| -export const savedQueries = [ |
| 24 | +const genderStatsQuery = ` |
| 25 | +# Gender Stats |
15 | 26 | {
|
16 |
| - query: dedent`# Planet With Max Population |
17 |
| - { |
18 |
| - planetWithMaxPopulation: allPlanets @_(get: "planets") { |
19 |
| - planets @_(maxBy: "population") { |
20 |
| - name |
21 |
| - population |
22 |
| - } |
23 |
| - } |
24 |
| - }`, |
25 |
| - variables: '' |
26 |
| -}, |
27 |
| - { |
28 |
| - query: dedent`# Gender Stats |
29 |
| - { |
30 |
| - genderStats: allPeople @_(get: "people") { |
31 |
| - people @_(countBy: "gender") { |
32 |
| - gender |
33 |
| - } |
34 |
| - } |
35 |
| - }`, |
36 |
| - variables: '' |
37 |
| -}, |
| 27 | + genderStats: allPeople @_(get: "people") { |
| 28 | + people @_(countBy: "gender") { |
| 29 | + gender |
| 30 | + } |
| 31 | + } |
| 32 | +}`.trim(); |
| 33 | + |
| 34 | +const mapPeopleToFilmsQuery = ` |
| 35 | +# Map People To Films |
38 | 36 | {
|
39 |
| - query: dedent`# Map People To Films |
40 |
| - { |
41 |
| - peopleToFilms: allPeople @_(get: "people") { |
42 |
| - people @_( |
43 |
| - keyBy: "name" |
44 |
| - mapValues: "filmConnection.films" |
45 |
| - ) { |
46 |
| - name |
47 |
| - filmConnection { |
48 |
| - films @_(map: "title") { |
49 |
| - title |
50 |
| - } |
51 |
| - } |
52 |
| - } |
53 |
| - } |
54 |
| - }`, |
55 |
| - variables: '' |
56 |
| -}]; |
| 37 | + peopleToFilms: allPeople @_(get: "people") { |
| 38 | + people @_( |
| 39 | + keyBy: "name" |
| 40 | + mapValues: "filmConnection.films" |
| 41 | + ) { |
| 42 | + name |
| 43 | + filmConnection { |
| 44 | + films @_(map: "title") { |
| 45 | + title |
| 46 | + } |
| 47 | + } |
| 48 | + } |
| 49 | + } |
| 50 | +}`.trim(); |
| 51 | + |
| 52 | +export const savedQueries = [ |
| 53 | + { query: maxPopulationQuery, variables: "" }, |
| 54 | + { query: genderStatsQuery, variables: "" }, |
| 55 | + { query: mapPeopleToFilmsQuery, variables: "" } |
| 56 | +]; |
0 commit comments