tRPCttRPC
Powered by
vildantursicV
tRPC•3y ago
vildantursic

Pass additional data from `useQuery` to context

For
splitLink
splitLink
there is a way to pass context value through
useQuery
useQuery
as second param
{ trpc: { context: { x: y } } }
{ trpc: { context: { x: y } } }
, but it doesn't propagate further from
splitLink
splitLink
.
Is there a similar way to pass some data to context (I want to update context data dynamicaly) after its initialization
createContext
createContext
?
I have case where my app have route e.g.
/[appName]/machine/[x]
/[appName]/machine/[x]
and I would like to pass
appName
appName
to context so that I don't have to pass it each time with other params on
useQuery
useQuery
. Is that possible and what would be the best way?
I was trying this
trpc.machine.useQuery({ id: x }, { trpc: { ctx: { app: "<appName>" } } })
trpc.machine.useQuery({ id: x }, { trpc: { ctx: { app: "<appName>" } } })
and similar variations.
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

useQuery context
Answer OverflowAAnswer Overflow / ❓-help
3y ago
Data from useQuery is inferred as data: {} | undefined
zirkelcZzirkelc / ❓-help
3y ago
useQuery caching data
НиткаННитка / ❓-help
2y ago