
discord-questions.trpc.io/m/1200404498661781544
Preview meta tags from the discord-questions.trpc.io website.
Linked Hostnames
5- 4 links todiscord-questions.trpc.io
- 1 link todev.to
- 1 link todiscord.com
- 1 link todiscord.gg
- 1 link towww.answeroverflow.com
Thumbnail
Search Engine Appearance
How do I pass a Generic to a trpc query procedure? - tRPC
I want to to something like this: ```ts type AppIdsWithConfig = typeof kodixCareAppId | typeof calendarAppId; const fakeProcedure = <T extends AppIdsWithConfig>(kodixAppId: T) => { const appIdToValue = { [kodixCareAppId]: "my value 1", [calendarAppId]: 1235, } as const; return appIdToValue[kodixAppId]; }; const value = fakeProcedure(kodixCareAppId); // ^? --> const value: "my value 1" const value2 = fakeProcedure(calendarAppId); // ^? --> const value2: 1235 ``` This is how you pass a generic to a function, as we know. I wanted to do it in a procedure. Right now I have a procedure: ```ts type AppIdsWithConfig = typeof kodixCareAppId | typeof calendarAppId; //How do I pass a Generic to this? I want to infer the result type based on the appId I pass in as an input getConfig: protectedProcedure .input( z.object({ appId: z.custom<AppIdsWithConfig>(), }), ) .query( async ({ ctx, input }) => await getAppConfig({ appId: input.appId, prisma: ctx.prisma, session: ctx.session, }), ), ```
Bing
How do I pass a Generic to a trpc query procedure? - tRPC
I want to to something like this: ```ts type AppIdsWithConfig = typeof kodixCareAppId | typeof calendarAppId; const fakeProcedure = <T extends AppIdsWithConfig>(kodixAppId: T) => { const appIdToValue = { [kodixCareAppId]: "my value 1", [calendarAppId]: 1235, } as const; return appIdToValue[kodixAppId]; }; const value = fakeProcedure(kodixCareAppId); // ^? --> const value: "my value 1" const value2 = fakeProcedure(calendarAppId); // ^? --> const value2: 1235 ``` This is how you pass a generic to a function, as we know. I wanted to do it in a procedure. Right now I have a procedure: ```ts type AppIdsWithConfig = typeof kodixCareAppId | typeof calendarAppId; //How do I pass a Generic to this? I want to infer the result type based on the appId I pass in as an input getConfig: protectedProcedure .input( z.object({ appId: z.custom<AppIdsWithConfig>(), }), ) .query( async ({ ctx, input }) => await getAppConfig({ appId: input.appId, prisma: ctx.prisma, session: ctx.session, }), ), ```
DuckDuckGo

How do I pass a Generic to a trpc query procedure? - tRPC
I want to to something like this: ```ts type AppIdsWithConfig = typeof kodixCareAppId | typeof calendarAppId; const fakeProcedure = <T extends AppIdsWithConfig>(kodixAppId: T) => { const appIdToValue = { [kodixCareAppId]: "my value 1", [calendarAppId]: 1235, } as const; return appIdToValue[kodixAppId]; }; const value = fakeProcedure(kodixCareAppId); // ^? --> const value: "my value 1" const value2 = fakeProcedure(calendarAppId); // ^? --> const value2: 1235 ``` This is how you pass a generic to a function, as we know. I wanted to do it in a procedure. Right now I have a procedure: ```ts type AppIdsWithConfig = typeof kodixCareAppId | typeof calendarAppId; //How do I pass a Generic to this? I want to infer the result type based on the appId I pass in as an input getConfig: protectedProcedure .input( z.object({ appId: z.custom<AppIdsWithConfig>(), }), ) .query( async ({ ctx, input }) => await getAppConfig({ appId: input.appId, prisma: ctx.prisma, session: ctx.session, }), ), ```
General Meta Tags
6- titleHow do I pass a Generic to a trpc query procedure? - tRPC
- charsetutf-8
- viewportwidth=device-width, initial-scale=1
- next-size-adjust
- descriptionI want to to something like this: ```ts type AppIdsWithConfig = typeof kodixCareAppId | typeof calendarAppId; const fakeProcedure = <T extends AppIdsWithConfig>(kodixAppId: T) => { const appIdToValue = { [kodixCareAppId]: "my value 1", [calendarAppId]: 1235, } as const; return appIdToValue[kodixAppId]; }; const value = fakeProcedure(kodixCareAppId); // ^? --> const value: "my value 1" const value2 = fakeProcedure(calendarAppId); // ^? --> const value2: 1235 ``` This is how you pass a generic to a function, as we know. I wanted to do it in a procedure. Right now I have a procedure: ```ts type AppIdsWithConfig = typeof kodixCareAppId | typeof calendarAppId; //How do I pass a Generic to this? I want to infer the result type based on the appId I pass in as an input getConfig: protectedProcedure .input( z.object({ appId: z.custom<AppIdsWithConfig>(), }), ) .query( async ({ ctx, input }) => await getAppConfig({ appId: input.appId, prisma: ctx.prisma, session: ctx.session, }), ), ```
Open Graph Meta Tags
3- og:titleHow do I pass a Generic to a trpc query procedure? - tRPC
- og:descriptionI want to to something like this: ```ts type AppIdsWithConfig = typeof kodixCareAppId | typeof calendarAppId; const fakeProcedure = <T extends AppIdsWithConfig>(kodixAppId: T) => { const appIdToValue = { [kodixCareAppId]: "my value 1", [calendarAppId]: 1235, } as const; return appIdToValue[kodixAppId]; }; const value = fakeProcedure(kodixCareAppId); // ^? --> const value: "my value 1" const value2 = fakeProcedure(calendarAppId); // ^? --> const value2: 1235 ``` This is how you pass a generic to a function, as we know. I wanted to do it in a procedure. Right now I have a procedure: ```ts type AppIdsWithConfig = typeof kodixCareAppId | typeof calendarAppId; //How do I pass a Generic to this? I want to infer the result type based on the appId I pass in as an input getConfig: protectedProcedure .input( z.object({ appId: z.custom<AppIdsWithConfig>(), }), ) .query( async ({ ctx, input }) => await getAppConfig({ appId: input.appId, prisma: ctx.prisma, session: ctx.session, }), ), ```
- og:imagehttps://discord-questions.trpc.io/og/post?id=1200404498661781544
Twitter Meta Tags
4- twitter:cardsummary_large_image
- twitter:titleHow do I pass a Generic to a trpc query procedure? - tRPC
- twitter:descriptionI want to to something like this: ```ts type AppIdsWithConfig = typeof kodixCareAppId | typeof calendarAppId; const fakeProcedure = <T extends AppIdsWithConfig>(kodixAppId: T) => { const appIdToValue = { [kodixCareAppId]: "my value 1", [calendarAppId]: 1235, } as const; return appIdToValue[kodixAppId]; }; const value = fakeProcedure(kodixCareAppId); // ^? --> const value: "my value 1" const value2 = fakeProcedure(calendarAppId); // ^? --> const value2: 1235 ``` This is how you pass a generic to a function, as we know. I wanted to do it in a procedure. Right now I have a procedure: ```ts type AppIdsWithConfig = typeof kodixCareAppId | typeof calendarAppId; //How do I pass a Generic to this? I want to infer the result type based on the appId I pass in as an input getConfig: protectedProcedure .input( z.object({ appId: z.custom<AppIdsWithConfig>(), }), ) .query( async ({ ctx, input }) => await getAppConfig({ appId: input.appId, prisma: ctx.prisma, session: ctx.session, }), ), ```
- twitter:imagehttps://discord-questions.trpc.io/og/post?id=1200404498661781544
Link Tags
8- canonicalhttps://discord-questions.trpc.io/m/1200404498661781544
- iconhttps://cdn.answeroverflow.com/867764511159091230/6af104c7f0f39a12fcd55bd7bd28928f/icon.png
- preloadhttps://www.answeroverflow.com/_next/static/media/4f05ba3a6752a328-s.p.woff2
- preloadhttps://www.answeroverflow.com/_next/static/media/9cf9c6e84ed13b5e-s.p.woff2
- preload/discord/3.png
Links
8- https://dev.to/nicklucas/trpc-patterns-router-factories-and-polymorphism-30b0
- https://discord-questions.trpc.io
- https://discord-questions.trpc.io/search
- https://discord-questions.trpc.io/u/208752229815943170
- https://discord-questions.trpc.io/u/311955969716256770