can i call mutations inside mutations?
can i call mutations inside mutations? is this... recommended?
4 Replies
If you want two different mutations to both include the same behavior, create a separate plain function to execute the shared behavior and call that function from both mutations. You'll generally pass the
ctx
into the function so it can execute the mutation.
This is less likely, but if you really do specifically have a need to call one mutation from another, you can use ctx.scheduler
to schedule the mutation from within another mutation.thanks, the scheduler is what I'm looking for
Note that you won't be able to await the scheduled mutation, the returned promise only resolves to indicate that the function was successfully scheduled.
the main difference is calling a js function would run it in the same transaction while scheduling it will run a separate transaction