GiraphQL
Search…
FieldBuilder

field(options)

    options: FieldOptions

FieldOptions

1
type FieldOptions = {
2
type: ReturnType;
3
args?: Args;
4
nullable?: boolean;
5
description?: string;
6
deprecationReason?: string;
7
resolve: (parent, args, context, info): ResolveValue;
8
};
Copied!

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

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)
Last modified 6mo ago