@btravstack/pothos
v0.54.0
Published
Pothos fields that call oRPC procedures, each declared error answered as a typed GraphQL refusal
Downloads
5,096
Maintainers
Readme
@btravstack/pothos
Pothos fields that call
oRPC procedures, for a GraphQL gateway in front of
contract-first services. The default export is the plugin, listed after
@unthrown/pothos's:
plugins: [RelayPlugin, ErrorsPlugin, UnthrownPlugin, OrpcPlugin].
t.procedureField(procedure, { type, call, input, output, refusals? })validates the field's input through the procedure's own contract before calling it, decodes the answer withoutput, and answers each error the procedure declares as the GraphQL error class registered for its code — a member of the field's result union. Field-localrefusalsoverride the builder's sharedorpc: { refusals }defaults. Together the maps must cover every errorcallcan return andInvalidInput; a missing code does not compile. A declared error handled by a narrowercallneeds no entry.t.procedureConnection(procedure, { …, connection })is the same for a Relay connection, with the decoded page folded byconnection.UNAUTHORIZEDandFORBIDDENare answered as GraphQL's own error, withextensions.code, whether the procedure declares them or not.loadProcedureandprocedureErrorsare the same answer through a DataLoader;contractCall,contractInputandcontractOutputare the contract half on its own.
Every dependency is a peer: Pothos plugins and graphql each need one copy.
Install @btravstack/contract alongside them; contractInput reuses its
/orpc input-schema accessor.
pnpm add @btravstack/pothos @btravstack/contract @pothos/core @pothos/plugin-errors @pothos/plugin-relay \
@unthrown/pothos@^0.1.2 graphql unthrown zod \
@orpc/[email protected] @orpc/[email protected]