erquhart
erquhart16mo ago

Convex functions that can only be invoked by another function

Maybe this is too niche, but there's a class of functions that I never want to execute directly via cli or the dashboard. They exist solely to be called by other functions. For example, my migrations typically consist of at least a run mutation and a paginate mutation. That paginate function is truly internal and never to be invoked except by other functions. In this case, only by one specific function. This blocks nothing and is just a guardrail, but nice for making things explicit. Effectively private vs internal.
5 Replies
ballingt
ballingt16mo ago
This is on the radar, thinking of it more like ways to elevate certain functions for dashboard use (annotate to add a docstring, organize dashboard functions, etc.) but as you can imagine not a high priority since the default of everything being runnable on the dashboard is convenient and the security model is sound.
erquhart
erquhartOP16mo ago
Yeah, agreed. Note, though, that the request includes blocking both dashboard and cli invocation. Definitely not a security thing, agreed.
ian
ian16mo ago
Are you more interested in preventing accidental use, reducing the number of options in the dashboard UI, or something else? The CLI doesn't have a way (yet) to list or auto-complete, so the only risk there would be to accidentally paginate, which doesn't seem like a big deal on the surface?
erquhart
erquhartOP16mo ago
Maybe it's down to semantics. When I export const myFunc = internalMutation({}), I'm basically asking convex to both deploy and expose this function for general use, when that's not actually what I want. In many cases I'm splitting out functions because Convex requires it, eg., scheduling, pagination. Exposing everything by default just feels unkempt I guess. Low hanging fruit wise, just hiding in the dashboard does take care of the most visible effect of this. But again, this is not causing problems, I just have to think when I'm looking at a list of functions and call the right one. Biasing for giving feedback rather than not.
ian
ian16mo ago
makes sense, thanks!

Did you find this page helpful?