Sandvich
Sandvich
TtRPC
Created by santi on 4/12/2024 in #❓-help
Is it possible to get the procedure name / id in middleware?
Until that feature gets implemented you might just have to do:
return {
ctx: {
cache: cachedData,
}
}
return {
ctx: {
cache: cachedData,
}
}
Then in your procedures
...
.query(({ ctx }) => {
if (ctx.cache) return ctx.cache;

...
})
...
.query(({ ctx }) => {
if (ctx.cache) return ctx.cache;

...
})
It's not ideal but it should work
8 replies
TtRPC
Created by Rasel Hossain on 4/9/2024 in #❓-help
How to get the Request Body data of QStash
No idea what Qstash is or how it works. Probably best reading their documentation
10 replies
TtRPC
Created by Gabriel on 3/6/2024 in #❓-help
Why deprecate experimental_standaloneMiddleware?
Any reason why you're using standalone middleware instead of regular middleware? Standalone is just for using the same middleware across different tRPC instances but it sounds like you're using one router and many procedures?
5 replies
TtRPC
Created by rhh4x0R on 4/11/2024 in #❓-help
tRPC + React Query Data Invalidation?
Also this seems like a react query question not a tRPC question. Do you want a link to that Discord server?
9 replies
TtRPC
Created by rhh4x0R on 4/11/2024 in #❓-help
tRPC + React Query Data Invalidation?
if it's the second then the query needs to do polling maybe? or if it's like a websocket connection then you can watch that an when it disconnects invalidate the query
9 replies
TtRPC
Created by rhh4x0R on 4/11/2024 in #❓-help
tRPC + React Query Data Invalidation?
If it's the first then you can invalidate the cache yourself
9 replies
TtRPC
Created by rhh4x0R on 4/11/2024 in #❓-help
tRPC + React Query Data Invalidation?
Are you as the client turning the server offline or is the client just watching and waiting to see if the server goes offline?
9 replies
TtRPC
Created by Rasel Hossain on 4/9/2024 in #❓-help
How to get the Request Body data of QStash
No description
10 replies
TtRPC
Created by Rasel Hossain on 4/9/2024 in #❓-help
How to get the Request Body data of QStash
if you check your browser devtools you'll see that's how trpc sends requests
10 replies
TtRPC
Created by Rasel Hossain on 4/9/2024 in #❓-help
How to get the Request Body data of QStash
I think you need /api/trpc/subscription.updateSubscription?batch=1
body: {
0: {
json: {
data:
....
body: {
0: {
json: {
data:
....
10 replies
TtRPC
Created by Katzius on 10/20/2023 in #❓-help
I want to create a wrapper for TRPC.init but I can't seem to get the context type correct.
You do Awaited<typeof createContext> but createContext isn't async so that doesn't do anything. I'd recommend just starting over with initTRPC.context<{test: string}>.create(...); and keep building up slowly to the more complex type you have until you find the error you made
9 replies
TtRPC
Created by diz6157 on 5/2/2023 in #❓-help
Best practices in naming and defining procedures when they don't fit into standard buckets?
Sorry to hijack this thread but this looks like a cool idea. I scaffolded out how that might look to create many procedures and this just looks really nice
const test = router({
greeting: {
query: publicProcedure
.input(z.string())
.query(({ input }) => {
return `Hello ${input}!`;
}),
mutation: publicProcedure
.input(z.object())
.mutation(() => {}),
subscription: publicProcedure.subscription(() => {
// ...
}),
}
});
const test = router({
greeting: {
query: publicProcedure
.input(z.string())
.query(({ input }) => {
return `Hello ${input}!`;
}),
mutation: publicProcedure
.input(z.object())
.mutation(() => {}),
subscription: publicProcedure.subscription(() => {
// ...
}),
}
});
You could argue there's some duplication in key name and method name but I think it's fine
26 replies