Skip to content

Commit 2a1cdfd

Browse files
author
Sashko Stubailo
committed
Some updates to examples for current WIP
1 parent 2df5918 commit 2a1cdfd

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

site/docs/Learn-Schema.md

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ That means that the GraphQL service needs to have a `Query` type with `hero` and
9090
```graphql
9191
type Query {
9292
hero(episode: Episode): Character
93-
droid(id: String!): Droid
93+
droid(id: ID!): Droid
9494
}
9595
```
9696

@@ -217,7 +217,7 @@ For example, you could have an interface `Character` that represents any charact
217217

218218
```graphql
219219
interface Character {
220-
id: String!
220+
id: ID!
221221
name: String!
222222
friends: [Character]
223223
appearsIn: [Episode]!
@@ -230,15 +230,16 @@ For example, here are some types that might implement `Character`:
230230

231231
```graphql
232232
type Human implements Character {
233-
id: String!
233+
id: ID!
234234
name: String!
235235
friends: [Character]
236236
appearsIn: [Episode]!
237-
homePlanet: String
237+
starships: [Starship]
238+
totalCredits: Int
238239
}
239240

240241
type Droid implements Character {
241-
id: String!
242+
id: ID!
242243
name: String!
243244
friends: [Character]
244245
appearsIn: [Episode]!
@@ -283,17 +284,7 @@ Union types are very similar to interfaces, but they don't get to specify any co
283284
XXX no example in SWAPI
284285

285286
```graphql
286-
union SearchResult = Photo | Person
287-
288-
type Person {
289-
name: String
290-
age: Int
291-
}
292-
293-
type Photo {
294-
height: Int
295-
width: Int
296-
}
287+
union SearchResult = Character | Starship
297288
```
298289

299290
In this case, if you query a field that returns the `SearchResult` union type, you need to use a conditional fragment to be able to query any fields at all.

site/docs/_swapiSchema.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ schema {
2525
type Query {
2626
hero(episode: Episode): Character
2727
search(text: String): [SearchResult]
28+
droid(id: ID!): Droid
29+
human(id: ID!): Human
30+
starship(id: ID!): Starship
2831
}
2932
3033
type Mutation {

0 commit comments

Comments
 (0)