Skip to Content
GraphQL Tools
DocumentationAPI@graphql-tools/utilssrcfunctionscollectSubFields

Function: collectSubFields()

collectSubFields(schema, fragments, variableValues, returnType, fieldNodes): FieldsAndPatches

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

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.

Unmemoized on purpose: callers that hit this on a hot path (e.g. executor) should wrap with a single lightweight memoize3 keyed by execution context.

Parameters

schema

GraphQLSchema

fragments

Record<string, FragmentDefinitionNode>

variableValues

VariableValues

returnType

GraphQLObjectType

fieldNodes

FieldNode[]

Returns

FieldsAndPatches