Skip to content

@btravstack/pothos


@btravstack/pothos ​

Classes ​

InvalidInput ​

Defined in: packages/pothos/src/contract.ts:38

An input the procedure's contract refuses, caught before the procedure is called: each of the contract's issues, with its message and path.

Extends ​

  • TaggedErrorInstance<"InvalidInput", { issues: readonly object[]; }>

Constructors ​

Constructor ​
ts
new InvalidInput(args): InvalidInput;

Defined in: node_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2386

Parameters ​
ParameterType
argsobject & object
Returns ​

InvalidInput

Inherited from ​
ts
TaggedError("InvalidInput")<{
  readonly issues: readonly { readonly message: string; readonly path: readonly PropertyKey[] }[];
}>.constructor

Properties ​

PropertyModifierTypeDefault valueOverridesInherited fromDefined in
_tagreadonly"InvalidInput"undefined-TaggedError("InvalidInput")._tagnode_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2363
cause?publicunknownundefined-TaggedError("InvalidInput").causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
issuesreadonlyreadonly object[]undefined-TaggedError("InvalidInput").issuespackages/pothos/src/contract.ts:39
messagepublicstring"Input does not satisfy the service contract"TaggedError("InvalidInput").message-packages/pothos/src/contract.ts:41
namepublicstringundefined-TaggedError("InvalidInput").namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstringundefined-TaggedError("InvalidInput").stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076

Type Aliases ​

ProcedureConnectionOptions ​

ts
type ProcedureConnectionOptions<Types, ParentShape, Type, Nullable, EdgeNullability, NodeNullability, Args, Kind, Schema, Page, Failure, Connection> = Omit<ResultConnectionOptions<Types, ParentShape, Type, Nullable, EdgeNullability, NodeNullability, Args, Kind, Failure, Connection>, "refusals" | "resolve"> & object & Covered<Types["Refusals"], Exclude<Failure, Access> | InvalidInput>;

Defined in: packages/pothos/src/procedure-field.ts:85

t.procedureConnection's options: resultConnection's, with call, input and output in place of resolve, connection folding the decoded page into the connection's shape, and an optional connectionType for fields beside its edges and page info.

Type Declaration ​

NameTypeDefined in
callCall<Types["Context"], z.input<Schema>, Failure>packages/pothos/src/procedure-field.ts:114
connection()(page, args) => Connectionpackages/pothos/src/procedure-field.ts:121
connectionType?ObjectRef<Types, Connection>packages/pothos/src/procedure-field.ts:120
input()(args, parent) => NoInfer<z.input<Schema>>packages/pothos/src/procedure-field.ts:115
outputz.ZodType<Page>packages/pothos/src/procedure-field.ts:119

Type Parameters ​

Type ParameterDefault type
Types extends SchemaTypes-
ParentShape-
Type extends OutputType<Types>-
Nullable extends boolean-
EdgeNullability extends FieldNullability<[unknown]>-
NodeNullability extends boolean-
Args extends InputFieldMap-
Kind extends FieldKind-
Schema extends z.ZodType-
Page-
Failure-
Connection extends ConnectionShapeForType<Types, Type, false, EdgeNullability, NodeNullability>ConnectionShapeForType<Types, Type, false, EdgeNullability, NodeNullability>

ProcedureFieldOptions ​

ts
type ProcedureFieldOptions<Types, ParentShape, Type, Nullable, Args, Kind, Schema, Failure> = Omit<ResultFieldOptions<Types, ParentShape, Type, Nullable, Args, Kind, Failure>, "refusals" | "resolve"> & object & Covered<Types["Refusals"], Exclude<Failure, Access> | InvalidInput>;

Defined in: packages/pothos/src/procedure-field.ts:57

t.procedureField's options: resultField's, with call, input and output in place of resolve, and the builder's orpc.refusals in place of refusals. The registry must cover every error call can return but the access refusals, and InvalidInput; an uncovered case is a compile error naming it. A declared error call handles itself needs no entry.

Type Declaration ​

NameTypeDefined in
callCall<Types["Context"], z.input<Schema>, Failure>packages/pothos/src/procedure-field.ts:70
input()(args, parent) => NoInfer<z.input<Schema>>packages/pothos/src/procedure-field.ts:71
outputz.ZodType<ShapeFromTypeParam<Types, Type, false>>packages/pothos/src/procedure-field.ts:75
tap()?(value, context) => voidpackages/pothos/src/procedure-field.ts:76

Type Parameters ​

Type Parameter
Types extends SchemaTypes
ParentShape
Type extends TypeParam<Types>
Nullable extends FieldNullability<Type>
Args extends InputFieldMap
Kind extends FieldKind
Schema extends z.ZodType
Failure

Variables ​

default ​

ts
const default: "orpc" = "orpc";

Defined in: packages/pothos/src/plugin.ts:8

Functions ​

