The GraphQL updatePost mutation

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:

  1. There is a new mutation that we need to insert into our schema, as follows:
updatePost (  post: PostInput!  postId: Int!): Post
  1. 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({,  },  {    where: {      id: postId    }  }).then((rows) => {    if(rows[0] === 1) {      logger.log({ level: 'info', ...

Get Hands-On Full-Stack Web Development with GraphQL and React now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.