relay-runtime 11.0.1 → 11.0.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/index.js +1 -1
- package/index.js.flow +4 -2
- package/lib/handlers/RelayDefaultHandlerProvider.js +1 -1
- package/lib/handlers/connection/ConnectionHandler.js +1 -1
- package/lib/handlers/connection/MutationHandlers.js +1 -1
- package/lib/multi-actor-environment/ActorIdentifier.js +23 -0
- package/lib/multi-actor-environment/ActorSpecificEnvironment.js +108 -0
- package/lib/multi-actor-environment/MultiActorEnvironment.js +156 -0
- package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +11 -0
- package/lib/multi-actor-environment/index.js +17 -0
- package/lib/mutations/RelayRecordProxy.js +1 -1
- package/lib/mutations/RelayRecordSourceMutator.js +1 -1
- package/lib/mutations/RelayRecordSourceProxy.js +1 -1
- package/lib/mutations/RelayRecordSourceSelectorProxy.js +1 -1
- package/lib/mutations/applyOptimisticMutation.js +1 -1
- package/lib/mutations/commitMutation.js +1 -1
- package/lib/network/RelayNetwork.js +1 -1
- package/lib/network/RelayQueryResponseCache.js +1 -1
- package/lib/query/GraphQLTag.js +1 -1
- package/lib/query/fetchQuery.js +1 -1
- package/lib/query/fetchQueryInternal.js +1 -1
- package/lib/store/DataChecker.js +1 -1
- package/lib/store/{RelayModernQueryExecutor.js → OperationExecutor.js} +81 -37
- package/lib/store/RelayConcreteVariables.js +1 -1
- package/lib/store/RelayModernEnvironment.js +99 -144
- package/lib/store/RelayModernFragmentSpecResolver.js +1 -1
- package/lib/store/RelayModernRecord.js +1 -1
- package/lib/store/RelayModernSelector.js +1 -1
- package/lib/store/RelayModernStore.js +1 -6
- package/lib/store/RelayOperationTracker.js +1 -1
- package/lib/store/RelayPublishQueue.js +9 -5
- package/lib/store/RelayReader.js +63 -10
- package/lib/store/RelayReferenceMarker.js +1 -1
- package/lib/store/RelayResponseNormalizer.js +47 -22
- package/lib/store/RelayStoreReactFlightUtils.js +1 -1
- package/lib/store/RelayStoreUtils.js +1 -1
- package/lib/store/ResolverFragments.js +57 -0
- package/lib/store/cloneRelayHandleSourceField.js +1 -1
- package/lib/store/cloneRelayScalarHandleSourceField.js +1 -1
- package/lib/store/createRelayContext.js +1 -1
- package/lib/store/readInlineData.js +1 -1
- package/lib/subscription/requestSubscription.js +18 -7
- package/lib/util/RelayConcreteNode.js +1 -0
- package/lib/util/RelayFeatureFlags.js +3 -1
- package/lib/util/RelayProfiler.js +17 -187
- package/lib/util/RelayReplaySubject.js +1 -1
- package/lib/util/getRelayHandleKey.js +1 -1
- package/lib/util/getRequestIdentifier.js +1 -1
- package/multi-actor-environment/ActorIdentifier.js.flow +27 -0
- package/multi-actor-environment/ActorSpecificEnvironment.js.flow +189 -0
- package/multi-actor-environment/MultiActorEnvironment.js.flow +233 -0
- package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +196 -0
- package/multi-actor-environment/index.js.flow +24 -0
- package/network/RelayNetworkTypes.js.flow +5 -4
- package/package.json +3 -2
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/{RelayModernQueryExecutor.js.flow → OperationExecutor.js.flow} +82 -35
- package/store/RelayModernEnvironment.js.flow +88 -131
- package/store/RelayModernStore.js.flow +0 -5
- package/store/RelayPublishQueue.js.flow +7 -4
- package/store/RelayReader.js.flow +57 -5
- package/store/RelayResponseNormalizer.js.flow +67 -26
- package/store/RelayStoreTypes.js.flow +15 -8
- package/store/ResolverFragments.js.flow +125 -0
- package/subscription/requestSubscription.js.flow +15 -7
- package/util/ReaderNode.js.flow +14 -1
- package/util/RelayConcreteNode.js.flow +1 -0
- package/util/RelayFeatureFlags.js.flow +4 -0
- package/util/RelayProfiler.js.flow +22 -194
- package/util/RelayRuntimeTypes.js.flow +3 -1
|
@@ -33,7 +33,7 @@ var RelayResponseNormalizer = require('./RelayResponseNormalizer');
|
|
|
33
33
|
|
|
34
34
|
var getOperation = require('../util/getOperation');
|
|
35
35
|
|
|
36
|
-
var invariant = require(
|
|
36
|
+
var invariant = require('invariant');
|
|
37
37
|
|
|
38
38
|
var stableCopy = require('../util/stableCopy');
|
|
39
39
|
|
|
@@ -163,7 +163,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
163
163
|
this._optimisticUpdates = null;
|
|
164
164
|
optimisticUpdates.forEach(function (update) {
|
|
165
165
|
return _this2._publishQueue.revertUpdate(update);
|
|
166
|
-
});
|
|
166
|
+
}); // OK: run revert on cancel
|
|
167
167
|
|
|
168
168
|
this._publishQueue.run();
|
|
169
169
|
}
|
|
@@ -209,7 +209,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
209
209
|
|
|
210
210
|
default:
|
|
211
211
|
this._state;
|
|
212
|
-
!false ? process.env.NODE_ENV !== "production" ? invariant(false, '
|
|
212
|
+
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: invalid executor state.') : invariant(false) : void 0;
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
this._operationExecutions.set(this._operation.request.identifier, activeState);
|
|
@@ -342,7 +342,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
342
342
|
var isOptimistic = ((_response$extensions = response.extensions) === null || _response$extensions === void 0 ? void 0 : _response$extensions.isOptimistic) === true;
|
|
343
343
|
|
|
344
344
|
if (isOptimistic && this._state !== 'started') {
|
|
345
|
-
!false ? process.env.NODE_ENV !== "production" ? invariant(false, '
|
|
345
|
+
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: optimistic payload received after server payload.') : invariant(false) : void 0;
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
if (isOptimistic) {
|
|
@@ -396,7 +396,9 @@ var Executor = /*#__PURE__*/function () {
|
|
|
396
396
|
|
|
397
397
|
var _partitionGraphQLResp = partitionGraphQLResponses(responsesWithData),
|
|
398
398
|
nonIncrementalResponses = _partitionGraphQLResp[0],
|
|
399
|
-
incrementalResponses = _partitionGraphQLResp[1];
|
|
399
|
+
incrementalResponses = _partitionGraphQLResp[1];
|
|
400
|
+
|
|
401
|
+
var hasNonIncrementalResponses = nonIncrementalResponses.length > 0; // In theory this doesn't preserve the ordering of the batch.
|
|
400
402
|
// The idea is that a batch is always:
|
|
401
403
|
// * at most one non-incremental payload
|
|
402
404
|
// * followed by zero or more incremental payloads
|
|
@@ -404,37 +406,68 @@ var Executor = /*#__PURE__*/function () {
|
|
|
404
406
|
// with the initial payload followed by some early-to-resolve incremental
|
|
405
407
|
// payloads (although, can that even happen?)
|
|
406
408
|
|
|
409
|
+
if (hasNonIncrementalResponses) {
|
|
410
|
+
var payloadFollowups = this._processResponses(nonIncrementalResponses);
|
|
407
411
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
// queue here, which will later passed to the store (via notify)
|
|
411
|
-
// to indicate that this is an operation that caused the store to update
|
|
412
|
-
|
|
412
|
+
if (!RelayFeatureFlags.ENABLE_BATCHED_STORE_UPDATES) {
|
|
413
|
+
var updatedOwners = this._publishQueue.run(this._operation);
|
|
413
414
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
this._updateOperationTracker(updatedOwners);
|
|
415
|
+
this._updateOperationTracker(updatedOwners);
|
|
416
|
+
}
|
|
417
417
|
|
|
418
418
|
this._processPayloadFollowups(payloadFollowups);
|
|
419
419
|
|
|
420
|
-
if (
|
|
421
|
-
this.
|
|
420
|
+
if (!RelayFeatureFlags.ENABLE_BATCHED_STORE_UPDATES) {
|
|
421
|
+
if (this._incrementalPayloadsPending && !this._retainDisposable) {
|
|
422
|
+
this._retainDisposable = this._store.retain(this._operation);
|
|
423
|
+
}
|
|
422
424
|
}
|
|
423
425
|
}
|
|
424
426
|
|
|
425
427
|
if (incrementalResponses.length > 0) {
|
|
426
|
-
var _payloadFollowups = this._processIncrementalResponses(incrementalResponses);
|
|
427
|
-
// for already initiated operation (and we're not passing it to
|
|
428
|
-
// the run(...) call)
|
|
428
|
+
var _payloadFollowups = this._processIncrementalResponses(incrementalResponses);
|
|
429
429
|
|
|
430
|
+
if (!RelayFeatureFlags.ENABLE_BATCHED_STORE_UPDATES) {
|
|
431
|
+
// For the incremental case, we're only handling follow-up responses
|
|
432
|
+
// for already initiated operation (and we're not passing it to
|
|
433
|
+
// the run(...) call)
|
|
434
|
+
var _updatedOwners = this._publishQueue.run();
|
|
430
435
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
this._updateOperationTracker(_updatedOwners);
|
|
436
|
+
this._updateOperationTracker(_updatedOwners);
|
|
437
|
+
}
|
|
434
438
|
|
|
435
439
|
this._processPayloadFollowups(_payloadFollowups);
|
|
436
440
|
}
|
|
437
441
|
|
|
442
|
+
if (this._isSubscriptionOperation && RelayFeatureFlags.ENABLE_UNIQUE_SUBSCRIPTION_ROOT) {
|
|
443
|
+
// We attach the id to allow the `requestSubscription` to read from the store using
|
|
444
|
+
// the current id in its `onNext` callback
|
|
445
|
+
if (responsesWithData[0].extensions == null) {
|
|
446
|
+
// $FlowFixMe[cannot-write]
|
|
447
|
+
responsesWithData[0].extensions = {
|
|
448
|
+
__relay_subscription_root_id: this._operation.fragment.dataID
|
|
449
|
+
};
|
|
450
|
+
} else {
|
|
451
|
+
responsesWithData[0].extensions.__relay_subscription_root_id = this._operation.fragment.dataID;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
if (RelayFeatureFlags.ENABLE_BATCHED_STORE_UPDATES) {
|
|
456
|
+
// OK: run once after each new payload
|
|
457
|
+
// If we have non-incremental responses, we passing `this._operation` to
|
|
458
|
+
// the publish queue here, which will later be passed to the store (via
|
|
459
|
+
// notify) to indicate that this operation caused the store to update
|
|
460
|
+
var _updatedOwners2 = this._publishQueue.run(hasNonIncrementalResponses ? this._operation : undefined);
|
|
461
|
+
|
|
462
|
+
if (hasNonIncrementalResponses) {
|
|
463
|
+
if (this._incrementalPayloadsPending && !this._retainDisposable) {
|
|
464
|
+
this._retainDisposable = this._store.retain(this._operation);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
this._updateOperationTracker(_updatedOwners2);
|
|
469
|
+
}
|
|
470
|
+
|
|
438
471
|
this._sink.next(response);
|
|
439
472
|
};
|
|
440
473
|
|
|
@@ -484,7 +517,8 @@ var Executor = /*#__PURE__*/function () {
|
|
|
484
517
|
this._optimisticUpdates = optimisticUpdates;
|
|
485
518
|
optimisticUpdates.forEach(function (update) {
|
|
486
519
|
return _this6._publishQueue.applyUpdate(update);
|
|
487
|
-
});
|
|
520
|
+
}); // OK: only called on construction and when receiving an optimistic payload from network,
|
|
521
|
+
// which doesn't fall-through to the regular next() handling
|
|
488
522
|
|
|
489
523
|
this._publishQueue.run();
|
|
490
524
|
};
|
|
@@ -566,11 +600,12 @@ var Executor = /*#__PURE__*/function () {
|
|
|
566
600
|
});
|
|
567
601
|
|
|
568
602
|
if (_this7._optimisticUpdates == null) {
|
|
569
|
-
process.env.NODE_ENV !== "production" ? warning(false, '
|
|
603
|
+
process.env.NODE_ENV !== "production" ? warning(false, 'OperationExecutor: Unexpected ModuleImport optimistic ' + 'update in operation %s.' + _this7._operation.request.node.params.name) : void 0;
|
|
570
604
|
} else {
|
|
571
605
|
var _this$_optimisticUpda;
|
|
572
606
|
|
|
573
|
-
(_this$_optimisticUpda = _this7._optimisticUpdates).push.apply(_this$_optimisticUpda, (0, _toConsumableArray2["default"])(moduleImportOptimisticUpdates));
|
|
607
|
+
(_this$_optimisticUpda = _this7._optimisticUpdates).push.apply(_this$_optimisticUpda, (0, _toConsumableArray2["default"])(moduleImportOptimisticUpdates)); // OK: always have to run() after an module import resolves async
|
|
608
|
+
|
|
574
609
|
|
|
575
610
|
_this7._publishQueue.run();
|
|
576
611
|
}
|
|
@@ -667,9 +702,11 @@ var Executor = /*#__PURE__*/function () {
|
|
|
667
702
|
});
|
|
668
703
|
|
|
669
704
|
if (relayPayloads.length > 0) {
|
|
670
|
-
|
|
705
|
+
if (!RelayFeatureFlags.ENABLE_BATCHED_STORE_UPDATES) {
|
|
706
|
+
var updatedOwners = _this9._publishQueue.run();
|
|
671
707
|
|
|
672
|
-
|
|
708
|
+
_this9._updateOperationTracker(updatedOwners);
|
|
709
|
+
}
|
|
673
710
|
|
|
674
711
|
_this9._processPayloadFollowups(relayPayloads);
|
|
675
712
|
}
|
|
@@ -738,7 +775,12 @@ var Executor = /*#__PURE__*/function () {
|
|
|
738
775
|
})).map(function (operation) {
|
|
739
776
|
if (operation != null) {
|
|
740
777
|
_this10._schedule(function () {
|
|
741
|
-
_this10._handleModuleImportPayload(moduleImportPayload, getOperation(operation));
|
|
778
|
+
_this10._handleModuleImportPayload(moduleImportPayload, getOperation(operation)); // OK: always have to run after an async module import resolves
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
var updatedOwners = _this10._publishQueue.run();
|
|
782
|
+
|
|
783
|
+
_this10._updateOperationTracker(updatedOwners);
|
|
742
784
|
});
|
|
743
785
|
}
|
|
744
786
|
}).subscribe({
|
|
@@ -764,9 +806,11 @@ var Executor = /*#__PURE__*/function () {
|
|
|
764
806
|
|
|
765
807
|
this._publishQueue.commitPayload(this._operation, relayPayload);
|
|
766
808
|
|
|
767
|
-
|
|
809
|
+
if (!RelayFeatureFlags.ENABLE_BATCHED_STORE_UPDATES) {
|
|
810
|
+
var updatedOwners = this._publishQueue.run();
|
|
768
811
|
|
|
769
|
-
|
|
812
|
+
this._updateOperationTracker(updatedOwners);
|
|
813
|
+
}
|
|
770
814
|
|
|
771
815
|
this._processPayloadFollowups([relayPayload]);
|
|
772
816
|
}
|
|
@@ -865,9 +909,11 @@ var Executor = /*#__PURE__*/function () {
|
|
|
865
909
|
if (pendingResponses != null) {
|
|
866
910
|
var payloadFollowups = this._processIncrementalResponses(pendingResponses);
|
|
867
911
|
|
|
868
|
-
|
|
912
|
+
if (!RelayFeatureFlags.ENABLE_BATCHED_STORE_UPDATES) {
|
|
913
|
+
var updatedOwners = this._publishQueue.run();
|
|
869
914
|
|
|
870
|
-
|
|
915
|
+
this._updateOperationTracker(updatedOwners);
|
|
916
|
+
}
|
|
871
917
|
|
|
872
918
|
this._processPayloadFollowups(payloadFollowups);
|
|
873
919
|
}
|
|
@@ -1120,15 +1166,13 @@ var Executor = /*#__PURE__*/function () {
|
|
|
1120
1166
|
};
|
|
1121
1167
|
|
|
1122
1168
|
_proto._updateOperationTracker = function _updateOperationTracker(updatedOwners) {
|
|
1123
|
-
if (
|
|
1169
|
+
if (updatedOwners != null && updatedOwners.length > 0) {
|
|
1124
1170
|
this._operationTracker.update(this._operation.request, new Set(updatedOwners));
|
|
1125
1171
|
}
|
|
1126
1172
|
};
|
|
1127
1173
|
|
|
1128
1174
|
_proto._completeOperationTracker = function _completeOperationTracker() {
|
|
1129
|
-
|
|
1130
|
-
this._operationTracker.complete(this._operation.request);
|
|
1131
|
-
}
|
|
1175
|
+
this._operationTracker.complete(this._operation.request);
|
|
1132
1176
|
};
|
|
1133
1177
|
|
|
1134
1178
|
return Executor;
|
|
@@ -1143,7 +1187,7 @@ function partitionGraphQLResponses(responses) {
|
|
|
1143
1187
|
path = response.path;
|
|
1144
1188
|
|
|
1145
1189
|
if (label == null || path == null) {
|
|
1146
|
-
!false ? process.env.NODE_ENV !== "production" ? invariant(false, '
|
|
1190
|
+
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: invalid incremental payload, expected ' + '`path` and `label` to either both be null/undefined, or ' + '`path` to be an `Array<string | number>` and `label` to be a ' + '`string`.') : invariant(false) : void 0;
|
|
1147
1191
|
}
|
|
1148
1192
|
|
|
1149
1193
|
incrementalResponses.push({
|
|
@@ -1183,7 +1227,7 @@ function validateOptimisticResponsePayload(payload) {
|
|
|
1183
1227
|
var incrementalPlaceholders = payload.incrementalPlaceholders;
|
|
1184
1228
|
|
|
1185
1229
|
if (incrementalPlaceholders != null && incrementalPlaceholders.length !== 0) {
|
|
1186
|
-
!false ? process.env.NODE_ENV !== "production" ? invariant(false, '
|
|
1230
|
+
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: optimistic responses cannot be returned ' + 'for operations that use incremental data delivery (@defer, ' + '@stream, and @stream_connection).') : invariant(false) : void 0;
|
|
1187
1231
|
}
|
|
1188
1232
|
}
|
|
1189
1233
|
|
|
@@ -14,7 +14,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
14
14
|
|
|
15
15
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
16
16
|
|
|
17
|
-
var invariant = require(
|
|
17
|
+
var invariant = require('invariant');
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Determines the variables that are in scope for a fragment given the variables
|
|
@@ -15,12 +15,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
15
15
|
|
|
16
16
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
17
17
|
|
|
18
|
+
var OperationExecutor = require('./OperationExecutor');
|
|
19
|
+
|
|
18
20
|
var RelayDefaultHandlerProvider = require('../handlers/RelayDefaultHandlerProvider');
|
|
19
21
|
|
|
20
22
|
var RelayFeatureFlags = require('../util/RelayFeatureFlags');
|
|
21
23
|
|
|
22
|
-
var RelayModernQueryExecutor = require('./RelayModernQueryExecutor');
|
|
23
|
-
|
|
24
24
|
var RelayObservable = require('../network/RelayObservable');
|
|
25
25
|
|
|
26
26
|
var RelayOperationTracker = require('../store/RelayOperationTracker');
|
|
@@ -35,16 +35,15 @@ var defaultRequiredFieldLogger = require('./defaultRequiredFieldLogger');
|
|
|
35
35
|
|
|
36
36
|
var generateID = require('../util/generateID');
|
|
37
37
|
|
|
38
|
-
var invariant = require(
|
|
38
|
+
var invariant = require('invariant');
|
|
39
39
|
|
|
40
40
|
var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
41
41
|
function RelayModernEnvironment(config) {
|
|
42
42
|
var _this = this;
|
|
43
43
|
|
|
44
|
-
var _config$log, _config$requiredField, _config$UNSTABLE_defa, _config$getDataID, _config$scheduler, _config$isServer, _config$operationTrac;
|
|
44
|
+
var _config$log, _config$requiredField, _config$UNSTABLE_defa, _config$getDataID, _config$handlerProvid, _config$scheduler, _config$isServer, _config$operationTrac;
|
|
45
45
|
|
|
46
46
|
this.configName = config.configName;
|
|
47
|
-
var handlerProvider = config.handlerProvider ? config.handlerProvider : RelayDefaultHandlerProvider;
|
|
48
47
|
this._treatMissingFieldsAsNull = config.treatMissingFieldsAsNull === true;
|
|
49
48
|
var operationLoader = config.operationLoader;
|
|
50
49
|
var reactFlightPayloadDeserializer = config.reactFlightPayloadDeserializer;
|
|
@@ -67,7 +66,7 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
67
66
|
this._operationExecutions = new Map();
|
|
68
67
|
this._network = this.__wrapNetworkWithLogObserver(config.network);
|
|
69
68
|
this._getDataID = (_config$getDataID = config.getDataID) !== null && _config$getDataID !== void 0 ? _config$getDataID : defaultGetDataID;
|
|
70
|
-
this._publishQueue = new RelayPublishQueue(config.store, handlerProvider, this._getDataID);
|
|
69
|
+
this._publishQueue = new RelayPublishQueue(config.store, (_config$handlerProvid = config.handlerProvider) !== null && _config$handlerProvid !== void 0 ? _config$handlerProvid : RelayDefaultHandlerProvider, this._getDataID);
|
|
71
70
|
this._scheduler = (_config$scheduler = config.scheduler) !== null && _config$scheduler !== void 0 ? _config$scheduler : null;
|
|
72
71
|
this._store = config.store;
|
|
73
72
|
this.options = config.options;
|
|
@@ -172,32 +171,16 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
172
171
|
};
|
|
173
172
|
|
|
174
173
|
_proto.applyMutation = function applyMutation(optimisticConfig) {
|
|
175
|
-
var
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
optimisticConfig: optimisticConfig,
|
|
184
|
-
publishQueue: _this5._publishQueue,
|
|
185
|
-
reactFlightPayloadDeserializer: _this5._reactFlightPayloadDeserializer,
|
|
186
|
-
reactFlightServerErrorHandler: _this5._reactFlightServerErrorHandler,
|
|
187
|
-
scheduler: _this5._scheduler,
|
|
188
|
-
sink: sink,
|
|
189
|
-
source: source,
|
|
190
|
-
store: _this5._store,
|
|
191
|
-
updater: null,
|
|
192
|
-
operationTracker: _this5._operationTracker,
|
|
193
|
-
getDataID: _this5._getDataID,
|
|
194
|
-
treatMissingFieldsAsNull: _this5._treatMissingFieldsAsNull,
|
|
195
|
-
shouldProcessClientComponents: _this5._shouldProcessClientComponents
|
|
196
|
-
});
|
|
197
|
-
return function () {
|
|
198
|
-
return executor.cancel();
|
|
199
|
-
};
|
|
174
|
+
var subscription = this._execute({
|
|
175
|
+
createSource: function createSource() {
|
|
176
|
+
return RelayObservable.create(function (_sink) {});
|
|
177
|
+
},
|
|
178
|
+
isClientPayload: false,
|
|
179
|
+
operation: optimisticConfig.operation,
|
|
180
|
+
optimisticConfig: optimisticConfig,
|
|
181
|
+
updater: null
|
|
200
182
|
}).subscribe({});
|
|
183
|
+
|
|
201
184
|
return {
|
|
202
185
|
dispose: function dispose() {
|
|
203
186
|
return subscription.unsubscribe();
|
|
@@ -214,43 +197,26 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
214
197
|
};
|
|
215
198
|
|
|
216
199
|
_proto.commitPayload = function commitPayload(operation, payload) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
var executor = RelayModernQueryExecutor.execute({
|
|
221
|
-
operation: operation,
|
|
222
|
-
operationExecutions: _this6._operationExecutions,
|
|
223
|
-
operationLoader: _this6._operationLoader,
|
|
224
|
-
optimisticConfig: null,
|
|
225
|
-
publishQueue: _this6._publishQueue,
|
|
226
|
-
reactFlightPayloadDeserializer: _this6._reactFlightPayloadDeserializer,
|
|
227
|
-
reactFlightServerErrorHandler: _this6._reactFlightServerErrorHandler,
|
|
228
|
-
scheduler: _this6._scheduler,
|
|
229
|
-
sink: sink,
|
|
230
|
-
source: RelayObservable.from({
|
|
200
|
+
this._execute({
|
|
201
|
+
createSource: function createSource() {
|
|
202
|
+
return RelayObservable.from({
|
|
231
203
|
data: payload
|
|
232
|
-
})
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
treatMissingFieldsAsNull: _this6._treatMissingFieldsAsNull,
|
|
239
|
-
shouldProcessClientComponents: _this6._shouldProcessClientComponents
|
|
240
|
-
});
|
|
241
|
-
return function () {
|
|
242
|
-
return executor.cancel();
|
|
243
|
-
};
|
|
204
|
+
});
|
|
205
|
+
},
|
|
206
|
+
isClientPayload: true,
|
|
207
|
+
operation: operation,
|
|
208
|
+
optimisticConfig: null,
|
|
209
|
+
updater: null
|
|
244
210
|
}).subscribe({});
|
|
245
211
|
};
|
|
246
212
|
|
|
247
213
|
_proto.commitUpdate = function commitUpdate(updater) {
|
|
248
|
-
var
|
|
214
|
+
var _this5 = this;
|
|
249
215
|
|
|
250
216
|
this._scheduleUpdates(function () {
|
|
251
|
-
|
|
217
|
+
_this5._publishQueue.commitUpdate(updater);
|
|
252
218
|
|
|
253
|
-
|
|
219
|
+
_this5._publishQueue.run();
|
|
254
220
|
});
|
|
255
221
|
};
|
|
256
222
|
|
|
@@ -271,7 +237,7 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
271
237
|
};
|
|
272
238
|
|
|
273
239
|
_proto._checkSelectorAndHandleMissingFields = function _checkSelectorAndHandleMissingFields(operation, handlers) {
|
|
274
|
-
var
|
|
240
|
+
var _this6 = this;
|
|
275
241
|
|
|
276
242
|
var target = RelayRecordSource.create();
|
|
277
243
|
|
|
@@ -282,9 +248,9 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
282
248
|
|
|
283
249
|
if (target.size() > 0) {
|
|
284
250
|
this._scheduleUpdates(function () {
|
|
285
|
-
|
|
251
|
+
_this6._publishQueue.commitSource(target);
|
|
286
252
|
|
|
287
|
-
|
|
253
|
+
_this6._publishQueue.run();
|
|
288
254
|
});
|
|
289
255
|
}
|
|
290
256
|
|
|
@@ -311,34 +277,18 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
311
277
|
;
|
|
312
278
|
|
|
313
279
|
_proto.execute = function execute(_ref) {
|
|
314
|
-
var
|
|
280
|
+
var _this7 = this;
|
|
315
281
|
|
|
316
282
|
var operation = _ref.operation,
|
|
317
283
|
updater = _ref.updater;
|
|
318
|
-
return
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
publishQueue: _this9._publishQueue,
|
|
327
|
-
reactFlightPayloadDeserializer: _this9._reactFlightPayloadDeserializer,
|
|
328
|
-
reactFlightServerErrorHandler: _this9._reactFlightServerErrorHandler,
|
|
329
|
-
scheduler: _this9._scheduler,
|
|
330
|
-
sink: sink,
|
|
331
|
-
source: source,
|
|
332
|
-
store: _this9._store,
|
|
333
|
-
updater: updater,
|
|
334
|
-
operationTracker: _this9._operationTracker,
|
|
335
|
-
getDataID: _this9._getDataID,
|
|
336
|
-
treatMissingFieldsAsNull: _this9._treatMissingFieldsAsNull,
|
|
337
|
-
shouldProcessClientComponents: _this9._shouldProcessClientComponents
|
|
338
|
-
});
|
|
339
|
-
return function () {
|
|
340
|
-
return executor.cancel();
|
|
341
|
-
};
|
|
284
|
+
return this._execute({
|
|
285
|
+
createSource: function createSource() {
|
|
286
|
+
return _this7._network.execute(operation.request.node.params, operation.request.variables, operation.request.cacheConfig || {}, null);
|
|
287
|
+
},
|
|
288
|
+
isClientPayload: false,
|
|
289
|
+
operation: operation,
|
|
290
|
+
optimisticConfig: null,
|
|
291
|
+
updater: updater
|
|
342
292
|
});
|
|
343
293
|
}
|
|
344
294
|
/**
|
|
@@ -354,49 +304,33 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
354
304
|
;
|
|
355
305
|
|
|
356
306
|
_proto.executeMutation = function executeMutation(_ref2) {
|
|
357
|
-
var
|
|
307
|
+
var _this8 = this;
|
|
358
308
|
|
|
359
309
|
var operation = _ref2.operation,
|
|
360
310
|
optimisticResponse = _ref2.optimisticResponse,
|
|
361
311
|
optimisticUpdater = _ref2.optimisticUpdater,
|
|
362
312
|
updater = _ref2.updater,
|
|
363
313
|
uploadables = _ref2.uploadables;
|
|
364
|
-
|
|
365
|
-
var optimisticConfig;
|
|
366
|
-
|
|
367
|
-
if (optimisticResponse || optimisticUpdater) {
|
|
368
|
-
optimisticConfig = {
|
|
369
|
-
operation: operation,
|
|
370
|
-
response: optimisticResponse,
|
|
371
|
-
updater: optimisticUpdater
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
var source = _this10._network.execute(operation.request.node.params, operation.request.variables, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, operation.request.cacheConfig), {}, {
|
|
376
|
-
force: true
|
|
377
|
-
}), uploadables);
|
|
314
|
+
var optimisticConfig;
|
|
378
315
|
|
|
379
|
-
|
|
316
|
+
if (optimisticResponse || optimisticUpdater) {
|
|
317
|
+
optimisticConfig = {
|
|
380
318
|
operation: operation,
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
optimisticConfig: optimisticConfig,
|
|
384
|
-
publishQueue: _this10._publishQueue,
|
|
385
|
-
reactFlightPayloadDeserializer: _this10._reactFlightPayloadDeserializer,
|
|
386
|
-
reactFlightServerErrorHandler: _this10._reactFlightServerErrorHandler,
|
|
387
|
-
scheduler: _this10._scheduler,
|
|
388
|
-
sink: sink,
|
|
389
|
-
source: source,
|
|
390
|
-
store: _this10._store,
|
|
391
|
-
updater: updater,
|
|
392
|
-
operationTracker: _this10._operationTracker,
|
|
393
|
-
getDataID: _this10._getDataID,
|
|
394
|
-
treatMissingFieldsAsNull: _this10._treatMissingFieldsAsNull,
|
|
395
|
-
shouldProcessClientComponents: _this10._shouldProcessClientComponents
|
|
396
|
-
});
|
|
397
|
-
return function () {
|
|
398
|
-
return executor.cancel();
|
|
319
|
+
response: optimisticResponse,
|
|
320
|
+
updater: optimisticUpdater
|
|
399
321
|
};
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return this._execute({
|
|
325
|
+
createSource: function createSource() {
|
|
326
|
+
return _this8._network.execute(operation.request.node.params, operation.request.variables, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, operation.request.cacheConfig), {}, {
|
|
327
|
+
force: true
|
|
328
|
+
}), uploadables);
|
|
329
|
+
},
|
|
330
|
+
isClientPayload: false,
|
|
331
|
+
operation: operation,
|
|
332
|
+
optimisticConfig: optimisticConfig,
|
|
333
|
+
updater: updater
|
|
400
334
|
});
|
|
401
335
|
}
|
|
402
336
|
/**
|
|
@@ -411,38 +345,59 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
411
345
|
;
|
|
412
346
|
|
|
413
347
|
_proto.executeWithSource = function executeWithSource(_ref3) {
|
|
414
|
-
var _this11 = this;
|
|
415
|
-
|
|
416
348
|
var operation = _ref3.operation,
|
|
417
349
|
source = _ref3.source;
|
|
350
|
+
return this._execute({
|
|
351
|
+
createSource: function createSource() {
|
|
352
|
+
return source;
|
|
353
|
+
},
|
|
354
|
+
isClientPayload: false,
|
|
355
|
+
operation: operation,
|
|
356
|
+
optimisticConfig: null,
|
|
357
|
+
updater: null
|
|
358
|
+
});
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
_proto.toJSON = function toJSON() {
|
|
362
|
+
var _this$configName;
|
|
363
|
+
|
|
364
|
+
return "RelayModernEnvironment(".concat((_this$configName = this.configName) !== null && _this$configName !== void 0 ? _this$configName : '', ")");
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
_proto._execute = function _execute(_ref4) {
|
|
368
|
+
var _this9 = this;
|
|
369
|
+
|
|
370
|
+
var createSource = _ref4.createSource,
|
|
371
|
+
isClientPayload = _ref4.isClientPayload,
|
|
372
|
+
operation = _ref4.operation,
|
|
373
|
+
optimisticConfig = _ref4.optimisticConfig,
|
|
374
|
+
updater = _ref4.updater;
|
|
418
375
|
return RelayObservable.create(function (sink) {
|
|
419
|
-
var executor =
|
|
376
|
+
var executor = OperationExecutor.execute({
|
|
377
|
+
getDataID: _this9._getDataID,
|
|
378
|
+
isClientPayload: isClientPayload,
|
|
420
379
|
operation: operation,
|
|
421
|
-
operationExecutions:
|
|
422
|
-
operationLoader:
|
|
423
|
-
operationTracker:
|
|
424
|
-
optimisticConfig:
|
|
425
|
-
publishQueue:
|
|
426
|
-
reactFlightPayloadDeserializer:
|
|
427
|
-
reactFlightServerErrorHandler:
|
|
428
|
-
scheduler:
|
|
380
|
+
operationExecutions: _this9._operationExecutions,
|
|
381
|
+
operationLoader: _this9._operationLoader,
|
|
382
|
+
operationTracker: _this9._operationTracker,
|
|
383
|
+
optimisticConfig: optimisticConfig,
|
|
384
|
+
publishQueue: _this9._publishQueue,
|
|
385
|
+
reactFlightPayloadDeserializer: _this9._reactFlightPayloadDeserializer,
|
|
386
|
+
reactFlightServerErrorHandler: _this9._reactFlightServerErrorHandler,
|
|
387
|
+
scheduler: _this9._scheduler,
|
|
388
|
+
shouldProcessClientComponents: _this9._shouldProcessClientComponents,
|
|
429
389
|
sink: sink,
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
390
|
+
// NOTE: Some product tests expect `Network.execute` to be called only
|
|
391
|
+
// when the Observable is executed.
|
|
392
|
+
source: createSource(),
|
|
393
|
+
store: _this9._store,
|
|
394
|
+
treatMissingFieldsAsNull: _this9._treatMissingFieldsAsNull,
|
|
395
|
+
updater: updater
|
|
435
396
|
});
|
|
436
397
|
return function () {
|
|
437
398
|
return executor.cancel();
|
|
438
399
|
};
|
|
439
400
|
});
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
_proto.toJSON = function toJSON() {
|
|
443
|
-
var _this$configName;
|
|
444
|
-
|
|
445
|
-
return "RelayModernEnvironment(".concat((_this$configName = this.configName) !== null && _this$configName !== void 0 ? _this$configName : '', ")");
|
|
446
401
|
}
|
|
447
402
|
/**
|
|
448
403
|
* Wraps the network with logging to ensure that network requests are
|
|
@@ -20,7 +20,7 @@ var RelayFeatureFlags = require('../util/RelayFeatureFlags');
|
|
|
20
20
|
|
|
21
21
|
var areEqual = require("fbjs/lib/areEqual");
|
|
22
22
|
|
|
23
|
-
var invariant = require(
|
|
23
|
+
var invariant = require('invariant');
|
|
24
24
|
|
|
25
25
|
var isScalarAndEqual = require('../util/isScalarAndEqual');
|
|
26
26
|
|
|
@@ -24,8 +24,6 @@ var RelayModernRecord = require('./RelayModernRecord');
|
|
|
24
24
|
|
|
25
25
|
var RelayOptimisticRecordSource = require('./RelayOptimisticRecordSource');
|
|
26
26
|
|
|
27
|
-
var RelayProfiler = require('../util/RelayProfiler');
|
|
28
|
-
|
|
29
27
|
var RelayReader = require('./RelayReader');
|
|
30
28
|
|
|
31
29
|
var RelayReferenceMarker = require('./RelayReferenceMarker');
|
|
@@ -42,7 +40,7 @@ var deepFreeze = require('../util/deepFreeze');
|
|
|
42
40
|
|
|
43
41
|
var defaultGetDataID = require('./defaultGetDataID');
|
|
44
42
|
|
|
45
|
-
var invariant = require(
|
|
43
|
+
var invariant = require('invariant');
|
|
46
44
|
|
|
47
45
|
var resolveImmediate = require('../util/resolveImmediate');
|
|
48
46
|
|
|
@@ -747,7 +745,4 @@ function getAvailabilityStatus(operationAvailability, operationLastWrittenAt, op
|
|
|
747
745
|
};
|
|
748
746
|
}
|
|
749
747
|
|
|
750
|
-
RelayProfiler.instrumentMethods(RelayModernStore.prototype, {
|
|
751
|
-
lookup: 'RelayModernStore.prototype.lookup'
|
|
752
|
-
});
|
|
753
748
|
module.exports = RelayModernStore;
|