tRPC useQuery with skipToken
I am trying to implement a useQuery which only happens once. I haven't been happy with setting enabled so something like
But... following their example nearly identically doesn't work for me. Broken Example Router And my error: Am I meant to define the skipToken in the zod input? It seems counter-intuitive to have to define skipToken in the zod input every single time this needs to be used on a route. P.S. I have a feeling this is a bug on tRPC itself given how little documentation and conversation surrounds the usage of skipToken on Discord and GitHub.
enabled: !!foo
as it'll still refetch, etc (and yes I know you can disable certain refetches, but that's not the goal here).
I found a supported, type-safe solution on the tRPC docs (https://trpc.io/docs/client/react/disabling-queries).But... following their example nearly identically doesn't work for me. Broken Example Router And my error: Am I meant to define the skipToken in the zod input? It seems counter-intuitive to have to define skipToken in the zod input every single time this needs to be used on a route. P.S. I have a feeling this is a bug on tRPC itself given how little documentation and conversation surrounds the usage of skipToken on Discord and GitHub.
Solution:Jump to solution
Nevermind, this idiot wasn't on tRPC v11.
Just did the upgrade, was pretty painless. Shoutout to the tRPC team.
I'll leave this up incase anyone else experiences a similar issue and goes down the rabbithole. UPGRADE TO V11 TO GET SKIPTOKEN TO WORK!...
1 Reply
Solution
Nevermind, this idiot wasn't on tRPC v11.
Just did the upgrade, was pretty painless. Shoutout to the tRPC team.
I'll leave this up incase anyone else experiences a similar issue and goes down the rabbithole. UPGRADE TO V11 TO GET SKIPTOKEN TO WORK!