collectConflictsBetween function
void
collectConflictsBetween(
- ValidationCtx context,
- List<
Conflict> conflicts, - Map<
SelectionSetNode, FieldsAndFragmentNames> cachedFieldsAndFragmentNames, - PairSet comparedFragmentPairs,
- bool parentFieldsAreMutuallyExclusive,
- NodeAndDefCollection fieldMap1,
- NodeAndDefCollection fieldMap2,
Collect all Conflicts between two collections of fields. This is similar to,
but different from the collectConflictsWithin
function above. This check
assumes that collectConflictsWithin
has already been called on each
provided collection of fields. This is true because this validator traverses
each individual selection set.
Implementation
void collectConflictsBetween(
ValidationCtx context,
List<Conflict> conflicts,
Map<SelectionSetNode, FieldsAndFragmentNames> cachedFieldsAndFragmentNames,
PairSet comparedFragmentPairs,
bool parentFieldsAreMutuallyExclusive,
NodeAndDefCollection fieldMap1,
NodeAndDefCollection fieldMap2,
) {
// A field map is a keyed collection, where each key represents a response
// name and the value at that key is a list of all fields which provide that
// response name. For any response name which appears in both provided field
// maps, each field from the first field map must be compared to every field
// in the second field map to find potential conflicts.
for (final e in fieldMap1.entries) {
final responseName = e.key;
final fields1 = e.value;
final fields2 = fieldMap2[responseName];
if (fields2 != null) {
for (final field1 in fields1) {
for (final field2 in fields2) {
final conflict = findConflict(
context,
cachedFieldsAndFragmentNames,
comparedFragmentPairs,
parentFieldsAreMutuallyExclusive,
responseName,
field1,
field2,
);
if (conflict != null) {
conflicts.add(conflict);
}
}
}
}
}
}