relayOptionsobject passed to builder can contain the following properties:
optional. Determins if clientMutationId fields are created on connections, and if they are required.
ID. Determines type used for cursor fields. Defaults behavior due to legacy reasons is
Stringfor everything except for connection arguments which use
ID. Overwritting this default is hightly encouraged.
nodeQueryOptions: Options for the
nodefield on the query object
nodesQueryOptions: Options for the
nodesfield on the query object
nodeTypeOptions: Options for the
pageInfoTypeOptions: Options for the
clientMutationIdFieldOptions: Options for the
clientMutationIdfield on connection objects
clientMutationIdInputOptions: Options for the
clientMutationIdinput field on connections fields
mutationInputArgOptions: Options for the Input object created for each connection field
cursorFieldOptions: Options for the
cursorfield on an edge object.
nodeFieldOptions: Options for the
nodefield on an edge object.
edgesFieldOptions: Options for the
edgesfield on a connection object.
pageInfoFieldOptions: Options for the
pageInfofield on a connection object.
hasNextPageFieldOptions: Options for the
hasNextPagefield on the
hasPreviousPageFieldOptions: Options for the
hasPreviousPagefield on the
startCursorFieldOptions: Options for the
startCursorfield on the
endCursorFieldOptions: Options for the
endCursorfield on the
beforeArgOptions: Options for the
beforearg on a connection field.
afterArgOptions: Options for the
afterarg on a connection field.
firstArgOptions: Options for the
firstarg on a connection field.
lastArgOptions: Options for the
lastarg on a connection field.
type, The type can be either the name of a name as a string, or any object that can be used in a type parameter.
typename) before they are passed to your resolver in the arguments object.
Nodeinterface, you can use the new
builder.nodewill create an object type that implements the
Nodeinterface. It will also create the
Nodeinterface the first time it is used. The
idshould return a number or string, which will be converted to a globalID. The
loadManymethods are optional, and
loadManywill be used if both are present. These methods allow a nodes to be loaded by id. The relay plugin adds to new query fields
nodeswhich can be used to directly fetch nodes using global IDs.
isTypeOfmethod which can be used to resolve the correct type for lists of generic nodes. When using a class as the type parameter, the
isTypeOfmethod defaults to using an
instanceofcheck, and falls back to checking the constructor property on the prototype. The means that for many cases if you are using classes in your type parameters, and all your values are instances of those classes, you won't need to implement an
isTypeOfmethod, but it is ussually better to explicitly define that behavior.
t.connectionfield builder method can be used to define connections. This method will automatically create the
Edgeobjects used by the connection, and add
lastarguments. The first time this method is used, it will also create the
resolveOffsetConnectionhas a few default limits to prevent unintentionally allowing too many records to be fetched at once. These limits can be configure using the following options:
resolveArrayConnection, which works just like
resolveOffsetConnectionand accepts the same options.
relayMutationFieldmethod to define relay compliant mutation fields. This method will generate a mutation field, an input object with a
clientMutationIdfield, and an output object with the corresponding
relayMutationFieldhas 4 arguments:
name: Name of the mutation field
inputOptions: Options for the
fieldOptions: Options for the mutation field
payloadOptions: Options for the Payload object
inputOptionshas a couple of non-standard options:
namewhich can be used to set the name of the input object
argNamewhich can be used to overwrite the default arguments name (
payloadOptionsobject also accepts a
nameproperty for setting the name of the payload object.
builder.connectionObjectcreates the connect object type and the associated Edge type.
t.arg.connectionArgs()will create the default connection args.
t.nodesmethods can be used to add additional node fields. the expected return values of
idsfields is the same as the resolve value of
t.globalID, and can either be a globalID or an object with and an
iduses a request cache, so the same node will only be loaded once per request, even if it is used multiple times across the schema.
encodeGlobalIDas helper methods for interacting with global IDs directly. If you accept a global ID as an argument you can use the
decodeGlobalIDfunction to decode it:
t.globalConnectionFields. These methods work like many of the other methods on the builder for adding fields to objects or interfaces.
totalCountfield. To make this more useful, we need to have our resolvers for each connection actually return an object that contains a totalCount for us. To guarantee that resolvers correclty implement this behavior, we can define custom properties that must be returned from connection resolvers when we set up our builder: