Skip to content

Commit ef458af

Browse files
committed
docs: fix null type descriptions in Introspection docs
We're currently specifying descriptions in the `StarWarsSchema` using comments, which is causing them to resolve as `null` when we run introspection queries, like in the [last example on the Introspection docs page](https://graphql.org/learn/introspection/). The [newer versions of the spec](https://spec.graphql.org/October2021/#sec-Descriptions) outline that descriptions should use a `BlockString`, so this change updates all the descriptions to use `BlockString` instead of comments. Looks like, alternatively, we could have specified `commentDescriptions` in our invocation of `makeExecutableSchema`, but we might as well make our schema consistent with the current way of specifying descriptions in the spec. Fixes graphql#1496
1 parent 51db38b commit ef458af

File tree

1 file changed

+147
-49
lines changed

1 file changed

+147
-49
lines changed

src/components/Marked/swapiSchema.tsx

+147-49
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ const typeDefs = /* GraphQL */ `
2727
mutation: Mutation
2828
}
2929
30-
# The query type, represents all of the entry points into our object graph
30+
"""
31+
The query type, represents all of the entry points into our object graph
32+
"""
3133
type Query {
3234
hero(episode: Episode): Character
3335
reviews(episode: Episode!): [Review]
@@ -38,155 +40,251 @@ const typeDefs = /* GraphQL */ `
3840
starship(id: ID!): Starship
3941
}
4042
41-
# The mutation type, represents all updates we can make to our data
43+
"""
44+
The mutation type, represents all updates we can make to our data
45+
"""
4246
type Mutation {
4347
createReview(episode: Episode, review: ReviewInput!): Review
4448
}
4549
46-
# The episodes in the Star Wars trilogy
50+
"""
51+
The episodes in the Star Wars trilogy
52+
"""
4753
enum Episode {
48-
# Star Wars Episode IV: A New Hope, released in 1977.
54+
"""
55+
Star Wars Episode IV: A New Hope, released in 1977.
56+
"""
4957
NEWHOPE
5058
51-
# Star Wars Episode V: The Empire Strikes Back, released in 1980.
59+
"""
60+
Star Wars Episode V: The Empire Strikes Back, released in 1980.
61+
"""
5262
EMPIRE
5363
54-
# Star Wars Episode VI: Return of the Jedi, released in 1983.
64+
"""
65+
Star Wars Episode VI: Return of the Jedi, released in 1983.
66+
"""
5567
JEDI
5668
}
5769
58-
# A character from the Star Wars universe
70+
"""
71+
A character from the Star Wars universe
72+
"""
5973
interface Character {
60-
# The ID of the character
74+
"""
75+
The ID of the character
76+
"""
6177
id: ID!
6278
63-
# The name of the character
79+
"""
80+
The name of the character
81+
"""
6482
name: String!
6583
66-
# The friends of the character, or an empty list if they have none
84+
"""
85+
The friends of the character, or an empty list if they have none
86+
"""
6787
friends: [Character]
6888
69-
# The friends of the character exposed as a connection with edges
89+
"""
90+
The friends of the character exposed as a connection with edges
91+
"""
7092
friendsConnection(first: Int, after: ID): FriendsConnection!
7193
72-
# The movies this character appears in
94+
"""
95+
The movies this character appears in
96+
"""
7397
appearsIn: [Episode]!
7498
}
7599
76-
# Units of height
100+
"""
101+
Units of height
102+
"""
77103
enum LengthUnit {
78-
# The standard unit around the world
104+
"""
105+
The standard unit around the world
106+
"""
79107
METER
80108
81-
# Primarily used in the United States
109+
"""
110+
Primarily used in the United States
111+
"""
82112
FOOT
83113
}
84114
85-
# A humanoid creature from the Star Wars universe
115+
"""
116+
A humanoid creature from the Star Wars universe
117+
"""
86118
type Human implements Character {
87-
# The ID of the human
119+
"""
120+
The ID of the human
121+
"""
88122
id: ID!
89123
90-
# What this human calls themselves
124+
"""
125+
What this human calls themselves
126+
"""
91127
name: String!
92128
93-
# Height in the preferred unit, default is meters
129+
"""
130+
Height in the preferred unit, default is meters
131+
"""
94132
height(unit: LengthUnit = METER): Float
95133
96-
# Mass in kilograms, or null if unknown
134+
"""
135+
Mass in kilograms, or null if unknown
136+
"""
97137
mass: Float
98138
99-
# This human's friends, or an empty list if they have none
139+
"""
140+
This human's friends, or an empty list if they have none
141+
"""
100142
friends: [Character]
101143
102-
# The friends of the human exposed as a connection with edges
144+
"""
145+
The friends of the human exposed as a connection with edges
146+
"""
103147
friendsConnection(first: Int, after: ID): FriendsConnection!
104148
105-
# The movies this human appears in
149+
"""
150+
The movies this human appears in
151+
"""
106152
appearsIn: [Episode]!
107153
108-
# A list of starships this person has piloted, or an empty list if none
154+
"""
155+
A list of starships this person has piloted, or an empty list if none
156+
"""
109157
starships: [Starship]
110158
}
111159
112-
# An autonomous mechanical character in the Star Wars universe
160+
"""
161+
An autonomous mechanical character in the Star Wars universe
162+
"""
113163
type Droid implements Character {
114-
# The ID of the droid
164+
"""
165+
The ID of the droid
166+
"""
115167
id: ID!
116168
117-
# What others call this droid
169+
"""
170+
What others call this droid
171+
"""
118172
name: String!
119173
120-
# This droid's friends, or an empty list if they have none
174+
"""
175+
This droid's friends, or an empty list if they have none
176+
"""
121177
friends: [Character]
122178
123-
# The friends of the droid exposed as a connection with edges
179+
"""
180+
The friends of the droid exposed as a connection with edges
181+
"""
124182
friendsConnection(first: Int, after: ID): FriendsConnection!
125183
126-
# The movies this droid appears in
184+
"""
185+
The movies this droid appears in
186+
"""
127187
appearsIn: [Episode]!
128188
129-
# This droid's primary function
189+
"""
190+
This droid's primary function
191+
"""
130192
primaryFunction: String
131193
}
132194
133-
# A connection object for a character's friends
195+
"""
196+
A connection object for a character's friends
197+
"""
134198
type FriendsConnection {
135-
# The total number of friends
199+
"""
200+
The total number of friends
201+
"""
136202
totalCount: Int
137203
138-
# The edges for each of the character's friends.
204+
"""
205+
The edges for each of the character's friends.
206+
"""
139207
edges: [FriendsEdge]
140208
141-
# A list of the friends, as a convenience when edges are not needed.
209+
"""
210+
A list of the friends, as a convenience when edges are not needed.
211+
"""
142212
friends: [Character]
143213
144-
# Information for paginating this connection
214+
"""
215+
Information for paginating this connection
216+
"""
145217
pageInfo: PageInfo!
146218
}
147219
148-
# An edge object for a character's friends
220+
"""
221+
An edge object for a character's friends
222+
"""
149223
type FriendsEdge {
150-
# A cursor used for pagination
224+
"""
225+
A cursor used for pagination
226+
"""
151227
cursor: ID!
152228
153-
# The character represented by this friendship edge
229+
"""
230+
The character represented by this friendship edge
231+
"""
154232
node: Character
155233
}
156234
157-
# Information for paginating this connection
235+
"""
236+
Information for paginating this connection
237+
"""
158238
type PageInfo {
159239
startCursor: ID
160240
endCursor: ID
161241
hasNextPage: Boolean!
162242
}
163243
164-
# Represents a review for a movie
244+
"""
245+
Represents a review for a movie
246+
"""
165247
type Review {
166-
# The number of stars this review gave, 1-5
248+
"""
249+
The number of stars this review gave, 1-5
250+
"""
167251
stars: Int!
168252
169-
# Comment about the movie
253+
"""
254+
Comment about the movie
255+
"""
170256
commentary: String
171257
}
172258
173-
# The input object sent when someone is creating a new review
259+
"""
260+
The input object sent when someone is creating a new review
261+
"""
174262
input ReviewInput {
175-
# 0-5 stars
263+
"""
264+
0-5 stars
265+
"""
176266
stars: Int!
177267
178-
# Comment about the movie, optional
268+
"""
269+
Comment about the movie, optional
270+
"""
179271
commentary: String
180272
}
181273
182274
type Starship {
183-
# The ID of the starship
275+
"""
276+
The ID of the starship
277+
"""
184278
id: ID!
185279
186-
# The name of the starship
280+
"""
281+
The name of the starship
282+
"""
187283
name: String!
188284
189-
# Length of the starship, along the longest axis
285+
"""
286+
Length of the starship, along the longest axis
287+
"""
190288
length(unit: LengthUnit = METER): Float
191289
}
192290

0 commit comments

Comments
 (0)