2021-09-27 14:47:55 +00:00
|
|
|
|
// ℹ️ Type-only import:
|
|
|
|
|
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export
|
|
|
|
|
import type { AppRouter } from "@server/routers/_app";
|
|
|
|
|
import { createReactQueryHooks } from "@trpc/react";
|
|
|
|
|
import type { inferProcedureOutput, inferProcedureInput } from "@trpc/server";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A set of strongly-typed React hooks from your `AppRouter` type signature with `createReactQueryHooks`.
|
|
|
|
|
* @link https://trpc.io/docs/react#3-create-trpc-hooks
|
|
|
|
|
*/
|
|
|
|
|
export const trpc = createReactQueryHooks<AppRouter>();
|
|
|
|
|
|
|
|
|
|
// export const transformer = superjson;
|
|
|
|
|
/**
|
|
|
|
|
* This is a helper method to infer the output of a query resolver
|
|
|
|
|
* @example type HelloOutput = inferQueryOutput<'hello'>
|
|
|
|
|
*/
|
|
|
|
|
export type inferQueryOutput<TRouteKey extends keyof AppRouter["_def"]["queries"]> = inferProcedureOutput<
|
|
|
|
|
AppRouter["_def"]["queries"][TRouteKey]
|
|
|
|
|
>;
|
|
|
|
|
|
|
|
|
|
export type inferQueryInput<TRouteKey extends keyof AppRouter["_def"]["queries"]> = inferProcedureInput<
|
|
|
|
|
AppRouter["_def"]["queries"][TRouteKey]
|
|
|
|
|
>;
|
|
|
|
|
|
|
|
|
|
export type inferMutationInput<TRouteKey extends keyof AppRouter["_def"]["mutations"]> = inferProcedureInput<
|
|
|
|
|
AppRouter["_def"]["mutations"][TRouteKey]
|
|
|
|
|
>;
|
2021-09-27 16:09:19 +00:00
|
|
|
|
|
|
|
|
|
export type inferMutationOutput<TRouteKey extends keyof AppRouter["_def"]["mutations"]> =
|
|
|
|
|
inferProcedureOutput<AppRouter["_def"]["mutations"][TRouteKey]>;
|