callProcedure() ​

ts
function callProcedure<Schema, Output, Failure>(
   procedure, 
   input, 
   call, 
   output
): AsyncResult<Output, InvalidInput | Exclude<Failure, Access>>;

Defined in: packages/pothos/src/procedure-field.ts:250

call handed the input the procedure's contract accepts, its answer decoded by output. UNAUTHORIZED and FORBIDDEN, declared or not, leave the error channel: they travel as a GraphQLError carrying the code in extensions.code, an error of the operation, never a refusal of the field.

Type Parameters ​

Type Parameter
Schema extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>
Output
Failure

Parameters ​

ParameterType
procedureProcedure<Schema>
inputunknown
call(input) => AsyncResult<unknown, Failure>
outputZodType<Output>

Returns ​

AsyncResult<Output, InvalidInput | Exclude<Failure, Access>>


contractCall() ​

ts
function contractCall<Schema, OutputSchema, Errors, Output, Failure>(
   procedure, 
   input, 
   call
): AsyncResult<Output, Failure | InvalidInput>;

Defined in: packages/pothos/src/contract.ts:52

call, handed the input as the procedure's contract parses it and encodes it back for the wire — its defaults applied, its codecs run, asynchronous refinements included — or InvalidInput without calling it. A schema with a transform cannot be encoded back: call gets the input as given, which the contract admitted. A contract whose input is not one Zod schema is a defect.

Type Parameters ​

Type Parameter
Schema extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>
OutputSchema extends AnySchema
Errors extends ErrorMap
Output
Failure

Parameters ​

ParameterType
procedureProcedureContract<Schema, OutputSchema, Errors>
inputunknown
call(validated) => AsyncResult<Output, Failure>

Returns ​

AsyncResult<Output, Failure | InvalidInput>


contractInput() ​

ts
function contractInput<Input, Output, Errors>(procedure): Input;

Defined in: packages/pothos/src/contract.ts:21

The one Zod schema a procedure's contract declares for its input, typed as declared — to derive a GraphQL argument's shape from it (.shape, a z.preprocess around it) when the schema is built.

A procedure whose contract holds anything but exactly one Zod input schema is a mistake in the schema's source, not a request's: it throws, once, as the schema is built.

Type Parameters ​

Type Parameter
Input extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>
Output extends AnySchema
Errors extends ErrorMap

Parameters ​

ParameterType
procedureProcedureContract<Input, Output, Errors>

Returns ​

Input


contractOutput() ​

ts
function contractOutput<Schema>(schema, value): AsyncResult<output<Schema>, never>;

Defined in: packages/pothos/src/contract.ts:91

A procedure's answer decoded by schema — the shape the GraphQL field resolves, codecs run. An answer the schema refuses is a defect: the service broke its own contract.

Type Parameters ​

Type Parameter
Schema extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

Parameters ​

ParameterType
schemaSchema
valueunknown

Returns ​

AsyncResult<output<Schema>, never>


loadProcedure() ​

ts
function loadProcedure<Schema, Output, Failure>(
   registry, 
   procedure, 
   call, 
   input, 
   output
): Promise<Error | Output>;

Defined in: packages/pothos/src/procedure-field.ts:282

What a DataLoader answers for one key read through procedure: the decoded value, or an Error — the registered refusal for a declared error, the defect otherwise — so one key's failure never fails the batch.

It answers a Promise, and that is the boundary: a DataLoader's batch function answers a value or an Error per key.

Type Parameters ​

Type Parameter
Schema extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>
Output
Failure extends Caseable

Parameters ​

ParameterType
registryReadonly<Record<string, ErrorClass>>
procedureProcedure<Schema>
call(input) => AsyncResult<unknown, Failure>
inputunknown
outputZodType<Output>

Returns ​

Promise<Error | Output>


procedureErrors() ​

ts
function procedureErrors(registry, procedure): object;

Defined in: packages/pothos/src/procedure-field.ts:300

The errors option of a field that reads procedure through loadProcedure: the registered refusals it can answer, as the field's result union.

Parameters ​

ParameterType
registryReadonly<Record<string, ErrorClass>>
procedureAnyProcedure

Returns ​

object

NameTypeDefined in
types(...args) => Error[]packages/pothos/src/procedure-field.ts:303

refusalsOf() ​

ts
function refusalsOf<Failure>(registry, procedure): Refusals<Failure>;

Defined in: packages/pothos/src/procedure-field.ts:228

The refusals a procedure can answer, read from registry: one per error code its contract declares, and InvalidInput. A code the registry lacks is left out, and so are UNAUTHORIZED and FORBIDDEN, answered as GraphQL's own error.

Type Parameters ​

Type Parameter
Failure

Parameters ​

ParameterType
registryReadonly<Record<string, ErrorClass>>
procedureAnyProcedure

Returns ​

Refusals<Failure>

Released under the MIT License.