ArgBuilder
This reference describes the options for an argument. For examples, see Arguments.
The option types below are summaries; Pothos infers their concrete types from your schema.
arg(options)
options: [FieldOptions]
FieldOptions
type FieldOptions = {
type: InputType;
required?: boolean | { list: boolean; items: boolean };
defaultValue?: DefaultValue;
description?: string;
deprecationReason?: string;
extensions?: Readonly<Record<string, unknown>>;
};-
type: Type Parameter -
required: defaults tofalse, unless overwritten in SchemaBuilder see -
description: string -
deprecationReason: marks the input as deprecated. -
extensions: metadata for tools and plugins. -
defaultValue: default value for field, type based ontypeoption.
Type Parameter
A Type Parameter for a Field can be any InputTypeRef returned by one of the
SchemaBuilder methods for defining an InputObject, Enum, or Scalar, a ts
enum used to define a graphql enum type, or a string that corresponds to one of the keys of the
Scalars object defined in SchemaTypes.
For lists, wrap the type in an array, for example ['ID']. A boolean required controls
the list itself; items are required by default. Use { list: false, items: false } to allow both
an omitted or null list and null items. Input object names declared in SchemaTypes.Inputs
can also be used as strings.
helpers
A set of helpers for creating scalar fields. These work the same as ArgBuilder, but omit the type
field from options.
Scalars
arg.string(options)arg.id(options)arg.boolean(options)arg.int(options)arg.float(options)arg.stringList(options)arg.idList(options)arg.booleanList(options)arg.intList(options)arg.floatList(options)
arg.listRef(type, options?)
Creates a list type reference, including nested lists. options.required controls the items
and defaults to true; the field or argument options control the outer list. See
Arguments for a nested-list example.