mutation / action calling
Suppose I have a
mutation
that depends on external API's and in a convex function that mutation calls two actions does convex combine these into a single sql
like query result before returning the result of the mutation or are the actions ran in there own transaction state?4 Replies
by calling the actions, do you mean scheduling the actions? are these convex action functions, or some other action?
Let me rephrase:
If a convex action is called from a
mutation
function and the action fails, does the mutation fail also or will it still commit the changes?You can’t call an action from a mutation synchronously, you can only schedule it for execution asynchronously. If you were allowed to make a mutation’s outcome dependent on the outcome of an action, your mutations wouldn’t be deterministic anymore and you’d lose out on a lot of the benefits that you’re used to (e.g. automatic mutation retries)
Another way to put it is that actions don’t run in any kind of transaction because you’re unconstrained in the action environment. You may have performed some side effects, like hitting an external API, which Convex wouldn’t know how to “roll back”
thank you!