Implementing GraphQL mutations
As per the GraphQL schema, you are going to implement two mutations – addTag and addQuantity.
The addTag mutation takes productId and a collection of tags as arguments and returns the Product object. The addQuantity mutation takes productId and the quantity to add and returns Product.
Let’s add this implementation to the existing ProductDatafetcher class as shown in the following code block:
// rest of the ProductDatafetcher class code@DgsMutation(field = MUTATION.AddTag)
public Product addTags(
@InputArgument("productId") String productId,
@InputArgument(value = "tags", collectionType =
TagInput.class) List<TagInput> tags) {
return tagService.addTags(productId, tags);
}
@DgsMutation(field = MUTATION.AddQuantity)
public Product addQuantity(
@InputArgument...