sh03
sh03
TtRPC
Created by sh03 on 3/9/2024 in #❓-help
The inferred type of 'trpc' cannot be named without a reference
I'm getting the same error as this post: https://discord.com/channels/867764511159091230/1170736851775127564/1170736851775127564 I have a monorepo setup with an api package (copied from https://github.com/t3-oss/create-t3-turbo/tree/main/packages/api) and a server + expo packages similarly copied from that monorepo. Any ideas what I should be looking at to solve this issue?
2 replies
TtRPC
Created by sh03 on 3/1/2024 in #❓-help
Type 'QueryClient' is missing the following properties from type 'QueryClient': queryCache, mutation
I'm getting this error:
Type 'QueryClient' is missing the following properties from type 'QueryClient': queryCache, mutationCache, logger, defaultOptions, and 4 more.ts(2740) context.d.ts(48, 5): The expected type comes from property 'queryClient' which is declared here on type 'IntrinsicAttributes & TRPCProviderProps<CreateRouterInner<RootConfig<{ ctx: object; meta: object; errorShape: DefaultErrorShape; transformer: DefaultDataTransformer; }>, { ...; }>, unknown>'
on line:
<api.Provider client={trpcClient} queryClient={queryClient}>
<api.Provider client={trpcClient} queryClient={queryClient}>
^ (copy pasted from https://trpc.io/docs/client/react/setup) These are my relevant package versions:
"@tanstack/react-query": "^5.24.1",
"@trpc/client": "^10.45.1",
"@trpc/react-query": "^10.45.1",
"@trpc/server": "^10.45.1",
"@tanstack/react-query": "^5.24.1",
"@trpc/client": "^10.45.1",
"@trpc/react-query": "^10.45.1",
"@trpc/server": "^10.45.1",
what am I doing wrong?
13 replies
TtRPC
Created by sh03 on 3/8/2023 in #❓-help
How to organise reusable functions
How do you guys organize functions that all need the same context (usually from tRPC)? For example let's say that you have 10 functions you use multiple times across multiple routers and they all share the same context. Do you use a class?
25 replies
TtRPC
Created by sh03 on 2/18/2023 in #❓-help
How to manage custom errors (e.g. custom error codes) in tRPC?
What's the recommended way to add fields to a TRPCError? How do you make that typesafe also on the client (e.g. custom error code is a specific union type). Thanks
6 replies
TtRPC
Created by sh03 on 2/5/2023 in #❓-help
Is there an example of a real world non trivial app?
Something that includes type inference, nested fields, calculated fields, nested React components that use data coming from the backend as prop? The only example app I've found is this: https://todomvc.trpc.io/ But it doesn't have any of the things I mentioned above 😢 Thanks
3 replies
TtRPC
Created by sh03 on 2/5/2023 in #❓-help
How to organise output types?
I'm having a hard time trying to figure out what the best way to organise output types and I was wondering if you guys/gals have any tips. Things I'm having a hard time with: - Some output objects that may be returned in multiple places (e.g. users.get, users.getAll, posts.get (as Post.author), etc.) all need the same extra fields that can't come directly from Prisma (e.g. "the last post from the user" or "whether one can delete this user"); what's the best way to extract and reuse the logic for these fields? - How to mask output types (e.g. make sure that I don't return User.passwordHash ever) - How to express calculated fields (e.g. fullName = firstName + lastName) - How to reuse output types in nested components (e.g. components that don't directly useQuery) Thanks 🙏
9 replies