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