field(options)
options
: FieldOptions
type FieldOptions = {
type: ReturnType;
args?: Args;
nullable?: boolean;
description?: string;
deprecationReason?: string;
resolve: (parent, args, context, info): ResolveValue;
};
type
: Type Parameter
args
: a map of arg name to arg values. Arg values can be created using an
InputFieldBuilder
(fieldBuilder.arg
) or using schemaBuilder.args
nullable
: boolean, defaults to false
, unless overwritten in SchemaBuilder see
Changing Default Nullability.
description
: string
deprecationReason
: string
resolve
: Resolver
A Type Parameter for a Field can be any TypeRef
returned by one of the
SchemaBuilder
methods for defining a type, a class used to create an object
or interface type, a ts enum used to define a graphql enum type, or a string that corresponds to one
of they keys of the Objects
, Interfaces
, or Scalars
objects defined in SchemaTypes
.
For List fields, the Type Parameter should be one of the above wrapped in an array eg ['User']
.
A function to resolve the value of this field.
Field resolvers should return a value (or promise) that matches the expected type for this field.
For Scalars
, Objects
, and Interfaces
this type is the corresponding type defined
SchemaTypes
. For Unions, the type may be any of the corresponding shapes of members of the union.
For Enums, the value is dependent on the implementation of the enum. See Enum
guide for more
details.
parent
: Parent will be a value of the backing model for the current type specified in
SchemaTypes
.
args
: an object matching the shape of the args option for the current field
context
: The type Context
type defined in SchemaTypes
.
info
: a GraphQLResolveInfo object see
https://graphql.org/graphql-js/type/#graphqlobjecttype
for more details.
A set of helpers for creating scalar fields. This work the same as
field
, but omit the type
field from options.
string(options)
id(options)
boolean(options)
int(options)
float(options)
stringList(options)
idList(options)
booleanList(options)
intList(options)
floatList(options)
A set of helpers to expose fields from the backing model. The name
arg can be any field from the
backing model that matches the type being exposed. Options are the same as
field
, but type
and resolve
are omitted.
exposeString(name, options)
exposeID(name, options)
exposeBoolean(name, options)
exposeInt(name, options)
exposeFloat(name, options)
exposeStringList(name, options)
exposeIDList(name, options)
exposeBooleanList(name, options)
exposeIntList(name, options)
exposeFloatList(name, options)