Sanjeet Kedia
Sanjeet Kedia16mo ago

How to get the type of a convex function return in react

I am making a typescript app, i want to get the type of the items that the convex function will return, how do i do it?
4 Replies
erquhart
erquhart16mo ago
(typeof api.my.func)['_returnType']
Sanjeet Kedia
Sanjeet KediaOP16mo ago
Also i am having difficulites making joints in convex
erquhart
erquhart16mo ago
Here's a post that will help you think through relationships in Convex: https://stack.convex.dev/relationship-structures-let-s-talk-about-schemas If you just want to get to code, that post features relationship helper functions from the convex team, and this post focuses on the functional side of using them: https://stack.convex.dev/functional-relationships-helpers
Relationship Structures: Let's Talk About Schemas
In this post we’ll look at some patterns for structuring relationships in the Convex database.
Functional Relationships: Helpers
In this post, we’ll look at some helper functions to help write code to traverse relationships in a readable, predictable, and debuggable way.
ballingt
ballingt16mo ago
If you want a type you've written yourself you could define a type, then annotate the return type of your Convex query/mutation/action. Inference like (typeof api.my.func)['_returnType'] is convenient but sometimes you want a reusable type like type User = { ... }.

Did you find this page helpful?