Skip to main content
Version: 10.x

ProcedureBuilder<TParams>

Type parameters

  • TParams extends ProcedureParams

Methods

input()

Add an input parser to the procedure.

Signature

ts
input<$Parser>(schema: TParams["_input_out"] extends typeof unsetMarker ? $Parser : inferParser<$Parser>["out"] extends undefined | Record<string, unknown> ? TParams["_input_out"] extends undefined | Record<string, unknown> ? undefined extends any[any] ? undefined extends any[any] ? $Parser : "Cannot chain an optional parser to a required parser" : $Parser : "All input parsers did not resolve to an object" : "All input parsers did not resolve to an object"): ProcedureBuilder<{
_config: TParams["_config"];
_ctx_out: TParams["_ctx_out"];
_input_in: OverwriteIfDefined<TParams["_input_in"], inferParser<$Parser>["in"]>;
_input_out: OverwriteIfDefined<TParams["_input_out"], inferParser<$Parser>["out"]>;
_meta: TParams["_meta"];
_output_in: TParams["_output_in"];
_output_out: TParams["_output_out"];
}>;
ts
input<$Parser>(schema: TParams["_input_out"] extends typeof unsetMarker ? $Parser : inferParser<$Parser>["out"] extends undefined | Record<string, unknown> ? TParams["_input_out"] extends undefined | Record<string, unknown> ? undefined extends any[any] ? undefined extends any[any] ? $Parser : "Cannot chain an optional parser to a required parser" : $Parser : "All input parsers did not resolve to an object" : "All input parsers did not resolve to an object"): ProcedureBuilder<{
_config: TParams["_config"];
_ctx_out: TParams["_ctx_out"];
_input_in: OverwriteIfDefined<TParams["_input_in"], inferParser<$Parser>["in"]>;
_input_out: OverwriteIfDefined<TParams["_input_out"], inferParser<$Parser>["out"]>;
_meta: TParams["_meta"];
_output_in: TParams["_output_in"];
_output_out: TParams["_output_out"];
}>;

Type parameters

  • $Parser extends Parser

Parameters

NameType
schemaTParams["_input_out"] extends typeof unsetMarker ? $Parser : inferParser<$Parser>["out"] extends undefined | Record<string, unknown> ? TParams["_input_out"] extends undefined | Record<string, unknown> ? undefined extends any[any] ? undefined extends any[any] ? $Parser : "Cannot chain an optional parser to a required parser" : $Parser : "All input parsers did not resolve to an object" : "All input parsers did not resolve to an object"

Returns

ProcedureBuilder<{ _config: TParams["_config"]; _ctx_out: TParams["_ctx_out"]; _input_in: OverwriteIfDefined<TParams["_input_in"], inferParser<$Parser>["in"]>; _input_out: OverwriteIfDefined<TParams["_input_out"], inferParser<$Parser>["out"]>; _meta: TParams["_meta"]; _output_in: TParams["_output_in"]; _output_out: TParams["_output_out"]; }>

Defined in: packages/server/src/core/internals/procedureBuilder.ts:88

meta()

Add a meta data to the procedure.

Signature

ts
meta(meta: TParams["_meta"]): ProcedureBuilder<TParams>;
ts
meta(meta: TParams["_meta"]): ProcedureBuilder<TParams>;

Parameters

NameType
metaTParams["_meta"]

Returns

ProcedureBuilder<TParams>

Defined in: packages/server/src/core/internals/procedureBuilder.ts:133

mutation()

Mutation procedure

Signature

ts
mutation<$Output>(resolver: Function): BuildProcedure<"mutation", TParams, $Output>;
ts
mutation<$Output>(resolver: Function): BuildProcedure<"mutation", TParams, $Output>;

Type parameters

  • $Output

Parameters

NameType
resolver(opts: ResolveOptions<TParams>) => MaybePromise<DefaultValue<TParams["_output_in"], $Output>>

Returns

BuildProcedure<"mutation", TParams, $Output>

Defined in: packages/server/src/core/internals/procedureBuilder.ts:163

output()

Add an output parser to the procedure.

Signature

ts
output<$Parser>(schema: $Parser): ProcedureBuilder<{
_config: TParams["_config"];
_ctx_out: TParams["_ctx_out"];
_input_in: TParams["_input_in"];
_input_out: TParams["_input_out"];
_meta: TParams["_meta"];
_output_in: inferParser<$Parser>["in"];
_output_out: inferParser<$Parser>["out"];
}>;
ts
output<$Parser>(schema: $Parser): ProcedureBuilder<{
_config: TParams["_config"];
_ctx_out: TParams["_ctx_out"];
_input_in: TParams["_input_in"];
_input_out: TParams["_input_out"];
_meta: TParams["_meta"];
_output_in: inferParser<$Parser>["in"];
_output_out: inferParser<$Parser>["out"];
}>;

Type parameters

  • $Parser extends Parser

Parameters

NameType
schema$Parser

Returns

ProcedureBuilder<{ _config: TParams["_config"]; _ctx_out: TParams["_ctx_out"]; _input_in: TParams["_input_in"]; _input_out: TParams["_input_out"]; _meta: TParams["_meta"]; _output_in: inferParser<$Parser>["in"]; _output_out: inferParser<$Parser>["out"]; }>

Defined in: packages/server/src/core/internals/procedureBuilder.ts:119

query()

Query procedure

Signature

ts
query<$Output>(resolver: Function): BuildProcedure<"query", TParams, $Output>;
ts
query<$Output>(resolver: Function): BuildProcedure<"query", TParams, $Output>;

Type parameters

  • $Output

Parameters

NameType
resolver(opts: ResolveOptions<TParams>) => MaybePromise<DefaultValue<TParams["_output_in"], $Output>>

Returns

BuildProcedure<"query", TParams, $Output>

Defined in: packages/server/src/core/internals/procedureBuilder.ts:154

subscription()

Mutation procedure

Signature

ts
subscription<$Output>(resolver: Function): BuildProcedure<"subscription", TParams, $Output>;
ts
subscription<$Output>(resolver: Function): BuildProcedure<"subscription", TParams, $Output>;

Type parameters

  • $Output

Parameters

NameType
resolver(opts: ResolveOptions<TParams>) => MaybePromise<DefaultValue<TParams["_output_in"], $Output>>

Returns

BuildProcedure<"subscription", TParams, $Output>

Defined in: packages/server/src/core/internals/procedureBuilder.ts:172

unstable_concat()

Extend the procedure with another procedure.

Warning

The TypeScript inference fails when chaining concatenated procedures.

Signature

ts
unstable_concat<$ProcedureBuilder>(proc: $ProcedureBuilder): $ProcedureBuilder extends ProcedureBuilder<$TParams> ? CreateProcedureReturnInput<TParams, $TParams> : never;
ts
unstable_concat<$ProcedureBuilder>(proc: $ProcedureBuilder): $ProcedureBuilder extends ProcedureBuilder<$TParams> ? CreateProcedureReturnInput<TParams, $TParams> : never;

Type parameters

Parameters

NameType
proc$ProcedureBuilder

Returns

$ProcedureBuilder extends ProcedureBuilder<$TParams> ? CreateProcedureReturnInput<TParams, $TParams> : never

Defined in: packages/server/src/core/internals/procedureBuilder.ts:146

use()

Add a middleware to the procedure.

Signature

ts
use<$Params>(fn: MiddlewareBuilder<TParams, $Params> | MiddlewareFunction<TParams, $Params>): CreateProcedureReturnInput<TParams, $Params>;
ts
use<$Params>(fn: MiddlewareBuilder<TParams, $Params> | MiddlewareFunction<TParams, $Params>): CreateProcedureReturnInput<TParams, $Params>;

Type parameters

  • $Params extends ProcedureParams<AnyRootConfig, unknown, unknown, unknown, unknown, unknown, unknown, $Params>

Parameters

NameType
fnMiddlewareBuilder<TParams, $Params> | MiddlewareFunction<TParams, $Params>

Returns

CreateProcedureReturnInput<TParams, $Params>

Defined in: packages/server/src/core/internals/procedureBuilder.ts:137