Skip to content

Commit ee5ce41

Browse files
authored
polish(validation): skip empty field comparisons (#4857)
Skip field comparisons when either collection is empty.
1 parent 4cf329a commit ee5ce41

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/validation/rules/OverlappingFieldsCanBeMergedRule.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ function collectConflictsBetweenFieldsAndFragment(
313313
varMap: VariableMap | undefined,
314314
fragmentSpread: FragmentSpread,
315315
): void {
316+
if (fieldMap.size === 0) {
317+
return;
318+
}
319+
316320
const { comparedFieldsAndFragmentPairs } = ruleContext;
317321
// Memoize so the fields and fragments are not compared for conflicts more
318322
// than once.
@@ -634,6 +638,9 @@ function collectConflictsBetween(
634638
fieldMap2: NodeAndDefCollection,
635639
varMap2: VariableMap | undefined,
636640
): void {
641+
if (fieldMap1.size === 0 || fieldMap2.size === 0) {
642+
return;
643+
}
637644
// A field map is a keyed collection, where each key represents a response
638645
// name and the value at that key is a list of all fields which provide that
639646
// response name. For any response name which appears in both provided field

0 commit comments

Comments
 (0)