@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: readonlyobject[]; }>
Constructors
Constructor
new InvalidInput(args): InvalidInput;Defined in: node_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2386
Parameters
| Parameter | Type |
|---|---|
args | object & object |
Returns
Inherited from
TaggedError("InvalidInput")<{
readonly issues: readonly { readonly message: string; readonly path: readonly PropertyKey[] }[];
}>.constructorProperties
| Property | Modifier | Type | Default value | Overrides | Inherited from | Defined in |
|---|---|---|---|---|---|---|
_tag | readonly | "InvalidInput" | undefined | - | TaggedError("InvalidInput")._tag | node_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2363 |
cause? | public | unknown | undefined | - | TaggedError("InvalidInput").cause | node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24 |
issues | readonly | readonly object[] | undefined | - | TaggedError("InvalidInput").issues | packages/pothos/src/contract.ts:39 |
message | public | string | "Input does not satisfy the service contract" | TaggedError("InvalidInput").message | - | packages/pothos/src/contract.ts:41 |
name | public | string | undefined | - | TaggedError("InvalidInput").name | node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074 |
stack? | public | string | undefined | - | TaggedError("InvalidInput").stack | node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076 |
Type Aliases
ProcedureConnectionOptions
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
| Name | Type | Defined in |
|---|---|---|
call | Call<Types["Context"], z.input<Schema>, Failure> | packages/pothos/src/procedure-field.ts:114 |
connection() | (page, args) => Connection | packages/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 |
output | z.ZodType<Page> | packages/pothos/src/procedure-field.ts:119 |
Type Parameters
| Type Parameter | Default 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
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
| Name | Type | Defined in |
|---|---|---|
call | Call<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 |
output | z.ZodType<ShapeFromTypeParam<Types, Type, false>> | packages/pothos/src/procedure-field.ts:75 |
tap()? | (value, context) => void | packages/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
const default: "orpc" = "orpc";Defined in: packages/pothos/src/plugin.ts:8
Functions
callProcedure()
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
| Parameter | Type |
|---|---|
procedure | Procedure<Schema> |
input | unknown |
call | (input) => AsyncResult<unknown, Failure> |
output | ZodType<Output> |
Returns
AsyncResult<Output, InvalidInput | Exclude<Failure, Access>>
contractCall()
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
| Parameter | Type |
|---|---|
procedure | ProcedureContract<Schema, OutputSchema, Errors> |
input | unknown |
call | (validated) => AsyncResult<Output, Failure> |
Returns
AsyncResult<Output, Failure | InvalidInput>
contractInput()
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
| Parameter | Type |
|---|---|
procedure | ProcedureContract<Input, Output, Errors> |
Returns
Input
contractOutput()
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
| Parameter | Type |
|---|---|
schema | Schema |
value | unknown |
Returns
AsyncResult<output<Schema>, never>
loadProcedure()
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
| Parameter | Type |
|---|---|
registry | Readonly<Record<string, ErrorClass>> |
procedure | Procedure<Schema> |
call | (input) => AsyncResult<unknown, Failure> |
input | unknown |
output | ZodType<Output> |
Returns
Promise<Error | Output>
procedureErrors()
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
| Parameter | Type |
|---|---|
registry | Readonly<Record<string, ErrorClass>> |
procedure | AnyProcedure |
Returns
object
| Name | Type | Defined in |
|---|---|---|
types | (...args) => Error[] | packages/pothos/src/procedure-field.ts:303 |
refusalsOf()
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
| Parameter | Type |
|---|---|
registry | Readonly<Record<string, ErrorClass>> |
procedure | AnyProcedure |
Returns
Refusals<Failure>