Skip to content

Commit d729c5b

Browse files
author
Sashko Stubailo
committed
Update inline fragment docs, other fields
1 parent c460982 commit d729c5b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

site/docs/Learn-Schema.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ query {
7979
hero {
8080
name
8181
}
82-
droid(id: "2001") {
82+
droid(id: "2000") {
8383
name
8484
}
8585
}
@@ -170,7 +170,7 @@ The Non-Null type modifier can also be used when defining arguments for a field,
170170

171171
```graphql
172172
# { "graphiql": true, "variables": { "id": null } }
173-
query DroidById($id: String!) {
173+
query DroidById($id: ID!) {
174174
droid(id: $id) {
175175
name
176176
}
@@ -249,7 +249,9 @@ type Droid implements Character {
249249

250250
You can see that both of these types have all of the fields from the `Character` interface, but also bring in extra fields, `homePlanet` and `primaryFunction`, that are specific to that particular type of character.
251251

252-
Interfaces are useful when you want to return an object or set of objects, but those might be of several different types. For example, in the following query:
252+
Interfaces are useful when you want to return an object or set of objects, but those might be of several different types.
253+
254+
For example, note that the following query produces an error:
253255

254256
```graphql
255257
# { "graphiql": true, "variables": { "ep": "JEDI" } }
@@ -261,7 +263,9 @@ query HeroForEpisode($ep: Episode!) {
261263
}
262264
```
263265

264-
The `hero` field returns the type `Character`, which means it might be either a `Human` or a `Droid` depending on the `episode` argument. In the query above, you can only ask for fields that exist on the `Character` interface, and to ask for a field on a specific object type, you need to use an inline fragment:
266+
The `hero` field returns the type `Character`, which means it might be either a `Human` or a `Droid` depending on the `episode` argument. In the query above, you can only ask for fields that exist on the `Character` interface, which doesn't include `primaryFunction`.
267+
268+
To ask for a field on a specific object type, you need to use an inline fragment:
265269

266270
```graphql
267271
# { "graphiql": true, "variables": { "ep": "JEDI" } }

0 commit comments

Comments
 (0)