Creating a custom mutation
In the previous section, you learned how to use mutation queries to create, update, and delete objects. These kinds of queries work well for simple scenarios but present some limitations in terms of the kinds of attributes that we can update or for the interdependence of multiple attributes. For example, on standard mutation queries, the QuantityValue
fields cannot be filled.
In this section, you will learn how to create a custom mutation function and how to use that to update values that cannot be updated through standard mutation queries.
To create a new custom mutation function, we need to add a function definition to the Datahub configuration schema. This can be made by implementing a listener for the pimcore.Datahub.graphql.mutation.preBuild
event.
In Chapter 12, Implementing Product Information Management, you learned how to implement an EventListener. In the following code snippet, you will see an example that will show how to implement a...