Skip to content

Commit

Permalink
docs: fix null type descriptions in Introspection docs
Browse files Browse the repository at this point in the history
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
  • Loading branch information
reillylm committed Jul 17, 2023
1 parent 51db38b commit ef458af
Showing 1 changed file with 147 additions and 49 deletions.
196 changes: 147 additions & 49 deletions src/components/Marked/swapiSchema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ const typeDefs = /* GraphQL */ `
mutation: Mutation
}
# The query type, represents all of the entry points into our object graph
"""
The query type, represents all of the entry points into our object graph
"""
type Query {
hero(episode: Episode): Character
reviews(episode: Episode!): [Review]
Expand All @@ -38,155 +40,251 @@ const typeDefs = /* GraphQL */ `
starship(id: ID!): Starship
}
# The mutation type, represents all updates we can make to our data
"""
The mutation type, represents all updates we can make to our data
"""
type Mutation {
createReview(episode: Episode, review: ReviewInput!): Review
}
# The episodes in the Star Wars trilogy
"""
The episodes in the Star Wars trilogy
"""
enum Episode {
# Star Wars Episode IV: A New Hope, released in 1977.
"""
Star Wars Episode IV: A New Hope, released in 1977.
"""
NEWHOPE
# Star Wars Episode V: The Empire Strikes Back, released in 1980.
"""
Star Wars Episode V: The Empire Strikes Back, released in 1980.
"""
EMPIRE
# Star Wars Episode VI: Return of the Jedi, released in 1983.
"""
Star Wars Episode VI: Return of the Jedi, released in 1983.
"""
JEDI
}
# A character from the Star Wars universe
"""
A character from the Star Wars universe
"""
interface Character {
# The ID of the character
"""
The ID of the character
"""
id: ID!
# The name of the character
"""
The name of the character
"""
name: String!
# The friends of the character, or an empty list if they have none
"""
The friends of the character, or an empty list if they have none
"""
friends: [Character]
# The friends of the character exposed as a connection with edges
"""
The friends of the character exposed as a connection with edges
"""
friendsConnection(first: Int, after: ID): FriendsConnection!
# The movies this character appears in
"""
The movies this character appears in
"""
appearsIn: [Episode]!
}
# Units of height
"""
Units of height
"""
enum LengthUnit {
# The standard unit around the world
"""
The standard unit around the world
"""
METER
# Primarily used in the United States
"""
Primarily used in the United States
"""
FOOT
}
# A humanoid creature from the Star Wars universe
"""
A humanoid creature from the Star Wars universe
"""
type Human implements Character {
# The ID of the human
"""
The ID of the human
"""
id: ID!
# What this human calls themselves
"""
What this human calls themselves
"""
name: String!
# Height in the preferred unit, default is meters
"""
Height in the preferred unit, default is meters
"""
height(unit: LengthUnit = METER): Float
# Mass in kilograms, or null if unknown
"""
Mass in kilograms, or null if unknown
"""
mass: Float
# This human's friends, or an empty list if they have none
"""
This human's friends, or an empty list if they have none
"""
friends: [Character]
# The friends of the human exposed as a connection with edges
"""
The friends of the human exposed as a connection with edges
"""
friendsConnection(first: Int, after: ID): FriendsConnection!
# The movies this human appears in
"""
The movies this human appears in
"""
appearsIn: [Episode]!
# A list of starships this person has piloted, or an empty list if none
"""
A list of starships this person has piloted, or an empty list if none
"""
starships: [Starship]
}
# An autonomous mechanical character in the Star Wars universe
"""
An autonomous mechanical character in the Star Wars universe
"""
type Droid implements Character {
# The ID of the droid
"""
The ID of the droid
"""
id: ID!
# What others call this droid
"""
What others call this droid
"""
name: String!
# This droid's friends, or an empty list if they have none
"""
This droid's friends, or an empty list if they have none
"""
friends: [Character]
# The friends of the droid exposed as a connection with edges
"""
The friends of the droid exposed as a connection with edges
"""
friendsConnection(first: Int, after: ID): FriendsConnection!
# The movies this droid appears in
"""
The movies this droid appears in
"""
appearsIn: [Episode]!
# This droid's primary function
"""
This droid's primary function
"""
primaryFunction: String
}
# A connection object for a character's friends
"""
A connection object for a character's friends
"""
type FriendsConnection {
# The total number of friends
"""
The total number of friends
"""
totalCount: Int
# The edges for each of the character's friends.
"""
The edges for each of the character's friends.
"""
edges: [FriendsEdge]
# A list of the friends, as a convenience when edges are not needed.
"""
A list of the friends, as a convenience when edges are not needed.
"""
friends: [Character]
# Information for paginating this connection
"""
Information for paginating this connection
"""
pageInfo: PageInfo!
}
# An edge object for a character's friends
"""
An edge object for a character's friends
"""
type FriendsEdge {
# A cursor used for pagination
"""
A cursor used for pagination
"""
cursor: ID!
# The character represented by this friendship edge
"""
The character represented by this friendship edge
"""
node: Character
}
# Information for paginating this connection
"""
Information for paginating this connection
"""
type PageInfo {
startCursor: ID
endCursor: ID
hasNextPage: Boolean!
}
# Represents a review for a movie
"""
Represents a review for a movie
"""
type Review {
# The number of stars this review gave, 1-5
"""
The number of stars this review gave, 1-5
"""
stars: Int!
# Comment about the movie
"""
Comment about the movie
"""
commentary: String
}
# The input object sent when someone is creating a new review
"""
The input object sent when someone is creating a new review
"""
input ReviewInput {
# 0-5 stars
"""
0-5 stars
"""
stars: Int!
# Comment about the movie, optional
"""
Comment about the movie, optional
"""
commentary: String
}
type Starship {
# The ID of the starship
"""
The ID of the starship
"""
id: ID!
# The name of the starship
"""
The name of the starship
"""
name: String!
# Length of the starship, along the longest axis
"""
Length of the starship, along the longest axis
"""
length(unit: LengthUnit = METER): Float
}
Expand Down

0 comments on commit ef458af

Please sign in to comment.