how to call a function (mutation) from another function (mutation)?
question in the title
4 Replies
snippet for editing
3 approaches I use:
1. Ideally, see if there's a way to avoid this situation, often by splitting reusable logic out into separate functions, so you can do everything you need to in one mutation. There are a lot of approaches for this covered in Convex Stack and their example repos on GitHub.
2. If you must call a mutation from another mutation, use the
scheduler
arg to schedule it (you can schedule with a 0 wait in this case).
3. Last option is using an action instead of the initial mutation. This is not ideal as actions don't have the same transactional/atomicity guarantees as mutations and won't be retried in case of failure.thanks!
Btw I am really enjoying convex
Its awesome
Perfect DX
Nice!! I'm totally not a convex team member, just a fellow avid user lol. But agree, and same!