-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wrap function handlers to support independently exported handler (#30…
…078) i've been doing this pattern so i can call my handler from other functions and from unit tests ```ts export async function listHandler(ctx: QueryCtx) { return await ctx.db.query("messages").collect(); }; export const list = query({ handler: listHandler, }); ``` unfortunately, this makes both `list` and `listHandler` get analyzed as callable queries -- in the dashboard function view, the function runner, `npx convex run`, in components codegen, etc. l To fix, we can avoid `query`, `mutation`, and friends modifying the handler in place. We re-wrap in a separate function, and attach the handler as `.handler` on this separate function so analyze can get source maps from it. Tested that the dashboard still finds the function just fine. <img width="1321" alt="Screenshot 2024-09-23 at 5 30 25 PM" src="https://github.com/user-attachments/assets/c6e37cc1-110b-4097-b817-661f1917e62d"> GitOrigin-RevId: ff0ecfdd44bf40f38ef9c377d86694b3747c15a4
- Loading branch information
Showing
2 changed files
with
45 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters