Challenge 1: Write an updatePost Mutation — Possible Solution ==================================================================== // Schema input UpdatePostInput { id: ID! title: String } type Mutation { createPost(input: CreatePostInput!): Post! updatePost(input: UpdatePostInput!): Post! } // Resolver Mutation: { createPost: (parent, args, context) => { return db.posts.create({ title: args.input.title, authorId: args.input.authorId, }); }, updatePost: (parent, args, context) => { return db.posts.update(args.input.id, { title: args.input.title, }); }, } WHY THIS WORKS -------------- - UpdatePostInput requires id: ID! (non-null) because there is no reasonable way to update a post without knowing WHICH post to update — but title: String is left nullable/optional, since a real update operation typically only needs to change SOME fields, not require the client to resend every field on every update. This mirrors a common, practical pattern: required identifier, optional fields to change. - updatePost follows the exact same structural pattern as createPost from the chapter — an input type wrapping the arguments, a Mutation field taking that input type as its sole argument, and a resolver reading args.input.* to perform the actual write — the only real difference is which underlying database operation it calls (update vs create) and which fields the input type actually needs. - Returning Post! (not just a Boolean) follows the chapter's "return the updated object" convention directly — a client calling updatePost can immediately query the post's current title (or any other Post field) in the same round trip, exactly as the chapter's createPost example demonstrated for a newly created post. - db.posts.update(args.input.id, { title: args.input.title }) uses args.input.id specifically to identify WHICH record to modify — this is the id the UPDATE operation needs, which is exactly why it was made a required (non-null) field on the input type, unlike title.