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.
Files changed (71) hide show
  1. package/index.js +1 -1
  2. package/index.js.flow +4 -2
  3. package/lib/handlers/RelayDefaultHandlerProvider.js +1 -1
  4. package/lib/handlers/connection/ConnectionHandler.js +1 -1
  5. package/lib/handlers/connection/MutationHandlers.js +1 -1
  6. package/lib/multi-actor-environment/ActorIdentifier.js +23 -0
  7. package/lib/multi-actor-environment/ActorSpecificEnvironment.js +108 -0
  8. package/lib/multi-actor-environment/MultiActorEnvironment.js +156 -0
  9. package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +11 -0
  10. package/lib/multi-actor-environment/index.js +17 -0
  11. package/lib/mutations/RelayRecordProxy.js +1 -1
  12. package/lib/mutations/RelayRecordSourceMutator.js +1 -1
  13. package/lib/mutations/RelayRecordSourceProxy.js +1 -1
  14. package/lib/mutations/RelayRecordSourceSelectorProxy.js +1 -1
  15. package/lib/mutations/applyOptimisticMutation.js +1 -1
  16. package/lib/mutations/commitMutation.js +1 -1
  17. package/lib/network/RelayNetwork.js +1 -1
  18. package/lib/network/RelayQueryResponseCache.js +1 -1
  19. package/lib/query/GraphQLTag.js +1 -1
  20. package/lib/query/fetchQuery.js +1 -1
  21. package/lib/query/fetchQueryInternal.js +1 -1
  22. package/lib/store/DataChecker.js +1 -1
  23. package/lib/store/{RelayModernQueryExecutor.js → OperationExecutor.js} +81 -37
  24. package/lib/store/RelayConcreteVariables.js +1 -1
  25. package/lib/store/RelayModernEnvironment.js +99 -144
  26. package/lib/store/RelayModernFragmentSpecResolver.js +1 -1
  27. package/lib/store/RelayModernRecord.js +1 -1
  28. package/lib/store/RelayModernSelector.js +1 -1
  29. package/lib/store/RelayModernStore.js +1 -6
  30. package/lib/store/RelayOperationTracker.js +1 -1
  31. package/lib/store/RelayPublishQueue.js +9 -5
  32. package/lib/store/RelayReader.js +63 -10
  33. package/lib/store/RelayReferenceMarker.js +1 -1
  34. package/lib/store/RelayResponseNormalizer.js +47 -22
  35. package/lib/store/RelayStoreReactFlightUtils.js +1 -1
  36. package/lib/store/RelayStoreUtils.js +1 -1
  37. package/lib/store/ResolverFragments.js +57 -0
  38. package/lib/store/cloneRelayHandleSourceField.js +1 -1
  39. package/lib/store/cloneRelayScalarHandleSourceField.js +1 -1
  40. package/lib/store/createRelayContext.js +1 -1
  41. package/lib/store/readInlineData.js +1 -1
  42. package/lib/subscription/requestSubscription.js +18 -7
  43. package/lib/util/RelayConcreteNode.js +1 -0
  44. package/lib/util/RelayFeatureFlags.js +3 -1
  45. package/lib/util/RelayProfiler.js +17 -187
  46. package/lib/util/RelayReplaySubject.js +1 -1
  47. package/lib/util/getRelayHandleKey.js +1 -1
  48. package/lib/util/getRequestIdentifier.js +1 -1
  49. package/multi-actor-environment/ActorIdentifier.js.flow +27 -0
  50. package/multi-actor-environment/ActorSpecificEnvironment.js.flow +189 -0
  51. package/multi-actor-environment/MultiActorEnvironment.js.flow +233 -0
  52. package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +196 -0
  53. package/multi-actor-environment/index.js.flow +24 -0
  54. package/network/RelayNetworkTypes.js.flow +5 -4
  55. package/package.json +3 -2
  56. package/relay-runtime.js +2 -2
  57. package/relay-runtime.min.js +2 -2
  58. package/store/{RelayModernQueryExecutor.js.flow → OperationExecutor.js.flow} +82 -35
  59. package/store/RelayModernEnvironment.js.flow +88 -131
  60. package/store/RelayModernStore.js.flow +0 -5
  61. package/store/RelayPublishQueue.js.flow +7 -4
  62. package/store/RelayReader.js.flow +57 -5
  63. package/store/RelayResponseNormalizer.js.flow +67 -26
  64. package/store/RelayStoreTypes.js.flow +15 -8
  65. package/store/ResolverFragments.js.flow +125 -0
  66. package/subscription/requestSubscription.js.flow +15 -7
  67. package/util/ReaderNode.js.flow +14 -1
  68. package/util/RelayConcreteNode.js.flow +1 -0
  69. package/util/RelayFeatureFlags.js.flow +4 -0
  70. package/util/RelayProfiler.js.flow +22 -194
  71. 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("fbjs/lib/invariant");
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, 'RelayModernQueryExecutor: invalid executor state.') : invariant(false) : void 0;
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, 'RelayModernQueryExecutor: optimistic payload received after server payload.') : invariant(false) : void 0;
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]; // In theory this doesn't preserve the ordering of the batch.
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
- if (nonIncrementalResponses.length > 0) {
409
- var payloadFollowups = this._processResponses(nonIncrementalResponses); // Please note that we're passing `this._operation` to the publish
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
- var updatedOwners = this._publishQueue.run(this._operation);
415
-
416
- this._updateOperationTracker(updatedOwners);
415
+ this._updateOperationTracker(updatedOwners);
416
+ }
417
417
 
418
418
  this._processPayloadFollowups(payloadFollowups);
419
419
 
