...
1schema {
2 query: Query
3 mutation: Mutation
4 subscription: Subscription
5}
6
7# The query type, represents all of the entry points into our object graph
8type Query {
9 hero(episode: Episode): Character
10 reviews(episode: Episode!): [Review]
11 search(text: String): [SearchResult]
12 character(id: ID!): Character
13 droid(id: ID!): Droid
14 human(id: ID!): Human
15 starship(id: ID!): Starship
16}
17# The mutation type, represents all updates we can make to our data
18type Mutation {
19 createReview(episode: Episode, review: ReviewInput!): Review
20}
21# The subscription type, represents all subscriptions we can make to our data
22type Subscription {
23 reviewAdded(episode: Episode): Review
24}
25# The episodes in the Star Wars trilogy
26enum Episode {
27 # Star Wars Episode IV: A New Hope, released in 1977.
28 NEWHOPE
29 # Star Wars Episode V: The Empire Strikes Back, released in 1980.
30 EMPIRE
31 # Star Wars Episode VI: Return of the Jedi, released in 1983.
32 JEDI
33}
34# A character from the Star Wars universe
35interface Character {
36 # The ID of the character
37 id: ID!
38 # The name of the character
39 name: String!
40 # The friends of the character, or an empty list if they have none
41 friends: [Character]
42 # The friends of the character exposed as a connection with edges
43 friendsConnection(first: Int, after: ID): FriendsConnection!
44 # The movies this character appears in
45 appearsIn: [Episode]!
46}
47# Units of height
48enum LengthUnit {
49 # The standard unit around the world
50 METER
51 # Primarily used in the United States
52 FOOT
53}
54# A humanoid creature from the Star Wars universe
55type Human implements Character {
56 # The ID of the human
57 id: ID!
58 # What this human calls themselves
59 name: String!
60 # The home planet of the human, or null if unknown
61 homePlanet: String
62 # Height in the preferred unit, default is meters
63 height(unit: LengthUnit = METER): Float
64 # Mass in kilograms, or null if unknown
65 mass: Float
66 # This human's friends, or an empty list if they have none
67 friends: [Character]
68 # The friends of the human exposed as a connection with edges
69 friendsConnection(first: Int, after: ID): FriendsConnection!
70 # The movies this human appears in
71 appearsIn: [Episode]!
72 # A list of starships this person has piloted, or an empty list if none
73 starships: [Starship]
74}
75# An autonomous mechanical character in the Star Wars universe
76type Droid implements Character {
77 # The ID of the droid
78 id: ID!
79 # What others call this droid
80 name: String!
81 # This droid's friends, or an empty list if they have none
82 friends: [Character]
83 # The friends of the droid exposed as a connection with edges
84 friendsConnection(first: Int, after: ID): FriendsConnection!
85 # The movies this droid appears in
86 appearsIn: [Episode]!
87 # This droid's primary function
88 primaryFunction: String
89}
90# A connection object for a character's friends
91type FriendsConnection {
92 # The total number of friends
93 totalCount: Int
94 # The edges for each of the character's friends.
95 edges: [FriendsEdge]
96 # A list of the friends, as a convenience when edges are not needed.
97 friends: [Character]
98 # Information for paginating this connection
99 pageInfo: PageInfo!
100}
101# An edge object for a character's friends
102type FriendsEdge {
103 # A cursor used for pagination
104 cursor: ID!
105 # The character represented by this friendship edge
106 node: Character
107}
108# Information for paginating this connection
109type PageInfo {
110 startCursor: ID
111 endCursor: ID
112 hasNextPage: Boolean!
113}
114# Represents a review for a movie
115type Review {
116 # The movie
117 episode: Episode
118 # The number of stars this review gave, 1-5
119 stars: Int!
120 # Comment about the movie
121 commentary: String
122}
123# The input object sent when someone is creating a new review
124input ReviewInput {
125 # 0-5 stars
126 stars: Int!
127 # Comment about the movie, optional
128 commentary: String
129 # Favorite color, optional
130 favorite_color: ColorInput
131}
132# The input object sent when passing in a color
133input ColorInput {
134 red: Int!
135 green: Int!
136 blue: Int!
137}
138type Starship {
139 # The ID of the starship
140 id: ID!
141 # The name of the starship
142 name: String!
143 # Length of the starship, along the longest axis
144 length(unit: LengthUnit = METER): Float
145 coordinates: [[Float!]!]
146}
147union SearchResult = Human | Droid | Starship
View as plain text