|
| 1 | +starwarsSchema: &starwarsSchema | |
| 2 | + """Starwars schema""" |
| 3 | + schema { |
| 4 | + query: Query |
| 5 | + } |
| 6 | + |
| 7 | + "One of the films in the Star Wars Trilogy" |
| 8 | + enum Episode { |
| 9 | + "Released in 1977." |
| 10 | + NEW_HOPE |
| 11 | + "Released in 1980." |
| 12 | + EMPIRE |
| 13 | + "Released in 1983." |
| 14 | + JEDI |
| 15 | + } |
| 16 | + |
| 17 | + "A character in the Star Wars Trilogy" |
| 18 | + interface Character { |
| 19 | + "The id of the character." |
| 20 | + id: String! |
| 21 | + "The name of the character." |
| 22 | + name: String |
| 23 | + "The friends of the character, or an empty list if they have none." |
| 24 | + friends: [Character] |
| 25 | + "Which movies they appear in." |
| 26 | + appearsIn: [Episode] |
| 27 | + "All secrets about their past." |
| 28 | + secretBackstory: String |
| 29 | + } |
| 30 | + |
| 31 | + "A humanoid creature in the Star Wars universe." |
| 32 | + type Human implements Character { |
| 33 | + "The id of the human." |
| 34 | + id: String! |
| 35 | + "The name of the human." |
| 36 | + name: String |
| 37 | + "The friends of the human, or an empty list if they have none." |
| 38 | + friends: [Character] |
| 39 | + "Which movies they appear in." |
| 40 | + appearsIn: [Episode] |
| 41 | + "The home planet of the human, or null if unknown." |
| 42 | + homePlanet: String |
| 43 | + "Where are they from and how they came to be who they are." |
| 44 | + secretBackstory: String |
| 45 | + } |
| 46 | + |
| 47 | + "A mechanical creature in the Star Wars universe." |
| 48 | + type Droid implements Character { |
| 49 | + "The id of the droid." |
| 50 | + id: String! |
| 51 | + "The name of the droid." |
| 52 | + name: String |
| 53 | + "The friends of the droid, or an empty list if they have none." |
| 54 | + friends: [Character] |
| 55 | + "Which movies they appear in." |
| 56 | + appearsIn: [Episode] |
| 57 | + "Construction date and the name of the designer." |
| 58 | + secretBackstory: String |
| 59 | + "The primary function of the droid." |
| 60 | + primaryFunction: String |
| 61 | + } |
| 62 | + type Query { |
| 63 | + hero( |
| 64 | + """ |
| 65 | + If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode. |
| 66 | + """ |
| 67 | + episode: Episode |
| 68 | + ): Character |
| 69 | + |
| 70 | + human( |
| 71 | + """ |
| 72 | + id of the human |
| 73 | + """ |
| 74 | + id: String! |
| 75 | + ): Human |
| 76 | + |
| 77 | + droid( |
| 78 | + """ |
| 79 | + id of the droid |
| 80 | + """ |
| 81 | + id: String! |
| 82 | + ): Droid |
| 83 | + } |
| 84 | + |
| 85 | +tests: |
| 86 | + Basic Introspection: |
| 87 | + - name: querying the schema for types |
| 88 | + schema: *starwarsSchema |
| 89 | + query: | |
| 90 | + { |
| 91 | + __schema { |
| 92 | + types { |
| 93 | + name |
| 94 | + } |
| 95 | + } |
| 96 | + } |
| 97 | + json: | |
| 98 | + {"__schema":{"types":[{"name":"Boolean"},{"name":"Character"},{"name":"Droid"},{"name":"Episode"},{"name":"Float"},{"name":"Human"},{"name":"ID"},{"name":"Int"},{"name":"Query"},{"name":"String"},{"name":"__Directive"},{"name":"__DirectiveLocation"},{"name":"__EnumValue"},{"name":"__Field"},{"name":"__InputValue"},{"name":"__Schema"},{"name":"__Type"},{"name":"__TypeKind"}]}} |
| 99 | +
|
| 100 | + - name: querying the schema for query type |
| 101 | + schema: *starwarsSchema |
| 102 | + query: | |
| 103 | + { |
| 104 | + __schema { |
| 105 | + queryType { |
| 106 | + name |
| 107 | + } |
| 108 | + } |
| 109 | + } |
| 110 | + json: | |
| 111 | + {"__schema":{"queryType":{"name":"Query"}}} |
| 112 | +
|
| 113 | + - name: querying the schema for a specific type |
| 114 | + schema: *starwarsSchema |
| 115 | + query: | |
| 116 | + { |
| 117 | + __type(name: "Droid") { |
| 118 | + name |
| 119 | + } |
| 120 | + } |
| 121 | + json: | |
| 122 | + {"__type":{"name":"Droid"}} |
| 123 | +
|
| 124 | + - name: querying the schema for an object kind |
| 125 | + schema: *starwarsSchema |
| 126 | + query: | |
| 127 | + { |
| 128 | + __type(name: "Droid") { |
| 129 | + name |
| 130 | + kind |
| 131 | + } |
| 132 | + } |
| 133 | + json: | |
| 134 | + {"__type":{"name":"Droid","kind":"OBJECT"}} |
| 135 | +
|
| 136 | + - name: querying the schema for an interface kind |
| 137 | + schema: *starwarsSchema |
| 138 | + query: | |
| 139 | + { |
| 140 | + __type(name: "Character") { |
| 141 | + name |
| 142 | + kind |
| 143 | + } |
| 144 | + } |
| 145 | + json: | |
| 146 | + {"__type":{"name":"Character","kind":"INTERFACE"}} |
| 147 | +
|
| 148 | + - name: querying the schema for object fields |
| 149 | + schema: *starwarsSchema |
| 150 | + query: | |
| 151 | + { |
| 152 | + __type(name: "Droid") { |
| 153 | + name |
| 154 | + fields { |
| 155 | + name |
| 156 | + type { |
| 157 | + name |
| 158 | + kind |
| 159 | + } |
| 160 | + } |
| 161 | + } |
| 162 | + } |
| 163 | + json: | |
| 164 | + {"__type":{"name":"Droid","fields":[{"name":"id","type":{"name":null,"kind":"NON_NULL"}},{"name":"name","type":{"name":"String","kind":"SCALAR"}},{"name":"friends","type":{"name":null,"kind":"LIST"}},{"name":"appearsIn","type":{"name":null,"kind":"LIST"}},{"name":"secretBackstory","type":{"name":"String","kind":"SCALAR"}},{"name":"primaryFunction","type":{"name":"String","kind":"SCALAR"}}]}} |
| 165 | +
|
| 166 | + - name: querying the schema for nested object fields |
| 167 | + schema: *starwarsSchema |
| 168 | + query: | |
| 169 | + { |
| 170 | + __type(name: "Droid") { |
| 171 | + name |
| 172 | + fields { |
| 173 | + name |
| 174 | + type { |
| 175 | + name |
| 176 | + kind |
| 177 | + ofType { |
| 178 | + name |
| 179 | + kind |
| 180 | + } |
| 181 | + } |
| 182 | + } |
| 183 | + } |
| 184 | + } |
| 185 | + json: | |
| 186 | + {"__type":{"name":"Droid","fields":[{"name":"id","type":{"name":null,"kind":"NON_NULL","ofType":{"name":"String","kind":"SCALAR"}}},{"name":"name","type":{"name":"String","kind":"SCALAR","ofType":null}},{"name":"friends","type":{"name":null,"kind":"LIST","ofType":{"name":"Character","kind":"INTERFACE"}}},{"name":"appearsIn","type":{"name":null,"kind":"LIST","ofType":{"name":"Episode","kind":"ENUM"}}},{"name":"secretBackstory","type":{"name":"String","kind":"SCALAR","ofType":null}},{"name":"primaryFunction","type":{"name":"String","kind":"SCALAR","ofType":null}}]}} |
| 187 | +
|
| 188 | + - name: querying the schema for field args |
| 189 | + schema: *starwarsSchema |
| 190 | + query: | |
| 191 | + { |
| 192 | + __schema { |
| 193 | + queryType { |
| 194 | + fields { |
| 195 | + name |
| 196 | + args { |
| 197 | + name |
| 198 | + description |
| 199 | + type { |
| 200 | + name |
| 201 | + kind |
| 202 | + ofType { |
| 203 | + name |
| 204 | + kind |
| 205 | + } |
| 206 | + } |
| 207 | + defaultValue |
| 208 | + } |
| 209 | + } |
| 210 | + } |
| 211 | + } |
| 212 | + } |
| 213 | + json: | |
| 214 | + {"__schema":{"queryType":{"fields":[{"name":"hero","args":[{"defaultValue":null,"description":"If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode.","name":"episode","type":{"kind":"ENUM","name":"Episode","ofType":null}}]},{"name":"human","args":[{"name":"id","description":"id of the human","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String"}},"defaultValue":null}]},{"name":"droid","args":[{"name":"id","description":"id of the droid","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String"}},"defaultValue":null}]}]}}} |
| 215 | +
|
| 216 | + - name: querying the schema for documentation |
| 217 | + schema: *starwarsSchema |
| 218 | + query: | |
| 219 | + { |
| 220 | + __type(name: "Droid") { |
| 221 | + name |
| 222 | + description |
| 223 | + } |
| 224 | + } |
| 225 | + json: | |
| 226 | + {"__type":{"name":"Droid","description":"A mechanical creature in the Star Wars universe."}} |
0 commit comments