A mutation is always located at two points in our code. One part is written inside of our GraphQL API in the back end, and the other one is written in our front end code.
We should start with the implementation on the back end side, as follows:
- There is a new mutation that we need to insert into our schema, as follows:
updatePost ( post: PostInput! postId: Int!): Post
- Once it is inside of our schema, the implementation to execute the mutation will follow. Copy the following code over to the resolvers.js file, in the RootMutation field:
updatePost(root, { post, postId }, context) { return Post.update({ ...post, }, { where: { id: postId } }).then((rows) => { if(rows[0] === 1) { logger.log({ level: 'info', ...