TkDodo 🔮
TkDodo 🔮
TtRPC
Created by Rule on 10/14/2023 in #❓-help
tRPC with with react-query prefetching in Next.js app directory.
We have an excellent new guide in the v5 docs: https://tanstack.com/query/v5/docs/react/guides/ssr
7 replies
TtRPC
Created by TkDodo 🔮 on 10/31/2023 in #❓-help
adding information to the QueryKey that is not part of the procedure input
thanks for your insights, greatly appreciated 🙏 I just brought this topic up in our architecture meeting and we agreed that explicitly passing it as input is the best way, so we'll do that.
6 replies
TtRPC
Created by vildantursic on 10/6/2023 in #❓-help
Cancel useQueries with single function
the cancel method you get back from trpc utils is the same as queryClient.cancelQueries: https://trpc.io/docs/client/react/useUtils#helpers
5 replies
TtRPC
Created by TkDodo 🔮 on 9/27/2023 in #❓-help
TRPCError that has TRPCError as cause
yeah that fixes it. Thank you so much 🙏 I'm not quite sure why I couldn't reproduce it in isolation though
6 replies
TtRPC
Created by alex on 12/21/2022 in #❓-help
Type safety with enabled option
queryClient.refetchQueries does not bypass enabled: false, only refetch from useQuery does
19 replies
TtRPC
Created by alex on 12/21/2022 in #❓-help
Type safety with enabled option
not if enabled is type boolean and that changes at runtime. Like !!userId is not something that can be evaluated at compile time. also, even if possible, it would be wrong, because enabled can be bypassed by calling refetch() returned from useQuery. So TypeScript is correct - it is potentially undefined 🙂
19 replies
TtRPC
Created by Jack Fischer on 12/20/2022 in #❓-help
`QueryClientProvider` not included in `withTRPC`?
With v10 of trpc, you need v4 of react-query, so the import must come from @tanstack/react-query
3 replies
TtRPC
Created by alex on 12/21/2022 in #❓-help
Type safety with enabled option
Good question, I also thought about this. Possibly the router in the backend will need to accept null as input? But that doesn't look too sexy. Curious what others can suggest 🤔
19 replies
TtRPC
Created by TkDodo 🔮 on 11/15/2022 in #❓-help
clear cookie onError
I added a function to remove the cookies into the ctx - that works. Haven't looked at middlewares - the logging example shows how I can await the result and then act on it. I'll try if this also works for errors. Not sure if I'd have to try/catch the const result = await next()
6 replies
TtRPC
Created by TkDodo 🔮 on 10/19/2022 in #❓-help
calling trpc endpoints from vanilla nextJs api routes
And breaks nothing 😉
26 replies
TtRPC
Created by TkDodo 🔮 on 10/19/2022 in #❓-help
calling trpc endpoints from vanilla nextJs api routes
Thx for merging ❤️
26 replies
TtRPC
Created by TkDodo 🔮 on 10/19/2022 in #❓-help
calling trpc endpoints from vanilla nextJs api routes
Fine by me, let's expose the helper then?
26 replies
TtRPC
Created by TkDodo 🔮 on 10/19/2022 in #❓-help
calling trpc endpoints from vanilla nextJs api routes
I don't really understand: why does TrpcClientError have a statusCode property, but TrpcError does not?
26 replies
TtRPC
Created by TkDodo 🔮 on 10/19/2022 in #❓-help
calling trpc endpoints from vanilla nextJs api routes
getHTTPStatusCodeFromError would be sweet, I have now made my own mapping according to this table: https://trpc.io/docs/v9/error-handling#error-codes
26 replies
TtRPC
Created by TkDodo 🔮 on 10/19/2022 in #❓-help
calling trpc endpoints from vanilla nextJs api routes
related follow-up question @julius : when I make a server-side call, and it errors (e.g. because of a zod validation error), I get a TRPCError. That has a code, which is a string and it says BAD_REQUEST. Is there a way to translate this to a proper status code like 400 in this case? Right now, all these errors are sent as 500 errors to the frontend and this is kinda suboptimal imo. Thanks 🙏
26 replies
TtRPC
Created by TkDodo 🔮 on 10/19/2022 in #❓-help
calling trpc endpoints from vanilla nextJs api routes
Yep, this works. Thanks a lot ❤️
26 replies
TtRPC
Created by TkDodo 🔮 on 10/19/2022 in #❓-help
calling trpc endpoints from vanilla nextJs api routes
oh, would I want something like this? https://github.com/trpc/trpc/issues/1724 appRouter.createCaller ?
26 replies
TtRPC
Created by Dani; on 10/13/2022 in #❓-help
data becomes never[] when destructuring with a fallback value
exactly. DefinedUseQueryResult is the one that is used in the overloads where initialData is passed and doesn't return undefined
18 replies
TtRPC
Created by Dani; on 10/13/2022 in #❓-help
data becomes never[] when destructuring with a fallback value
Those live on useQuery so you'd likely have to duplicate the logic?
18 replies