collectConflictsBetweenFieldsAndFragment function

void collectConflictsBetweenFieldsAndFragment(
  1. ValidationCtx context,
  2. List<Conflict> conflicts,
  3. Map<SelectionSetNode, FieldsAndFragmentNames> cachedFieldsAndFragmentNames,
  4. PairSet comparedFragmentPairs,
  5. bool areMutuallyExclusive,
  6. NodeAndDefCollection fieldMap,
  7. String fragmentName,
)

Collect all conflicts found between a set of fields and a fragment reference including via spreading in any nested fragments.

Implementation

void collectConflictsBetweenFieldsAndFragment(
  ValidationCtx context,
  List<Conflict> conflicts,
  Map<SelectionSetNode, FieldsAndFragmentNames> cachedFieldsAndFragmentNames,
  PairSet comparedFragmentPairs,
  bool areMutuallyExclusive,
  NodeAndDefCollection fieldMap,
  String fragmentName,
) {
  final fragment = context.fragmentsMap[fragmentName];
  if (fragment == null) {
    return;
  }

  final f = getReferencedFieldsAndFragmentNames(
    context,
    cachedFieldsAndFragmentNames,
    fragment,
  );
  final fieldMap2 = f.fieldMap;
  final referencedFragmentNames = f.fragmentNames;

  // Do not compare a fragment`s fieldMap to itself.
  if (fieldMap == fieldMap2) {
    return;
  }

  // (D) First collect any conflicts between the provided collection of fields
  // and the collection of fields represented by the given fragment.
  collectConflictsBetween(
    context,
    conflicts,
    cachedFieldsAndFragmentNames,
    comparedFragmentPairs,
    areMutuallyExclusive,
    fieldMap,
    fieldMap2,
  );

  // (E) Then collect any conflicts between the provided collection of fields
  // and any fragment names found in the given fragment.
  for (final referencedFragmentName in referencedFragmentNames) {
    collectConflictsBetweenFieldsAndFragment(
      context,
      conflicts,
      cachedFieldsAndFragmentNames,
      comparedFragmentPairs,
      areMutuallyExclusive,
      fieldMap,
      referencedFragmentName,
    );
  }
}