Skip to content

HandlerOptions

Shorthand input and output declarations accepted when adding a Mutation or Query.

The shorthand is expanded onto the operation’s InputBuilder and OutputBuilder before the operation builder is returned, so a spec can still refine the result through operation.input and operation.output.

Declaring a mandatory id and an Item result

app.addMutation('unarchive', { input: { id: 'id!' }, output: [category, moment] }, async (input, _current, ctx) => {
const item = await ctx.getItem(input.id);
return item?.unarchive();
});

readonly optional input?: InputDefinition | Record<string, PrimitiveDataType | MandatoryPrimitiveDataType>

Input Properties keyed by name, each given as a primitive data type. A trailing ! marks the Property mandatory, for example 'id!'. When omitted, the operation declares no input.

undefined

readonly optional output?: PrimitiveDataType | OutputDefinition | TemplateBuilder | TemplateBuilder[] | TemplateDefinition | TemplateDefinition[] | "template"

Result shape of the operation. A data type such as 'boolean' declares a single value, one Template (as a TemplateBuilder or Definition) declares an Item of that Template, an array of Templates declares an Item of any of them, 'template' declares a Template Definition, and an OutputDefinition is used as declared. When omitted, the operation returns nothing.

undefined