API

ArgBuilder

Reference for the arg builder `t.arg` — the arg method and its scalar helpers.

The arg builder is the t.arg object on a FieldBuilder. Its methods define a field's arguments. For a guided introduction, see Arguments.

arg(options)

  • options: ArgOptions

ArgOptions

type ArgOptions = {
  type: ReturnType;
  required?: boolean;
  defaultValue?: DefaultValue;
  description?: string;
  deprecationReason?: string;
  extensions?: Record<string, unknown>;
};
  • type: Type Parameter
  • required: whether the arg must be provided. Defaults to false unless you flip it in the builder — see Default nullability.
  • defaultValue: default value used when the arg is omitted. Its type follows the type option.
  • description: text description of the arg, surfaced in tools like GraphiQL.
  • deprecationReason: marks the arg deprecated with this reason.
  • extensions: arbitrary extension metadata, read by directives and server plugins.

Type parameter

An arg's type can be any InputTypeRef returned by a SchemaBuilder method that defines an InputObject, Enum, or Scalar, a TypeScript enum used to define a GraphQL enum, or a string matching a key of the Scalars map in SchemaTypes.

For list args, wrap any of the above in an array — for example ['ID'].

Scalar helpers

Shortcuts for defining scalar args. Each works like arg but omits the type option:

  • 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)