On this page

collectSubFields

The collectSubFields variable exported by @graphql-tools/utils.

const collectSubFields: (schema, fragments, variableValues, returnType, fieldNodes) => FieldsAndPatches

Defined in: packages/utils/src/collectFields.ts:258

Given an array of field nodes, collects all of the subfields of the passed in fields, and returns them at the end.

CollectSubFields requires the “return type” of an object. For a field that returns an Interface or Union type, the “return type” will be the actual object type returned by that field.

Parameters

schema

GraphQLSchema

fragments

Record<string, FragmentDefinitionNode>

variableValues

VariableValues

returnType

GraphQLObjectType

fieldNodes

FieldNode[]

Returns

FieldsAndPatches