420
- if (this._incrementalPayloadsPending && !this._retainDisposable) {
421
- this._retainDisposable = this._store.retain(this._operation);
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); // For the incremental case, we're only handling follow-up responses
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
- var _updatedOwners = this._publishQueue.run();
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, 'RelayModernQueryExecutor: Unexpected ModuleImport optimistic ' + 'update in operation %s.' + _this7._operation.request.node.params.name) : void 0;
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
- var updatedOwners = _this9._publishQueue.run();
705
+ if (!RelayFeatureFlags.ENABLE_BATCHED_STORE_UPDATES) {
706
+ var updatedOwners = _this9._publishQueue.run();
671
707
 
672
- _this9._updateOperationTracker(updatedOwners);
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
- var updatedOwners = this._publishQueue.run();
809
+ if (!RelayFeatureFlags.ENABLE_BATCHED_STORE_UPDATES) {
810
+ var updatedOwners = this._publishQueue.run();
768
811
 
769
- this._updateOperationTracker(updatedOwners);
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
- var updatedOwners = this._publishQueue.run();
912
+ if (!RelayFeatureFlags.ENABLE_BATCHED_STORE_UPDATES) {
913
+ var updatedOwners = this._publishQueue.run();
869
914
 
870
- this._updateOperationTracker(updatedOwners);
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 (this._operationTracker != null && updatedOwners != null && updatedOwners.length > 0) {
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
- if (this._operationTracker != null) {
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, 'RelayModernQueryExecutor: 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;
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, 'RelayModernQueryExecutor: optimistic responses cannot be returned ' + 'for operations that use incremental data delivery (@defer, ' + '@stream, and @stream_connection).') : invariant(false) : void 0;
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("fbjs/lib/invariant");
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("fbjs/lib/invariant");
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 _this5 = this;
176
-
177
- var subscription = RelayObservable.create(function (sink) {
178
- var source = RelayObservable.create(function (_sink) {});
179
- var executor = RelayModernQueryExecutor.execute({
180
- operation: optimisticConfig.operation,
181
- operationExecutions: _this5._operationExecutions,
182
- operationLoader: _this5._operationLoader,
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
- var _this6 = this;
218
-
219
- RelayObservable.create(function (sink) {
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
- store: _this6._store,
234
- updater: null,
235
- operationTracker: _this6._operationTracker,
236
- getDataID: _this6._getDataID,
237
- isClientPayload: true,
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 _this7 = this;
214
+ var _this5 = this;
249
215
 
250
216
  this._scheduleUpdates(function () {
251
- _this7._publishQueue.commitUpdate(updater);
217
+ _this5._publishQueue.commitUpdate(updater);
252
218
 
253
- _this7._publishQueue.run();
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 _this8 = this;
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
- _this8._publishQueue.commitSource(target);
251
+ _this6._publishQueue.commitSource(target);
286
252
 
287
- _this8._publishQueue.run();
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 _this9 = this;
280
+ var _this7 = this;
315
281
 
316
282
  var operation = _ref.operation,
317
283
  updater = _ref.updater;
318
- return RelayObservable.create(function (sink) {
319
- var source = _this9._network.execute(operation.request.node.params, operation.request.variables, operation.request.cacheConfig || {}, null);
320
-
321
- var executor = RelayModernQueryExecutor.execute({
322
- operation: operation,
323
- operationExecutions: _this9._operationExecutions,
324
- operationLoader: _this9._operationLoader,
325
- optimisticConfig: null,
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 _this10 = this;
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
- return RelayObservable.create(function (sink) {
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
- var executor = RelayModernQueryExecutor.execute({
316
+ if (optimisticResponse || optimisticUpdater) {
317
+ optimisticConfig = {
380
318
  operation: operation,
381
- operationExecutions: _this10._operationExecutions,
382
- operationLoader: _this10._operationLoader,
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 = RelayModernQueryExecutor.execute({
376
+ var executor = OperationExecutor.execute({
377
+ getDataID: _this9._getDataID,
378
+ isClientPayload: isClientPayload,
420
379
  operation: operation,
421
- operationExecutions: _this11._operationExecutions,
422
- operationLoader: _this11._operationLoader,
423
- operationTracker: _this11._operationTracker,
424
- optimisticConfig: null,
425
- publishQueue: _this11._publishQueue,
426
- reactFlightPayloadDeserializer: _this11._reactFlightPayloadDeserializer,
427
- reactFlightServerErrorHandler: _this11._reactFlightServerErrorHandler,
428
- scheduler: _this11._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
- source: source,
431
- store: _this11._store,
432
- getDataID: _this11._getDataID,
433
- treatMissingFieldsAsNull: _this11._treatMissingFieldsAsNull,
434
- shouldProcessClientComponents: _this11._shouldProcessClientComponents
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("fbjs/lib/invariant");
23
+ var invariant = require('invariant');
24
24
 
25
25
  var isScalarAndEqual = require('../util/isScalarAndEqual');
26
26
 
@@ -18,7 +18,7 @@ var areEqual = require("fbjs/lib/areEqual");
18
18
 
19
19
  var deepFreeze = require('../util/deepFreeze');
20
20
 
21
- var invariant = require("fbjs/lib/invariant");
21
+ var invariant = require('invariant');
22
22
 
23
23
  var warning = require("fbjs/lib/warning");
24
24
 
@@ -12,7 +12,7 @@
12
12
 
13
13
  var areEqual = require("fbjs/lib/areEqual");
14
14
 
15
- var invariant = require("fbjs/lib/invariant");
15
+ var invariant = require('invariant');
16
16
 
17
17
  var warning = require("fbjs/lib/warning");
18
18
 
@@ -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("fbjs/lib/invariant");
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;