diff --git a/src/validation/rules/OverlappingFieldsCanBeMergedRule.ts b/src/validation/rules/OverlappingFieldsCanBeMergedRule.ts index 60d5c680e9a..3fd56961ac0 100644 --- a/src/validation/rules/OverlappingFieldsCanBeMergedRule.ts +++ b/src/validation/rules/OverlappingFieldsCanBeMergedRule.ts @@ -494,15 +494,18 @@ const processDiscoveredFragments = ( fieldMap: NodeAndDefCollection, discoveredFragments: Array>, ) => { - while (discoveredFragments.length !== 0) { - const item = discoveredFragments.pop(); + let item; + while ((item = discoveredFragments.pop()) !== undefined) { + const [fragmentName, referencedFragmentName] = item; if ( - !item || - comparedFragmentPairs.has(item[1], item[0], areMutuallyExclusive) + comparedFragmentPairs.has( + referencedFragmentName, + fragmentName, + areMutuallyExclusive, + ) ) { continue; } - const [fragmentName, referencedFragmentName] = item; comparedFragmentPairs.add( referencedFragmentName, fragmentName,