stefano
stefano10mo ago

Sharing logic between queries and mutations

hello, I'm having an hard time calling an internalQuery from a mutation action. Is this possibile?
3 Replies
Michal Srb
Michal Srb10mo ago
You can call JS/TS functions from mutations and queries: https://docs.convex.dev/typescript#type-annotating-server-side-helpers There's no point in calling a query from a mutation, since a mutation can do everything a query can do.
TypeScript | Convex Developer Hub
Move faster with end-to-end type safety.
sshader
sshader10mo ago
Best Practices | Convex Developer Hub
Here's a collection of our recommendations on how best to use Convex to build
stefano
stefanoOP10mo ago
Thanks,I created a "helpers.ts" file where I write reusable functions, But is creating a helper file where I store all the functions considered a safe practice? For example, as long as I check if the user is authorized to check the functions before they get called in the real functions (query, action, mutation, etc) it should be safe right? There's no way one could run this functions directly?
No description

Did you find this page helpful?