relay-runtime 10.0.0 → 10.0.1
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.
- package/index.js +1 -1
- package/lib/store/RelayModernStore.js +6 -6
- package/lib/store/RelayReader.js +4 -16
- package/lib/store/RelayResponseNormalizer.js +9 -36
- package/lib/store/StoreInspector.js +1 -3
- package/lib/util/recycleNodesInto.js +2 -8
- package/package.json +1 -1
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/RelayModernStore.js.flow +7 -7
- package/store/RelayReader.js.flow +4 -12
- package/store/RelayResponseNormalizer.js.flow +10 -31
- package/store/StoreInspector.js.flow +1 -3
- package/util/recycleNodesInto.js.flow +2 -8
|
@@ -90,7 +90,7 @@ class RelayModernStore implements Store {
|
|
|
90
90
|
_globalInvalidationEpoch: ?number;
|
|
91
91
|
_invalidationSubscriptions: Set<InvalidationSubscription>;
|
|
92
92
|
_invalidatedRecordIDs: Set<DataID>;
|
|
93
|
-
|
|
93
|
+
__log: ?LogFunction;
|
|
94
94
|
_queryCacheExpirationTime: ?number;
|
|
95
95
|
_operationLoader: ?OperationLoader;
|
|
96
96
|
_optimisticSource: ?MutableRecordSource;
|
|
@@ -141,7 +141,7 @@ class RelayModernStore implements Store {
|
|
|
141
141
|
this._globalInvalidationEpoch = null;
|
|
142
142
|
this._invalidationSubscriptions = new Set();
|
|
143
143
|
this._invalidatedRecordIDs = new Set();
|
|
144
|
-
this.
|
|
144
|
+
this.__log = options?.log ?? null;
|
|
145
145
|
this._queryCacheExpirationTime = options?.queryCacheExpirationTime;
|
|
146
146
|
this._operationLoader = options?.operationLoader ?? null;
|
|
147
147
|
this._optimisticSource = null;
|
|
@@ -285,7 +285,7 @@ class RelayModernStore implements Store {
|
|
|
285
285
|
sourceOperation?: OperationDescriptor,
|
|
286
286
|
invalidateStore?: boolean,
|
|
287
287
|
): $ReadOnlyArray<RequestDescriptor> {
|
|
288
|
-
const log = this.
|
|
288
|
+
const log = this.__log;
|
|
289
289
|
if (log != null) {
|
|
290
290
|
log({
|
|
291
291
|
name: 'store.notify.start',
|
|
@@ -375,7 +375,7 @@ class RelayModernStore implements Store {
|
|
|
375
375
|
);
|
|
376
376
|
// NOTE: log *after* processing the source so that even if a bad log function
|
|
377
377
|
// mutates the source, it doesn't affect Relay processing of it.
|
|
378
|
-
const log = this.
|
|
378
|
+
const log = this.__log;
|
|
379
379
|
if (log != null) {
|
|
380
380
|
log({
|
|
381
381
|
name: 'store.publish',
|
|
@@ -533,7 +533,7 @@ class RelayModernStore implements Store {
|
|
|
533
533
|
'RelayModernStore: Unexpected call to snapshot() while a previous ' +
|
|
534
534
|
'snapshot exists.',
|
|
535
535
|
);
|
|
536
|
-
const log = this.
|
|
536
|
+
const log = this.__log;
|
|
537
537
|
if (log != null) {
|
|
538
538
|
log({
|
|
539
539
|
name: 'store.snapshot',
|
|
@@ -577,7 +577,7 @@ class RelayModernStore implements Store {
|
|
|
577
577
|
'RelayModernStore: Unexpected call to restore(), expected a snapshot ' +
|
|
578
578
|
'to exist (make sure to call snapshot()).',
|
|
579
579
|
);
|
|
580
|
-
const log = this.
|
|
580
|
+
const log = this.__log;
|
|
581
581
|
if (log != null) {
|
|
582
582
|
log({
|
|
583
583
|
name: 'store.restore',
|
|
@@ -664,7 +664,7 @@ class RelayModernStore implements Store {
|
|
|
664
664
|
}
|
|
665
665
|
}
|
|
666
666
|
|
|
667
|
-
const log = this.
|
|
667
|
+
const log = this.__log;
|
|
668
668
|
if (log != null) {
|
|
669
669
|
log({
|
|
670
670
|
name: 'store.gc',
|
|
@@ -318,9 +318,7 @@ class RelayReader {
|
|
|
318
318
|
RelayModernRecord.getDataID(record),
|
|
319
319
|
prevData,
|
|
320
320
|
);
|
|
321
|
-
|
|
322
|
-
* fb,oss) This comment suppresses an error found when Flow v0.98 was
|
|
323
|
-
* deployed. To see the error delete this comment and run Flow. */
|
|
321
|
+
// $FlowFixMe[incompatible-variance]
|
|
324
322
|
data[applicationName] = this._traverse(field, linkedID, prevData);
|
|
325
323
|
}
|
|
326
324
|
|
|
@@ -356,9 +354,7 @@ class RelayReader {
|
|
|
356
354
|
if (linkedID === undefined) {
|
|
357
355
|
this._isMissingData = true;
|
|
358
356
|
}
|
|
359
|
-
|
|
360
|
-
* fb,oss) This comment suppresses an error found when Flow v0.98 was
|
|
361
|
-
* deployed. To see the error delete this comment and run Flow. */
|
|
357
|
+
// $FlowFixMe[cannot-write]
|
|
362
358
|
linkedArray[nextIndex] = linkedID;
|
|
363
359
|
return;
|
|
364
360
|
}
|
|
@@ -371,12 +367,8 @@ class RelayReader {
|
|
|
371
367
|
RelayModernRecord.getDataID(record),
|
|
372
368
|
prevItem,
|
|
373
369
|
);
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
* deployed. To see the error delete this comment and run Flow. */
|
|
377
|
-
/* $FlowFixMe[incompatible-variance] (>=0.98.0 site=www,mobile,react_
|
|
378
|
-
* native_fb,oss) This comment suppresses an error found when Flow v0.98
|
|
379
|
-
* was deployed. To see the error delete this comment and run Flow. */
|
|
370
|
+
// $FlowFixMe[cannot-write]
|
|
371
|
+
// $FlowFixMe[incompatible-variance]
|
|
380
372
|
linkedArray[nextIndex] = this._traverse(field, linkedID, prevItem);
|
|
381
373
|
});
|
|
382
374
|
data[applicationName] = linkedArray;
|
|
@@ -490,15 +490,9 @@ class RelayResponseNormalizer {
|
|
|
490
490
|
);
|
|
491
491
|
const nextID =
|
|
492
492
|
this._getDataId(
|
|
493
|
-
|
|
494
|
-
* native_fb,oss) This comment suppresses an error found when Flow
|
|
495
|
-
* v0.98 was deployed. To see the error delete this comment and run
|
|
496
|
-
* Flow. */
|
|
493
|
+
// $FlowFixMe[incompatible-variance]
|
|
497
494
|
fieldValue,
|
|
498
|
-
|
|
499
|
-
* native_fb,oss) This comment suppresses an error found when Flow
|
|
500
|
-
* v0.98 was deployed. To see the error delete this comment and run
|
|
501
|
-
* Flow. */
|
|
495
|
+
// $FlowFixMe[incompatible-variance]
|
|
502
496
|
field.concreteType ?? this._getRecordType(fieldValue),
|
|
503
497
|
) ||
|
|
504
498
|
// Reuse previously generated client IDs
|
|
@@ -520,18 +514,14 @@ class RelayResponseNormalizer {
|
|
|
520
514
|
RelayModernRecord.setLinkedRecordID(record, storageKey, nextID);
|
|
521
515
|
let nextRecord = this._recordSource.get(nextID);
|
|
522
516
|
if (!nextRecord) {
|
|
523
|
-
|
|
524
|
-
* native_fb,oss) This comment suppresses an error found when Flow v0.98
|
|
525
|
-
* was deployed. To see the error delete this comment and run Flow. */
|
|
517
|
+
// $FlowFixMe[incompatible-variance]
|
|
526
518
|
const typeName = field.concreteType || this._getRecordType(fieldValue);
|
|
527
519
|
nextRecord = RelayModernRecord.create(nextID, typeName);
|
|
528
520
|
this._recordSource.set(nextID, nextRecord);
|
|
529
521
|
} else if (__DEV__) {
|
|
530
522
|
this._validateRecordType(nextRecord, field, fieldValue);
|
|
531
523
|
}
|
|
532
|
-
|
|
533
|
-
* fb,oss) This comment suppresses an error found when Flow v0.98 was
|
|
534
|
-
* deployed. To see the error delete this comment and run Flow. */
|
|
524
|
+
// $FlowFixMe[incompatible-variance]
|
|
535
525
|
this._traverseSelections(field, nextRecord, fieldValue);
|
|
536
526
|
}
|
|
537
527
|
|
|
@@ -564,15 +554,9 @@ class RelayResponseNormalizer {
|
|
|
564
554
|
);
|
|
565
555
|
const nextID =
|
|
566
556
|
this._getDataId(
|
|
567
|
-
|
|
568
|
-
* native_fb,oss) This comment suppresses an error found when Flow
|
|
569
|
-
* v0.98 was deployed. To see the error delete this comment and run
|
|
570
|
-
* Flow. */
|
|
557
|
+
// $FlowFixMe[incompatible-variance]
|
|
571
558
|
item,
|
|
572
|
-
|
|
573
|
-
* native_fb,oss) This comment suppresses an error found when Flow
|
|
574
|
-
* v0.98 was deployed. To see the error delete this comment and run
|
|
575
|
-
* Flow. */
|
|
559
|
+
// $FlowFixMe[incompatible-variance]
|
|
576
560
|
field.concreteType ?? this._getRecordType(item),
|
|
577
561
|
) ||
|
|
578
562
|
(prevIDs && prevIDs[nextIndex]) || // Reuse previously generated client IDs:
|
|
@@ -591,10 +575,7 @@ class RelayResponseNormalizer {
|
|
|
591
575
|
nextIDs.push(nextID);
|
|
592
576
|
let nextRecord = this._recordSource.get(nextID);
|
|
593
577
|
if (!nextRecord) {
|
|
594
|
-
|
|
595
|
-
* native_fb,oss) This comment suppresses an error found when Flow
|
|
596
|
-
* v0.98 was deployed. To see the error delete this comment and run
|
|
597
|
-
* Flow. */
|
|
578
|
+
// $FlowFixMe[incompatible-variance]
|
|
598
579
|
const typeName = field.concreteType || this._getRecordType(item);
|
|
599
580
|
nextRecord = RelayModernRecord.create(nextID, typeName);
|
|
600
581
|
this._recordSource.set(nextID, nextRecord);
|
|
@@ -609,9 +590,7 @@ class RelayResponseNormalizer {
|
|
|
609
590
|
storageKey,
|
|
610
591
|
);
|
|
611
592
|
}
|
|
612
|
-
|
|
613
|
-
* native_fb,oss) This comment suppresses an error found when Flow v0.98
|
|
614
|
-
* was deployed. To see the error delete this comment and run Flow. */
|
|
593
|
+
// $FlowFixMe[incompatible-variance]
|
|
615
594
|
this._traverseSelections(field, nextRecord, item);
|
|
616
595
|
this._path.pop();
|
|
617
596
|
});
|
|
@@ -658,8 +637,8 @@ class RelayResponseNormalizer {
|
|
|
658
637
|
previousValue === undefined ||
|
|
659
638
|
previousValue === fieldValue,
|
|
660
639
|
'RelayResponseNormalizer: Invalid record. The record contains two ' +
|
|
661
|
-
'instances of the same id: `%s` with conflicting field, %s and its values: %s and %s.' +
|
|
662
|
-
'If two fields are different but share' +
|
|
640
|
+
'instances of the same id: `%s` with conflicting field, %s and its values: %s and %s. ' +
|
|
641
|
+
'If two fields are different but share ' +
|
|
663
642
|
'the same id, one field will overwrite the other.',
|
|
664
643
|
dataID,
|
|
665
644
|
storageKey,
|
|
@@ -147,9 +147,7 @@ if (__DEV__) {
|
|
|
147
147
|
return getWrappedRecord(source, value.__ref);
|
|
148
148
|
}
|
|
149
149
|
if (Array.isArray(value.__refs)) {
|
|
150
|
-
|
|
151
|
-
* suppresses an error found when Flow v0.111.0 was deployed. To
|
|
152
|
-
* see the error, delete this comment and run Flow. */
|
|
150
|
+
// $FlowFixMe[incompatible-call]
|
|
153
151
|
return value.__refs.map(ref => getWrappedRecord(source, ref));
|
|
154
152
|
}
|
|
155
153
|
}
|
|
@@ -59,17 +59,11 @@ function recycleNodesInto<T>(prevData: T, nextData: T): T {
|
|
|
59
59
|
if (nextValue !== nextObject[key]) {
|
|
60
60
|
if (__DEV__) {
|
|
61
61
|
if (!Object.isFrozen(nextObject)) {
|
|
62
|
-
|
|
63
|
-
* native_fb,oss) This comment suppresses an error found when
|
|
64
|
-
* Flow v0.98 was deployed. To see the error delete this comment
|
|
65
|
-
* and run Flow. */
|
|
62
|
+
// $FlowFixMe[cannot-write]
|
|
66
63
|
nextObject[key] = nextValue;
|
|
67
64
|
}
|
|
68
65
|
} else {
|
|
69
|
-
|
|
70
|
-
* fb,oss) This comment suppresses an error found when Flow v0.98
|
|
71
|
-
* was deployed. To see the error delete this comment and run Flow.
|
|
72
|
-
*/
|
|
66
|
+
// $FlowFixMe[cannot-write]
|
|
73
67
|
nextObject[key] = nextValue;
|
|
74
68
|
}
|
|
75
69
|
}
|