allenA
Convex Community2y ago
1 reply
allen

Curious if there is a best practices for

Curious if there is a best practices for fanning out in convex. As an example scenario, imagine you have an status update mutation. That then needs to trigger a notification to all followers, which is an action. I could see the following approaches:

1) status update mutation queries all followers (collects all or paginates, unsure if there is a benefit here) and schedules a the action for each follower.
2) status update mutation schedules a separate mutation (to have access to ctx.scheduler even though its just querying) that does the follower collection and notification action scheduling. This would make the status update mutation more transactional to its area of concern, but unsure if its worth breaking out, if approach above is performant enough.
3) Have that separate mutation work in paginated batches and reschedule itself to page through the follower result set until exhausted.

I'm sure some of this comes down to "how many followers are we dealing with?", but with that being an unknown, which is advised? Or a completely different approach I'm not thinking of?
Was this page helpful?