getReferencedFieldsAndFragmentNames function
FieldsAndFragmentNames
getReferencedFieldsAndFragmentNames(
- ValidationCtx context,
- Map<
SelectionSetNode, FieldsAndFragmentNames> cachedFieldsAndFragmentNames, - FragmentDefinitionNode fragment
Given a reference to a fragment, return the represented collection of fields as well as a list of nested fragment names referenced via fragment spreads.
Implementation
FieldsAndFragmentNames getReferencedFieldsAndFragmentNames(
ValidationCtx context,
Map<SelectionSetNode, FieldsAndFragmentNames> cachedFieldsAndFragmentNames,
FragmentDefinitionNode fragment,
) {
// Short-circuit building a type from the node if possible.
final cached = cachedFieldsAndFragmentNames[fragment.selectionSet];
if (cached != null) {
return cached;
}
final fragmentType = convertTypeOrNull(
fragment.typeCondition.on,
context.schema.typeMap,
) as GraphQLNamedType?;
return getFieldsAndFragmentNames(
context,
cachedFieldsAndFragmentNames,
fragmentType,
fragment.selectionSet,
);
}