API

InputFieldBuilder

Reference for the input field builder — the field method and its scalar helpers.

The input field builder is the t argument passed to the fields function of builder.inputType. Its methods define the fields of an input object. For a guided introduction, see Input objects. The same builder backs a field's arguments through t.arg.

field(options)

  • options: InputFieldOptions

InputFieldOptions

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

Type parameter

An input field'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 fields, wrap any of the above in an array — for example ['ID'].

Scalar helpers

Shortcuts for defining scalar input fields. Each works like field but omits the type option:

  • string(options)
  • id(options)
  • boolean(options)
  • int(options)
  • float(options)
  • stringList(options)
  • idList(options)
  • booleanList(options)
  • intList(options)
  • floatList(options)
  • listRef(type, options)