diff --git a/src/types.ts b/src/types.ts index 71cec3ee..922d1693 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,4 @@ -import { Procedure, ProcedureParams, Router } from '@trpc/server'; +import { Procedure, ProcedureParams, ProcedureType, Router } from '@trpc/server'; import type { RootConfig } from '@trpc/server/dist/core/internals/config'; import { TRPC_ERROR_CODE_KEY } from '@trpc/server/rpc'; import type { RouterDef } from '@trpc/server/src/core/router'; @@ -37,7 +37,7 @@ export type OpenApiMeta = TMeta & { export type OpenApiProcedure = Procedure< 'query' | 'mutation', - ProcedureParams< + { type: ProcedureType } & ProcedureParams< RootConfig<{ transformer: any; errorShape: any; diff --git a/src/utils/procedure.ts b/src/utils/procedure.ts index 8881bc8b..64e8c14c 100644 --- a/src/utils/procedure.ts +++ b/src/utils/procedure.ts @@ -23,6 +23,7 @@ const getProcedureType = (procedure: OpenApiProcedure): ProcedureType => { if (procedure._def.query) return 'query'; if (procedure._def.mutation) return 'mutation'; if (procedure._def.subscription) return 'subscription'; + if (procedure._def.type) return procedure._def.type; throw new Error('Unknown procedure type'); };