relay-runtime 10.0.0 → 10.1.2
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/handlers/RelayDefaultHandlerProvider.js.flow +6 -0
- package/handlers/connection/MutationHandlers.js.flow +121 -3
- package/index.js +1 -1
- package/index.js.flow +16 -1
- package/lib/handlers/RelayDefaultHandlerProvider.js +9 -0
- package/lib/handlers/connection/MutationHandlers.js +147 -14
- package/lib/index.js +7 -0
- package/lib/mutations/RelayDeclarativeMutationConfig.js +5 -7
- package/lib/mutations/commitMutation.js +1 -4
- package/lib/mutations/validateMutation.js +28 -12
- package/lib/network/RelayQueryResponseCache.js +3 -7
- package/lib/query/GraphQLTag.js +2 -1
- package/lib/query/fetchQuery.js +2 -3
- package/lib/query/fetchQueryInternal.js +2 -3
- package/lib/store/DataChecker.js +85 -10
- package/lib/store/RelayConcreteVariables.js +2 -6
- package/lib/store/RelayModernEnvironment.js +81 -72
- package/lib/store/RelayModernFragmentSpecResolver.js +14 -7
- package/lib/store/RelayModernOperationDescriptor.js +6 -5
- package/lib/store/RelayModernQueryExecutor.js +46 -33
- package/lib/store/RelayModernRecord.js +3 -7
- package/lib/store/RelayModernStore.js +45 -143
- package/lib/store/RelayOperationTracker.js +7 -9
- package/lib/store/RelayOptimisticRecordSource.js +2 -6
- package/lib/store/RelayPublishQueue.js +1 -1
- package/lib/store/RelayReader.js +200 -49
- package/lib/store/RelayRecordSourceMapImpl.js +3 -5
- package/lib/store/RelayReferenceMarker.js +87 -5
- package/lib/store/RelayResponseNormalizer.js +123 -54
- package/lib/store/RelayStoreReactFlightUtils.js +47 -0
- package/lib/store/RelayStoreSubscriptions.js +162 -0
- package/lib/store/RelayStoreSubscriptionsUsingMapByID.js +258 -0
- package/lib/store/StoreInspector.js +3 -9
- package/lib/store/createRelayContext.js +5 -0
- package/lib/store/defaultRequiredFieldLogger.js +18 -0
- package/lib/store/normalizeRelayPayload.js +2 -6
- package/lib/subscription/requestSubscription.js +2 -3
- package/lib/util/NormalizationNode.js +1 -5
- package/lib/util/RelayConcreteNode.js +2 -0
- package/lib/util/RelayFeatureFlags.js +6 -2
- package/lib/util/createPayloadFor3DField.js +2 -7
- package/lib/util/getFragmentIdentifier.js +12 -3
- package/lib/util/getOperation.js +33 -0
- package/lib/util/isEmptyObject.js +25 -0
- package/lib/util/recycleNodesInto.js +6 -9
- package/lib/util/reportMissingRequiredFields.js +48 -0
- package/mutations/commitMutation.js.flow +1 -2
- package/mutations/validateMutation.js.flow +34 -5
- package/network/RelayNetworkTypes.js.flow +22 -0
- package/package.json +2 -2
- package/query/GraphQLTag.js.flow +3 -1
- package/query/fetchQuery.js.flow +2 -2
- package/query/fetchQueryInternal.js.flow +0 -5
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/DataChecker.js.flow +68 -2
- package/store/RelayModernEnvironment.js.flow +107 -87
- package/store/RelayModernFragmentSpecResolver.js.flow +13 -1
- package/store/RelayModernOperationDescriptor.js.flow +5 -1
- package/store/RelayModernQueryExecutor.js.flow +47 -23
- package/store/RelayModernStore.js.flow +40 -114
- package/store/RelayPublishQueue.js.flow +1 -1
- package/store/RelayReader.js.flow +184 -27
- package/store/RelayReferenceMarker.js.flow +72 -5
- package/store/RelayResponseNormalizer.js.flow +140 -50
- package/store/RelayStoreReactFlightUtils.js.flow +64 -0
- package/store/RelayStoreSubscriptions.js.flow +168 -0
- package/store/RelayStoreSubscriptionsUsingMapByID.js.flow +259 -0
- package/store/RelayStoreTypes.js.flow +130 -37
- package/store/StoreInspector.js.flow +1 -3
- package/store/createRelayContext.js.flow +3 -0
- package/store/defaultRequiredFieldLogger.js.flow +23 -0
- package/subscription/requestSubscription.js.flow +5 -2
- package/util/NormalizationNode.js.flow +17 -2
- package/util/ReaderNode.js.flow +20 -1
- package/util/RelayConcreteNode.js.flow +6 -0
- package/util/RelayFeatureFlags.js.flow +10 -1
- package/util/getFragmentIdentifier.js.flow +33 -9
- package/util/getOperation.js.flow +40 -0
- package/util/isEmptyObject.js.flow +25 -0
- package/util/recycleNodesInto.js.flow +13 -8
- package/util/reportMissingRequiredFields.js.flow +51 -0
|
@@ -12,16 +12,14 @@
|
|
|
12
12
|
|
|
13
13
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
14
14
|
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
15
|
+
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
17
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
22
18
|
|
|
23
19
|
var DataChecker = require('./DataChecker');
|
|
24
20
|
|
|
21
|
+
var RelayFeatureFlags = require('../util/RelayFeatureFlags');
|
|
22
|
+
|
|
25
23
|
var RelayModernRecord = require('./RelayModernRecord');
|
|
26
24
|
|
|
27
25
|
var RelayOptimisticRecordSource = require('./RelayOptimisticRecordSource');
|
|
@@ -32,18 +30,20 @@ var RelayReader = require('./RelayReader');
|
|
|
32
30
|
|
|
33
31
|
var RelayReferenceMarker = require('./RelayReferenceMarker');
|
|
34
32
|
|
|
33
|
+
var RelayStoreReactFlightUtils = require('./RelayStoreReactFlightUtils');
|
|
34
|
+
|
|
35
|
+
var RelayStoreSubscriptions = require('./RelayStoreSubscriptions');
|
|
36
|
+
|
|
37
|
+
var RelayStoreSubscriptionsUsingMapByID = require('./RelayStoreSubscriptionsUsingMapByID');
|
|
38
|
+
|
|
35
39
|
var RelayStoreUtils = require('./RelayStoreUtils');
|
|
36
40
|
|
|
37
41
|
var deepFreeze = require('../util/deepFreeze');
|
|
38
42
|
|
|
39
43
|
var defaultGetDataID = require('./defaultGetDataID');
|
|
40
44
|
|
|
41
|
-
var hasOverlappingIDs = require('./hasOverlappingIDs');
|
|
42
|
-
|
|
43
45
|
var invariant = require("fbjs/lib/invariant");
|
|
44
46
|
|
|
45
|
-
var recycleNodesInto = require('../util/recycleNodesInto');
|
|
46
|
-
|
|
47
47
|
var resolveImmediate = require('../util/resolveImmediate');
|
|
48
48
|
|
|
49
49
|
var _require = require('./RelayStoreUtils'),
|
|
@@ -102,7 +102,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
102
102
|
this._globalInvalidationEpoch = null;
|
|
103
103
|
this._invalidationSubscriptions = new Set();
|
|
104
104
|
this._invalidatedRecordIDs = new Set();
|
|
105
|
-
this.
|
|
105
|
+
this.__log = (_options$log = options === null || options === void 0 ? void 0 : options.log) !== null && _options$log !== void 0 ? _options$log : null;
|
|
106
106
|
this._queryCacheExpirationTime = options === null || options === void 0 ? void 0 : options.queryCacheExpirationTime;
|
|
107
107
|
this._operationLoader = (_options$operationLoa = options === null || options === void 0 ? void 0 : options.operationLoader) !== null && _options$operationLoa !== void 0 ? _options$operationLoa : null;
|
|
108
108
|
this._optimisticSource = null;
|
|
@@ -110,7 +110,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
110
110
|
this._releaseBuffer = [];
|
|
111
111
|
this._roots = new Map();
|
|
112
112
|
this._shouldScheduleGC = false;
|
|
113
|
-
this.
|
|
113
|
+
this._storeSubscriptions = RelayFeatureFlags.ENABLE_STORE_SUBSCRIPTIONS_REFACTOR === true ? new RelayStoreSubscriptionsUsingMapByID() : new RelayStoreSubscriptions();
|
|
114
114
|
this._updatedRecordIDs = {};
|
|
115
115
|
initializeRecordSource(this._recordSource);
|
|
116
116
|
}
|
|
@@ -186,7 +186,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
186
186
|
if (rootEntryIsStale) {
|
|
187
187
|
_this2._roots["delete"](id);
|
|
188
188
|
|
|
189
|
-
_this2.
|
|
189
|
+
_this2.scheduleGC();
|
|
190
190
|
} else {
|
|
191
191
|
_this2._releaseBuffer.push(id); // If the release buffer is now over-full, remove the least-recently
|
|
192
192
|
// added entry and schedule a GC. Note that all items in the release
|
|
@@ -198,7 +198,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
198
198
|
|
|
199
199
|
_this2._roots["delete"](_id);
|
|
200
200
|
|
|
201
|
-
_this2.
|
|
201
|
+
_this2.scheduleGC();
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
}
|
|
@@ -248,7 +248,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
248
248
|
_proto.notify = function notify(sourceOperation, invalidateStore) {
|
|
249
249
|
var _this3 = this;
|
|
250
250
|
|
|
251
|
-
var log = this.
|
|
251
|
+
var log = this.__log;
|
|
252
252
|
|
|
253
253
|
if (log != null) {
|
|
254
254
|
log({
|
|
@@ -267,13 +267,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
267
267
|
var source = this.getSource();
|
|
268
268
|
var updatedOwners = [];
|
|
269
269
|
|
|
270
|
-
this.
|
|
271
|
-
var owner = _this3._updateSubscription(source, subscription);
|
|
272
|
-
|
|
273
|
-
if (owner != null) {
|
|
274
|
-
updatedOwners.push(owner);
|
|
275
|
-
}
|
|
276
|
-
});
|
|
270
|
+
this._storeSubscriptions.updateSubscriptions(source, this._updatedRecordIDs, updatedOwners);
|
|
277
271
|
|
|
278
272
|
this._invalidationSubscriptions.forEach(function (subscription) {
|
|
279
273
|
_this3._updateInvalidationSubscription(subscription, invalidateStore === true);
|
|
@@ -336,7 +330,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
336
330
|
this._currentWriteEpoch + 1, idsMarkedForInvalidation, this._updatedRecordIDs, this._invalidatedRecordIDs); // NOTE: log *after* processing the source so that even if a bad log function
|
|
337
331
|
// mutates the source, it doesn't affect Relay processing of it.
|
|
338
332
|
|
|
339
|
-
var log = this.
|
|
333
|
+
var log = this.__log;
|
|
340
334
|
|
|
341
335
|
if (log != null) {
|
|
342
336
|
log({
|
|
@@ -348,28 +342,11 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
348
342
|
};
|
|
349
343
|
|
|
350
344
|
_proto.subscribe = function subscribe(snapshot, callback) {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
var subscription = {
|
|
354
|
-
backup: null,
|
|
355
|
-
callback: callback,
|
|
356
|
-
snapshot: snapshot,
|
|
357
|
-
stale: false
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
var dispose = function dispose() {
|
|
361
|
-
_this4._subscriptions["delete"](subscription);
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
this._subscriptions.add(subscription);
|
|
365
|
-
|
|
366
|
-
return {
|
|
367
|
-
dispose: dispose
|
|
368
|
-
};
|
|
345
|
+
return this._storeSubscriptions.subscribe(snapshot, callback);
|
|
369
346
|
};
|
|
370
347
|
|
|
371
348
|
_proto.holdGC = function holdGC() {
|
|
372
|
-
var
|
|
349
|
+
var _this4 = this;
|
|
373
350
|
|
|
374
351
|
if (this._gcRun) {
|
|
375
352
|
this._gcRun = null;
|
|
@@ -379,13 +356,13 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
379
356
|
this._gcHoldCounter++;
|
|
380
357
|
|
|
381
358
|
var dispose = function dispose() {
|
|
382
|
-
if (
|
|
383
|
-
|
|
359
|
+
if (_this4._gcHoldCounter > 0) {
|
|
360
|
+
_this4._gcHoldCounter--;
|
|
384
361
|
|
|
385
|
-
if (
|
|
386
|
-
|
|
362
|
+
if (_this4._gcHoldCounter === 0 && _this4._shouldScheduleGC) {
|
|
363
|
+
_this4.scheduleGC();
|
|
387
364
|
|
|
388
|
-
|
|
365
|
+
_this4._shouldScheduleGC = false;
|
|
389
366
|
}
|
|
390
367
|
}
|
|
391
368
|
};
|
|
@@ -402,51 +379,16 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
402
379
|
|
|
403
380
|
_proto.__getUpdatedRecordIDs = function __getUpdatedRecordIDs() {
|
|
404
381
|
return this._updatedRecordIDs;
|
|
405
|
-
} // Returns the owner (RequestDescriptor) if the subscription was affected by the
|
|
406
|
-
// latest update, or null if it was not affected.
|
|
407
|
-
;
|
|
408
|
-
|
|
409
|
-
_proto._updateSubscription = function _updateSubscription(source, subscription) {
|
|
410
|
-
var backup = subscription.backup,
|
|
411
|
-
callback = subscription.callback,
|
|
412
|
-
snapshot = subscription.snapshot,
|
|
413
|
-
stale = subscription.stale;
|
|
414
|
-
var hasOverlappingUpdates = hasOverlappingIDs(snapshot.seenRecords, this._updatedRecordIDs);
|
|
415
|
-
|
|
416
|
-
if (!stale && !hasOverlappingUpdates) {
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
var nextSnapshot = hasOverlappingUpdates || !backup ? RelayReader.read(source, snapshot.selector) : backup;
|
|
421
|
-
var nextData = recycleNodesInto(snapshot.data, nextSnapshot.data);
|
|
422
|
-
nextSnapshot = {
|
|
423
|
-
data: nextData,
|
|
424
|
-
isMissingData: nextSnapshot.isMissingData,
|
|
425
|
-
seenRecords: nextSnapshot.seenRecords,
|
|
426
|
-
selector: nextSnapshot.selector
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
if (process.env.NODE_ENV !== "production") {
|
|
430
|
-
deepFreeze(nextSnapshot);
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
subscription.snapshot = nextSnapshot;
|
|
434
|
-
subscription.stale = false;
|
|
435
|
-
|
|
436
|
-
if (nextSnapshot.data !== snapshot.data) {
|
|
437
|
-
callback(nextSnapshot);
|
|
438
|
-
return snapshot.selector.owner;
|
|
439
|
-
}
|
|
440
382
|
};
|
|
441
383
|
|
|
442
384
|
_proto.lookupInvalidationState = function lookupInvalidationState(dataIDs) {
|
|
443
|
-
var
|
|
385
|
+
var _this5 = this;
|
|
444
386
|
|
|
445
387
|
var invalidations = new Map();
|
|
446
388
|
dataIDs.forEach(function (dataID) {
|
|
447
389
|
var _RelayModernRecord$ge;
|
|
448
390
|
|
|
449
|
-
var record =
|
|
391
|
+
var record = _this5.getSource().get(dataID);
|
|
450
392
|
|
|
451
393
|
invalidations.set(dataID, (_RelayModernRecord$ge = RelayModernRecord.getInvalidationEpoch(record)) !== null && _RelayModernRecord$ge !== void 0 ? _RelayModernRecord$ge : null);
|
|
452
394
|
});
|
|
@@ -467,7 +409,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
467
409
|
} // Check if the invalidation state for any of the ids has changed.
|
|
468
410
|
|
|
469
411
|
|
|
470
|
-
var _iterator =
|
|
412
|
+
var _iterator = (0, _createForOfIteratorHelper2["default"])(prevInvalidationState.dataIDs),
|
|
471
413
|
_step;
|
|
472
414
|
|
|
473
415
|
try {
|
|
@@ -488,7 +430,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
488
430
|
};
|
|
489
431
|
|
|
490
432
|
_proto.subscribeToInvalidationState = function subscribeToInvalidationState(invalidationState, callback) {
|
|
491
|
-
var
|
|
433
|
+
var _this6 = this;
|
|
492
434
|
|
|
493
435
|
var subscription = {
|
|
494
436
|
callback: callback,
|
|
@@ -496,7 +438,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
496
438
|
};
|
|
497
439
|
|
|
498
440
|
var dispose = function dispose() {
|
|
499
|
-
|
|
441
|
+
_this6._invalidationSubscriptions["delete"](subscription);
|
|
500
442
|
};
|
|
501
443
|
|
|
502
444
|
this._invalidationSubscriptions.add(subscription);
|
|
@@ -507,13 +449,13 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
507
449
|
};
|
|
508
450
|
|
|
509
451
|
_proto._updateInvalidationSubscription = function _updateInvalidationSubscription(subscription, invalidatedStore) {
|
|
510
|
-
var
|
|
452
|
+
var _this7 = this;
|
|
511
453
|
|
|
512
454
|
var callback = subscription.callback,
|
|
513
455
|
invalidationState = subscription.invalidationState;
|
|
514
456
|
var dataIDs = invalidationState.dataIDs;
|
|
515
457
|
var isSubscribedToInvalidatedIDs = invalidatedStore || dataIDs.some(function (dataID) {
|
|
516
|
-
return
|
|
458
|
+
return _this7._invalidatedRecordIDs.has(dataID);
|
|
517
459
|
});
|
|
518
460
|
|
|
519
461
|
if (!isSubscribedToInvalidatedIDs) {
|
|
@@ -524,10 +466,8 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
524
466
|
};
|
|
525
467
|
|
|
526
468
|
_proto.snapshot = function snapshot() {
|
|
527
|
-
var _this9 = this;
|
|
528
|
-
|
|
529
469
|
!(this._optimisticSource == null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayModernStore: Unexpected call to snapshot() while a previous ' + 'snapshot exists.') : invariant(false) : void 0;
|
|
530
|
-
var log = this.
|
|
470
|
+
var log = this.__log;
|
|
531
471
|
|
|
532
472
|
if (log != null) {
|
|
533
473
|
log({
|
|
@@ -535,31 +475,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
535
475
|
});
|
|
536
476
|
}
|
|
537
477
|
|
|
538
|
-
this.
|
|
539
|
-
// Backup occurs after writing a new "final" payload(s) and before (re)applying
|
|
540
|
-
// optimistic changes. Each subscription's `snapshot` represents what was *last
|
|
541
|
-
// published to the subscriber*, which notably may include previous optimistic
|
|
542
|
-
// updates. Therefore a subscription can be in any of the following states:
|
|
543
|
-
// - stale=true: This subscription was restored to a different value than
|
|
544
|
-
// `snapshot`. That means this subscription has changes relative to its base,
|
|
545
|
-
// but its base has changed (we just applied a final payload): recompute
|
|
546
|
-
// a backup so that we can later restore to the state the subscription
|
|
547
|
-
// should be in.
|
|
548
|
-
// - stale=false: This subscription was restored to the same value than
|
|
549
|
-
// `snapshot`. That means this subscription does *not* have changes relative
|
|
550
|
-
// to its base, so the current `snapshot` is valid to use as a backup.
|
|
551
|
-
if (!subscription.stale) {
|
|
552
|
-
subscription.backup = subscription.snapshot;
|
|
553
|
-
return;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
var snapshot = subscription.snapshot;
|
|
557
|
-
var backup = RelayReader.read(_this9.getSource(), snapshot.selector);
|
|
558
|
-
var nextData = recycleNodesInto(snapshot.data, backup.data);
|
|
559
|
-
backup.data = nextData; // backup owns the snapshot and can safely mutate
|
|
560
|
-
|
|
561
|
-
subscription.backup = backup;
|
|
562
|
-
});
|
|
478
|
+
this._storeSubscriptions.snapshotSubscriptions(this.getSource());
|
|
563
479
|
|
|
564
480
|
if (this._gcRun) {
|
|
565
481
|
this._gcRun = null;
|
|
@@ -571,7 +487,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
571
487
|
|
|
572
488
|
_proto.restore = function restore() {
|
|
573
489
|
!(this._optimisticSource != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayModernStore: Unexpected call to restore(), expected a snapshot ' + 'to exist (make sure to call snapshot()).') : invariant(false) : void 0;
|
|
574
|
-
var log = this.
|
|
490
|
+
var log = this.__log;
|
|
575
491
|
|
|
576
492
|
if (log != null) {
|
|
577
493
|
log({
|
|
@@ -582,31 +498,13 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
582
498
|
this._optimisticSource = null;
|
|
583
499
|
|
|
584
500
|
if (this._shouldScheduleGC) {
|
|
585
|
-
this.
|
|
501
|
+
this.scheduleGC();
|
|
586
502
|
}
|
|
587
503
|
|
|
588
|
-
this.
|
|
589
|
-
var backup = subscription.backup;
|
|
590
|
-
subscription.backup = null;
|
|
591
|
-
|
|
592
|
-
if (backup) {
|
|
593
|
-
if (backup.data !== subscription.snapshot.data) {
|
|
594
|
-
subscription.stale = true;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
subscription.snapshot = {
|
|
598
|
-
data: subscription.snapshot.data,
|
|
599
|
-
isMissingData: backup.isMissingData,
|
|
600
|
-
seenRecords: backup.seenRecords,
|
|
601
|
-
selector: backup.selector
|
|
602
|
-
};
|
|
603
|
-
} else {
|
|
604
|
-
subscription.stale = true;
|
|
605
|
-
}
|
|
606
|
-
});
|
|
504
|
+
this._storeSubscriptions.restoreSubscriptions();
|
|
607
505
|
};
|
|
608
506
|
|
|
609
|
-
_proto.
|
|
507
|
+
_proto.scheduleGC = function scheduleGC() {
|
|
610
508
|
if (this._gcHoldCounter > 0) {
|
|
611
509
|
this._shouldScheduleGC = true;
|
|
612
510
|
return;
|
|
@@ -642,7 +540,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
642
540
|
var startEpoch = this._currentWriteEpoch;
|
|
643
541
|
var references = new Set(); // Mark all records that are traversable from a root
|
|
644
542
|
|
|
645
|
-
var _iterator2 =
|
|
543
|
+
var _iterator2 = (0, _createForOfIteratorHelper2["default"])(this._roots.values()),
|
|
646
544
|
_step2;
|
|
647
545
|
|
|
648
546
|
try {
|
|
@@ -663,7 +561,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
663
561
|
_iterator2.f();
|
|
664
562
|
}
|
|
665
563
|
|
|
666
|
-
var log = this.
|
|
564
|
+
var log = this.__log;
|
|
667
565
|
|
|
668
566
|
if (log != null) {
|
|
669
567
|
log({
|
|
@@ -705,7 +603,7 @@ function initializeRecordSource(target) {
|
|
|
705
603
|
/**
|
|
706
604
|
* Updates the target with information from source, also updating a mapping of
|
|
707
605
|
* which records in the target were changed as a result.
|
|
708
|
-
* Additionally, will
|
|
606
|
+
* Additionally, will mark records as invalidated at the current write epoch
|
|
709
607
|
* given the set of record ids marked as stale in this update.
|
|
710
608
|
*/
|
|
711
609
|
|
|
@@ -767,7 +665,11 @@ function updateTargetFromSource(target, source, currentWriteEpoch, idsMarkedForI
|
|
|
767
665
|
}
|
|
768
666
|
|
|
769
667
|
if (sourceRecord && targetRecord) {
|
|
770
|
-
|
|
668
|
+
// ReactFlightClientResponses are lazy and only materialize when readRoot
|
|
669
|
+
// is called when we read the field, so if the record is a Flight field
|
|
670
|
+
// we always use the new record's data regardless of whether
|
|
671
|
+
// it actually changed. Let React take care of reconciliation instead.
|
|
672
|
+
var nextRecord = RelayModernRecord.getType(targetRecord) === RelayStoreReactFlightUtils.REACT_FLIGHT_TYPE_NAME ? sourceRecord : RelayModernRecord.update(targetRecord, sourceRecord);
|
|
771
673
|
|
|
772
674
|
if (nextRecord !== targetRecord) {
|
|
773
675
|
// Prevent mutation of a record from outside the store.
|
|
@@ -10,11 +10,9 @@
|
|
|
10
10
|
// flowlint ambiguous-object-type:error
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
15
|
+
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
18
16
|
|
|
19
17
|
var invariant = require("fbjs/lib/invariant");
|
|
20
18
|
|
|
@@ -39,7 +37,7 @@ var RelayOperationTracker = /*#__PURE__*/function () {
|
|
|
39
37
|
|
|
40
38
|
var newlyAffectedOwners = new Set();
|
|
41
39
|
|
|
42
|
-
var _iterator =
|
|
40
|
+
var _iterator = (0, _createForOfIteratorHelper2["default"])(affectedOwners),
|
|
43
41
|
_step;
|
|
44
42
|
|
|
45
43
|
try {
|
|
@@ -78,7 +76,7 @@ var RelayOperationTracker = /*#__PURE__*/function () {
|
|
|
78
76
|
|
|
79
77
|
var ownersAffectedByOperation = this._pendingOperationsToOwners.get(pendingOperation) || new Set();
|
|
80
78
|
|
|
81
|
-
var _iterator2 =
|
|
79
|
+
var _iterator2 = (0, _createForOfIteratorHelper2["default"])(newlyAffectedOwners),
|
|
82
80
|
_step2;
|
|
83
81
|
|
|
84
82
|
try {
|
|
@@ -116,7 +114,7 @@ var RelayOperationTracker = /*#__PURE__*/function () {
|
|
|
116
114
|
|
|
117
115
|
var updatedOwners = new Set();
|
|
118
116
|
|
|
119
|
-
var _iterator3 =
|
|
117
|
+
var _iterator3 = (0, _createForOfIteratorHelper2["default"])(affectedOwners),
|
|
120
118
|
_step3;
|
|
121
119
|
|
|
122
120
|
try {
|
|
@@ -144,7 +142,7 @@ var RelayOperationTracker = /*#__PURE__*/function () {
|
|
|
144
142
|
_iterator3.f();
|
|
145
143
|
}
|
|
146
144
|
|
|
147
|
-
var _iterator4 =
|
|
145
|
+
var _iterator4 = (0, _createForOfIteratorHelper2["default"])(completedOwners),
|
|
148
146
|
_step4;
|
|
149
147
|
|
|
150
148
|
try {
|
|
@@ -163,7 +161,7 @@ var RelayOperationTracker = /*#__PURE__*/function () {
|
|
|
163
161
|
_iterator4.f();
|
|
164
162
|
}
|
|
165
163
|
|
|
166
|
-
var _iterator5 =
|
|
164
|
+
var _iterator5 = (0, _createForOfIteratorHelper2["default"])(updatedOwners),
|
|
167
165
|
_step5;
|
|
168
166
|
|
|
169
167
|
try {
|
|
@@ -12,11 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
14
14
|
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
18
|
-
|
|
19
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
15
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
20
16
|
|
|
21
17
|
var RelayRecordSource = require('./RelayRecordSource');
|
|
22
18
|
|
|
@@ -102,7 +98,7 @@ var RelayOptimisticRecordSource = /*#__PURE__*/function () {
|
|
|
102
98
|
_proto.toJSON = function toJSON() {
|
|
103
99
|
var _this = this;
|
|
104
100
|
|
|
105
|
-
var merged =
|
|
101
|
+
var merged = (0, _objectSpread2["default"])({}, this._base.toJSON());
|
|
106
102
|
|
|
107
103
|
this._sink.getRecordIDs().forEach(function (dataID) {
|
|
108
104
|
var record = _this.get(dataID);
|
|
@@ -146,7 +146,7 @@ var RelayPublishQueue = /*#__PURE__*/function () {
|
|
|
146
146
|
|
|
147
147
|
_proto.run = function run(sourceOperation) {
|
|
148
148
|
if (process.env.NODE_ENV !== "production") {
|
|
149
|
-
process.env.NODE_ENV !== "production" ? warning(this._isRunning !== true, 'A store update was detected within another store update. Please ' +
|
|
149
|
+
process.env.NODE_ENV !== "production" ? warning(this._isRunning !== true, 'A store update was detected within another store update. Please ' + "make sure new store updates aren't being executed within an " + 'updater function for a different update.') : void 0;
|
|
150
150
|
this._isRunning = true;
|
|
151
151
|
}
|
|
152
152
|
|