Skip to content

Commit

Permalink
add missing invocations
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Jun 19, 2024
1 parent 15f7181 commit 34bce09
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,7 @@ describe('Validate: Overlapping fields can be merged', () => {
__typename
}
`;

expectErrors(query).toDeepEqual([]);
});
});
47 changes: 45 additions & 2 deletions src/validation/rules/OverlappingFieldsCanBeMergedRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ function findConflictsBetweenSubSelectionSets(

// (I) Then collect conflicts between the first collection of fields and
// those referenced by each fragment name associated with the second.
const discoveredFragments: Array<Array<string>> = [];
for (const fragmentName2 of fragmentNames2) {
collectConflictsBetweenFieldsAndFragment(
context,
Expand All @@ -434,7 +435,28 @@ function findConflictsBetweenSubSelectionSets(
areMutuallyExclusive,
fieldMap1,
fragmentName2,
[],
discoveredFragments,
);
}

// (E) Then collect any conflicts between the provided collection of fields
// and any fragment names found in the given fragment.
while (discoveredFragments.length !== 0) {
const item = discoveredFragments.pop();
if (!item || comparedFragmentPairs.has(item[1], item[0], areMutuallyExclusive)) {
continue;
}
const [fragmentName, referencedFragmentName] = item;
comparedFragmentPairs.add(referencedFragmentName, fragmentName, areMutuallyExclusive);
collectConflictsBetweenFieldsAndFragment(
context,
conflicts,
cachedFieldsAndFragmentNames,
comparedFragmentPairs,
false,
fieldMap1,
fragmentName,
discoveredFragments,
);
}

Expand All @@ -449,7 +471,28 @@ function findConflictsBetweenSubSelectionSets(
areMutuallyExclusive,
fieldMap2,
fragmentName1,
[],
discoveredFragments,
);
}

// (E) Then collect any conflicts between the provided collection of fields
// and any fragment names found in the given fragment.
while (discoveredFragments.length !== 0) {
const item = discoveredFragments.pop();
if (!item || comparedFragmentPairs.has(item[1], item[0], areMutuallyExclusive)) {
continue;
}
const [fragmentName, referencedFragmentName] = item;
comparedFragmentPairs.add(referencedFragmentName, fragmentName, areMutuallyExclusive);
collectConflictsBetweenFieldsAndFragment(
context,
conflicts,
cachedFieldsAndFragmentNames,
comparedFragmentPairs,
areMutuallyExclusive,
fieldMap2,
fragmentName,
discoveredFragments,
);
}

Expand Down

0 comments on commit 34bce09

Please sign in to comment.