Complete the code to define a mutation that adds a new user with a name.
type Mutation { addUser(name: String!): [1] }The mutation must specify the return type after the colon. Here, : User means the mutation returns a User object.
Complete the mutation resolver function to update a user's name by ID.
updateUser: (parent, args, context) => { return context.db.users.[1](args.id, args.name); }The correct method to modify user data is typically called update. It updates the user with the given ID and new name.
Fix the error in the mutation resolver that tries to delete a user but returns nothing.
deleteUser: (parent, args, context) => { context.db.users.delete(args.id); return [1]; }After deleting, returning null is common to indicate no user object is returned.
Complete the code to complete the mutation that creates a post and returns its ID and title.
type Mutation { createPost(title: String!, content: String!): [1] { id, title } }The mutation returns a Post type. Inside the selection set, fields are separated by commas, so , is correct.
Fill all three blanks to write a mutation resolver that adds a comment and returns the comment text if the content length is greater than 0.
addComment: (parent, args, context) => { if (args.content.[3] [1] 0) { return { text: args.[2] }; } else { return null; } }The condition checks if args.content.length is greater than 0. Then it returns an object with the text field set to args.content.