jbgrunewald
jbgrunewald
TtRPC
Created by jbgrunewald on 2/2/2024 in #❓-help
Create Wrapper only for Procedures that support Infinite Query
Greetings, I'm attempting to create a help that will handle some generic logic I desire for a series of infinite queries. I found this stackoverflow post, https://stackoverflow.com/questions/77096846/wrap-usequery-of-trpc-in-a-custom-hook-with-correct-typescript-types, which is essentially what I want. The only difference is that I only want to accept procedures that implement the inputs required for the useInifiniteQuery method to be available. The implementation above will not expose that function. I noticed that the main difference is that the inputs params for an infinite query procedure must have { cursor?: any }. There's no built in Procedure for infiniteQuery, but I thought I could make one by doing something like this. type InfiniteQueryProcedure = Procedure<"query", any & { cursor?: any }>; I think this is saying, this is a query and the input params support a cursor. However, when I pass this Procedure type to the DecorateProcedure, it does not seem to recognize the types correctly to enable the useInfiniteQuery method. Stack: - node v20 - pnpm - TRPC v10
2 replies