Skip to content

Commit fddcb50

Browse files
committed
Add more mutations for Learn docs.
1 parent f7e425d commit fddcb50

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/components/marked/swapi-schema.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ const typeDefs = /* GraphQL */ `
3131
# The mutation type, represents all updates we can make to our data
3232
type Mutation {
3333
createReview(episode: Episode, review: ReviewInput!): Review
34+
updateHumanName(id: ID!, name: String!): Human
35+
deleteStarship(id: ID!): ID
3436
}
3537
3638
# The episodes in the Star Wars trilogy
@@ -365,6 +367,20 @@ const resolvers = {
365367
},
366368
Mutation: {
367369
createReview: (root, { episode, review }) => review,
370+
updateHumanName: (root, { id, name }) => {
371+
const human = humanData[id]
372+
if (!human) {
373+
throw new Error("Human not found")
374+
}
375+
return { ...human, name }
376+
},
377+
deleteStarship: (root, { id }) => {
378+
const starship = getStarship(id)
379+
if (!starship) {
380+
throw new Error("Starship not found")
381+
}
382+
return id
383+
},
368384
},
369385
Character: {
370386
__resolveType(data, context, info) {

0 commit comments

Comments
 (0)