FieldBuilder
field(options)
options:FieldOptions
FieldOptions
-
type: Type Parameter -
args: a map of arg name to arg values. Arg values can be created using anInputFieldBuilder(
fieldBuilder.arg) or usingschemaBuilder.args -
nullable: boolean, defaults tofalse, unless overwritten in SchemaBuilder see Changing Default Nullability. -
description: string -
deprecationReason: string -
resolve: Resolver
Type Parameter
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'].
Resolver
A function to resolve the value of this field.
Return type
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.
Args
-
parent: Parent will be a value of the backing model for the current type specified inSchemaTypes. -
args: an object matching the shape of the args option for the current field -
context: The typeContexttype defined inSchemaTypes. -
info: a GraphQLResolveInfo object seehttps://graphql.org/graphql-js/type/#graphqlobjecttype
for more details.
helpers
A set of helpers for creating scalar fields. This work the same as
field, but omit the type field from options.
Scalars
string(options)id(options)boolean(options)int(options)float(options)stringList(options)idList(options)booleanList(options)intList(options)floatList(options)listRef(type, options)
expose
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)