btraut
btraut5mo ago

trpc's useQuery with undefined input adds extra {"values":["undefined"]} to query

My React app has several calls to query endpoints that have no input data but that do need useQuery params:
const result = trpc.onboarding.activationSteps.useQuery(undefined, {
cacheTime: ms("10m"),
})
const result = trpc.onboarding.activationSteps.useQuery(undefined, {
cacheTime: ms("10m"),
})
These calls result in tRPC fetching the following: /trpc/onboarding.activationSteps?input={"json":null,"meta":{"values":["undefined"]}} I'd really like to avoid all the extra query param junk. Is there a way to leave this off and just call /trpc/onboarding.activationSteps?
1 Reply
btraut
btraut5mo ago
GitHub
Overload for useQuery when passing options for query with no params...
This may be a dumb idea or not really feasible but I thought I'd raise it. Currently when using useQuery on an endpoint that has no input, you have to pass undefined as the first parameter if y...