Instructor: 00:01 I want to update the product by ID. Let's create the mutation to update the product. It will accept the input argument. The type of the input is product input, and it will return a new product.
00:15 Also, need ID in the argument because I want to update the product by ID. The type of the ID is ID. ID is required field.
00:26 Let's create the resolver. Update product and I don't have any root object here. I want to de-structure the ID and input. I am going to use findOneAndUpdate method. Product model has this method -- findOneAndUpdate.
00:51 The first argument is criteria object. We need to provide the ID. Both key and value are same, so I am going to use this ID.
00:59 The second argument is input. The third argument is we need to tell MongoDB, "I want to get a new record in the response."
01:10 I am going to apply await expression. If promise will be resolved, it will return a new updated product.
01:16 Let's try to test it. Let me show you the docs. We have update product mutation.
01:23 Let's say I would like to update the name of the course, I would like to update the name of the product. We need to send the update mutation -- update product.
01:34 First argument is ID, and the second argument is input. We need to update the name.
01:40 I am going to replace the name from GraphQL to Relay course. I also want to see the ID and name in the response.
01:52 Incredible, a product has updated successfully. You can see that we have named Relay course.