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

Function: collectFields()

collectFields<TVariables>(schema, fragments, variableValues, runtimeType, selectionSet): FieldsAndPatches

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

Given a selectionSet, collects all of the fields and returns them.

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

Type Parameters

TVariables

TVariables = any

Parameters

schema

GraphQLSchema

fragments

Record<string, FragmentDefinitionNode>

variableValues

TVariables

runtimeType

GraphQLObjectType

selectionSet

SelectionSetNode

Returns

FieldsAndPatches