Mutations are a mechanism to run procedures through EQL. For a syntax review please check the EQL Mutations specification.
To create mutations you can use the
defmutation helper, which is similar to the
Here is a mutation to save a file on disk:
defresolver, one difference here is that in mutations there is no
mutations always use
This is a subtle difference, but you can see it by inspecting the mutation:
Note what would be
::pco/input on a
defresolver, it's now
::pco/params in mutation.
inputs, parameters don't have auto-resolution, they always come as-is,
but having this information can help on creating extensions (to support auto-resolution
if wanted) and help to understand the system (documentation).
To run the mutation you need to use the EQL interface:
The result of the mutation result comes in the same key as the mutation name.
By default the mutation symbol is the fully qualified var name of the mutation. Note we use the backtick to use the complete name.
Mutations are the first thing the runner executes, this way you know the reads from the query will have update values, in case the mutation affects something related to them.
You can also make a join in the mutation to specify what you want from the result. For this example we will write a resolver to get the file size, and use it as part of the mutation request:
Changing mutation symbol
I recommend sticking to fully qualified names, but in case you need a different name
you can use the
::pco/op-name to make it something else:
Resolve mutation params
On Pathom, when you call a mutation, the params flow without any alteration. The default behavior is meant to give the fastest path possible to invoke mutations.
That said, it's common also to want the params to be "resolved", just like Pathom does with inputs on resolvers.
To make that happen, you can use the
mutation-resolve-params built-in plugin. When
you add this plugin, Pathom will use the
::pco/params as a query and will run that
on the user params, and then deliver the resolved data to the mutation.
::pco/params is inferred from the argument destructuring.