xxxxxxxxxx
# The query type, represents all of the entry points into our object graph
type Query {
hero(episode: Episode): Character
reviews(episode: Episode!): [Review]
search(text: String): [SearchResult]
character(id: ID!): Character
droid(id: ID!): Droid
human(id: ID!): Human
starship(id: ID!): Starship
}
# The mutation type, represents all updates we can make to our data
type Mutation {
createReview(episode: Episode, review: ReviewInput!): Review
}
# The subscription type, represents all subscriptions we can make to our data
type Subscription {
reviewAdded(episode: Episode): Review
}
# The episodes in the Star Wars trilogy
enum Episode {
# Star Wars Episode IV: A New Hope, released in 1977.
NEWHOPE
# Star Wars Episode V: The Empire Strikes Back, released in 1980.
EMPIRE
# Star Wars Episode VI: Return of the Jedi, released in 1983.
JEDI
}
xxxxxxxxxx
fragment CharacterData on Character
(
includeAppearsIn: { type: "Boolean", defaultValue: false }
) {
id
name
appearsIn (if: $includeAppearsIn)
... on Human {
homePlanet
}
... on Droid {
primaryFunction
}
}
query UserProfile {
hero {
id
...CharacterData (includeAppearsIn: true)
friends {
id
...CharacterData (includeAppearsIn: false)
}
}
}
xxxxxxxxxx
query UserProfile {
hero {
id
name
appearsIn
friends {
id
name
... on Human {
homePlanet
}
... on Droid {
primaryFunction
}
}
... on Human {
homePlanet
}
... on Droid {
primaryFunction
}
}
}