NerdkidChiki
NerdkidChiki•15mo ago

How do i change the type returned from a usePaginateQuery

hello everyone, i am querying data from a comments table that needs to be paginated but i also need to fetch data from the commentsvotes table (like a join table). The issue i have is that the returned type doesn't reflect the additional votes property i added. How do i fix this issue? Do i create a a new type and how do i force the return type to be of that custom type?
No description
2 Replies
lee
lee•15mo ago
You can get type inference working on the page by doing return {...postComment, page: commentsWithVotes}; . The thing is that in typescript each variable can only have one type, so you can't change the type of postComment but you can create a new variable with the updated type
NerdkidChiki
NerdkidChikiOP•15mo ago
wow....thanks so much 😎, its working now.....i got it working before now by creating a new type and casting the expected result on the client but i know that was not ideal.....your method works perfectly

Did you find this page helpful?