@@ -200,6 +200,7 @@ function findConflictsWithinSelectionSet(
200
200
conflicts ,
201
201
cachedFieldsAndFragmentNames ,
202
202
comparedFragmentPairs ,
203
+ null ,
203
204
false ,
204
205
fieldMap ,
205
206
fragmentNames [ i ] ,
@@ -231,10 +232,15 @@ function collectConflictsBetweenFieldsAndFragment(
231
232
conflicts : Array < Conflict > ,
232
233
cachedFieldsAndFragmentNames : Map < SelectionSetNode , FieldsAndFragmentNames > ,
233
234
comparedFragmentPairs : PairSet ,
235
+ comparedFragmentsForFields : null | Set < string > ,
234
236
areMutuallyExclusive : boolean ,
235
237
fieldMap : NodeAndDefCollection ,
236
238
fragmentName : string ,
237
239
) : void {
240
+ if ( comparedFragmentsForFields ?. has ( fragmentName ) ) {
241
+ return ;
242
+ }
243
+
238
244
const fragment = context . getFragment ( fragmentName ) ;
239
245
if ( ! fragment ) {
240
246
return ;
@@ -266,12 +272,15 @@ function collectConflictsBetweenFieldsAndFragment(
266
272
267
273
// (E) Then collect any conflicts between the provided collection of fields
268
274
// and any fragment names found in the given fragment.
275
+ const newComparedFragmentsForFields =
276
+ comparedFragmentsForFields ?? new Set ( [ fragmentName ] ) ;
269
277
for ( const referencedFragmentName of referencedFragmentNames ) {
270
278
collectConflictsBetweenFieldsAndFragment (
271
279
context ,
272
280
conflicts ,
273
281
cachedFieldsAndFragmentNames ,
274
282
comparedFragmentPairs ,
283
+ newComparedFragmentsForFields ,
275
284
areMutuallyExclusive ,
276
285
fieldMap ,
277
286
referencedFragmentName ,
@@ -414,6 +423,7 @@ function findConflictsBetweenSubSelectionSets(
414
423
conflicts ,
415
424
cachedFieldsAndFragmentNames ,
416
425
comparedFragmentPairs ,
426
+ null ,
417
427
areMutuallyExclusive ,
418
428
fieldMap1 ,
419
429
fragmentName2 ,
@@ -428,6 +438,7 @@ function findConflictsBetweenSubSelectionSets(
428
438
conflicts ,
429
439
cachedFieldsAndFragmentNames ,
430
440
comparedFragmentPairs ,
441
+ null ,
431
442
areMutuallyExclusive ,
432
443
fieldMap2 ,
433
444
fragmentName1 ,
0 commit comments