relay-runtime 0.0.0-main-7207485b → 0.0.0-main-d2d2d1f2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -402,14 +402,7 @@ function getVariablesFromPluralFragment(
402
402
  return variables;
403
403
  }
404
404
 
405
- /**
406
- * @public
407
- *
408
- * Determine if two selectors are equal (represent the same selection). Note
409
- * that this function returns `false` when the two queries/fragments are
410
- * different objects, even if they select the same fields.
411
- */
412
- function areEqualSelectors(
405
+ function areEqualSingularSelectors(
413
406
  thisSelector: SingularReaderSelector,
414
407
  thatSelector: SingularReaderSelector,
415
408
  ): boolean {
@@ -421,6 +414,37 @@ function areEqualSelectors(
421
414
  );
422
415
  }
423
416
 
417
+ /**
418
+ * @public
419
+ *
420
+ * Determine if two selectors are equal (represent the same selection). Note
421
+ * that this function returns `false` when the two queries/fragments are
422
+ * different objects, even if they select the same fields.
423
+ */
424
+ function areEqualSelectors(
425
+ a: ?(SingularReaderSelector | PluralReaderSelector),
426
+ b: ?(SingularReaderSelector | PluralReaderSelector),
427
+ ): boolean {
428
+ if (
429
+ a?.kind === 'SingularReaderSelector' &&
430
+ b?.kind === 'SingularReaderSelector'
431
+ ) {
432
+ return areEqualSingularSelectors(a, b);
433
+ } else if (
434
+ a?.kind === 'PluralReaderSelector' &&
435
+ b?.kind === 'PluralReaderSelector'
436
+ ) {
437
+ return (
438
+ a.selectors.length === b.selectors.length &&
439
+ a.selectors.every((s, i) => areEqualSingularSelectors(s, b.selectors[i]))
440
+ );
441
+ } else if (a == null && b == null) {
442
+ return true;
443
+ } else {
444
+ return false;
445
+ }
446
+ }
447
+
424
448
  function createReaderSelector(
425
449
  fragment: ReaderFragment,
426
450
  dataID: DataID,