Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid calling convex functions directly #33

Merged
merged 5 commits into from
Jan 3, 2025
Merged

Conversation

ldanilek
Copy link
Contributor

@ldanilek ldanilek commented Jan 2, 2025

Avoid calling convex functions -- queries/mutations/actions/httpactions -- directly, as if they were js functions. Instead, their _handler property is the js function, if it exists.

This avoids a new console.warn which was added to "convex/server" which happens if you call a registered query/mutation/action/httpaction directly.

I added some types, but i'm not sure if this makes it actually safer. the main benefit was not needing casts to make the PublicHttpAction type flow through from router.lookup


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ldanilek ldanilek requested a review from sshader January 2, 2025 23:35
Copy link
Contributor

@sshader sshader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slight preference for using mapped types instead of overloads but not blocking (e.g. https://github.com/get-convex/convex-test/compare/sshader-mapped-types?expand=1)

Co-authored-by: Sarah Shader <[email protected]>
@ldanilek ldanilek merged commit 44d1d74 into main Jan 3, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants