discord-questions.trpc.io/m/1200404498661781544

Preview meta tags from the discord-questions.trpc.io website.

Linked Hostnames

5

Thumbnail

Search Engine Appearance

Google

https://discord-questions.trpc.io/m/1200404498661781544

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

https://discord-questions.trpc.io/m/1200404498661781544

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

https://discord-questions.trpc.io/m/1200404498661781544

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
    • title
      How do I pass a Generic to a trpc query procedure? - tRPC
    • charset
      utf-8
    • viewport
      width=device-width, initial-scale=1
    • next-size-adjust
    • description
      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, }), ), ```
  • Open Graph Meta Tags

    3
    • og:title
      How do I pass a Generic to a trpc query procedure? - tRPC
    • og:description
      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, }), ), ```
    • og:image
      https://discord-questions.trpc.io/og/post?id=1200404498661781544
  • Twitter Meta Tags

    4
    • twitter:card
      summary_large_image
    • twitter:title
      How do I pass a Generic to a trpc query procedure? - tRPC
    • twitter:description
      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, }), ), ```
    • twitter:image
      https://discord-questions.trpc.io/og/post?id=1200404498661781544
  • Link Tags

    8
    • canonical
      https://discord-questions.trpc.io/m/1200404498661781544
    • icon
      https://cdn.answeroverflow.com/867764511159091230/6af104c7f0f39a12fcd55bd7bd28928f/icon.png
    • preload
      https://www.answeroverflow.com/_next/static/media/4f05ba3a6752a328-s.p.woff2
    • preload
      https://www.answeroverflow.com/_next/static/media/9cf9c6e84ed13b5e-s.p.woff2
    • preload
      /discord/3.png

Links

8