I'm currently working through refactoring my Convex queries and mutations to allow upgrading to 1.21, which throws a type error when you call Convex functions from other Convex functions.
The docs recommend relocating your functions into a model/ directory, and then importing and calling those functions from your Convex mutations and queries.
I have a few questions:
- Why is calling Convex functions from other functions an anti-pattern, specifically?
- The examples in the docs take the logic from the original query/mutation and relocate it to a new function in a directory called
model/, and then import and call that function from the original mutation/query. I don't fully understand the rationale behind this, since now there are two separate files with similar/identical function names, and two places to test instead of one. - For maintainability, is the recommendation to relocate all query and mutation logic into a separate function within
model/? My first intuition was to only relocate the shared logic, but the docs seem to suggest otherwise?