relay-runtime 11.0.0-rc.0 → 12.0.0

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 (128) hide show
  1. package/handlers/connection/ConnectionHandler.js.flow +7 -0
  2. package/handlers/connection/MutationHandlers.js.flow +28 -0
  3. package/index.js +1 -1
  4. package/index.js.flow +20 -3
  5. package/lib/handlers/RelayDefaultHandlerProvider.js +1 -1
  6. package/lib/handlers/connection/ConnectionHandler.js +12 -6
  7. package/lib/handlers/connection/MutationHandlers.js +67 -8
  8. package/lib/index.js +15 -0
  9. package/lib/multi-actor-environment/ActorIdentifier.js +33 -0
  10. package/lib/multi-actor-environment/ActorSpecificEnvironment.js +148 -0
  11. package/lib/multi-actor-environment/ActorUtils.js +27 -0
  12. package/lib/multi-actor-environment/MultiActorEnvironment.js +406 -0
  13. package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +11 -0
  14. package/lib/multi-actor-environment/index.js +21 -0
  15. package/lib/mutations/RelayRecordProxy.js +1 -1
  16. package/lib/mutations/RelayRecordSourceMutator.js +1 -1
  17. package/lib/mutations/RelayRecordSourceProxy.js +1 -1
  18. package/lib/mutations/RelayRecordSourceSelectorProxy.js +7 -2
  19. package/lib/mutations/applyOptimisticMutation.js +1 -1
  20. package/lib/mutations/commitMutation.js +5 -2
  21. package/lib/mutations/validateMutation.js +39 -17
  22. package/lib/network/RelayNetwork.js +1 -1
  23. package/lib/network/RelayObservable.js +3 -1
  24. package/lib/network/RelayQueryResponseCache.js +20 -3
  25. package/lib/network/wrapNetworkWithLogObserver.js +78 -0
  26. package/lib/query/GraphQLTag.js +1 -1
  27. package/lib/query/fetchQuery.js +1 -1
  28. package/lib/query/fetchQueryInternal.js +1 -1
  29. package/lib/store/DataChecker.js +132 -50
  30. package/lib/store/{RelayModernQueryExecutor.js → OperationExecutor.js} +524 -187
  31. package/lib/store/RelayConcreteVariables.js +29 -4
  32. package/lib/store/RelayModernEnvironment.js +137 -220
  33. package/lib/store/RelayModernFragmentSpecResolver.js +49 -23
  34. package/lib/store/RelayModernRecord.js +36 -2
  35. package/lib/store/RelayModernSelector.js +1 -1
  36. package/lib/store/RelayModernStore.js +53 -22
  37. package/lib/store/RelayOperationTracker.js +34 -24
  38. package/lib/store/RelayPublishQueue.js +30 -8
  39. package/lib/store/RelayReader.js +177 -29
  40. package/lib/store/RelayRecordSource.js +87 -3
  41. package/lib/store/RelayReferenceMarker.js +53 -28
  42. package/lib/store/RelayResponseNormalizer.js +247 -108
  43. package/lib/store/RelayStoreReactFlightUtils.js +7 -11
  44. package/lib/store/RelayStoreSubscriptions.js +8 -5
  45. package/lib/store/RelayStoreUtils.js +10 -4
  46. package/lib/store/ResolverCache.js +213 -0
  47. package/lib/store/ResolverFragments.js +57 -0
  48. package/lib/store/cloneRelayHandleSourceField.js +1 -1
  49. package/lib/store/cloneRelayScalarHandleSourceField.js +1 -1
  50. package/lib/store/createRelayContext.js +2 -2
  51. package/lib/store/defaultGetDataID.js +3 -1
  52. package/lib/store/readInlineData.js +1 -1
  53. package/lib/subscription/requestSubscription.js +32 -6
  54. package/lib/util/RelayConcreteNode.js +3 -0
  55. package/lib/util/RelayFeatureFlags.js +5 -4
  56. package/lib/util/RelayProfiler.js +17 -187
  57. package/lib/util/RelayReplaySubject.js +22 -7
  58. package/lib/util/deepFreeze.js +1 -0
  59. package/lib/util/getPaginationMetadata.js +41 -0
  60. package/lib/util/getPaginationVariables.js +67 -0
  61. package/lib/util/getPendingOperationsForFragment.js +55 -0
  62. package/lib/util/getRefetchMetadata.js +36 -0
  63. package/lib/util/getRelayHandleKey.js +1 -1
  64. package/lib/util/getRequestIdentifier.js +1 -1
  65. package/lib/util/getValueAtPath.js +51 -0
  66. package/lib/util/isEmptyObject.js +1 -1
  67. package/lib/util/registerEnvironmentWithDevTools.js +26 -0
  68. package/lib/util/withDuration.js +31 -0
  69. package/multi-actor-environment/ActorIdentifier.js.flow +43 -0
  70. package/multi-actor-environment/ActorSpecificEnvironment.js.flow +217 -0
  71. package/multi-actor-environment/ActorUtils.js.flow +33 -0
  72. package/multi-actor-environment/MultiActorEnvironment.js.flow +485 -0
  73. package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +245 -0
  74. package/multi-actor-environment/index.js.flow +27 -0
  75. package/mutations/RelayRecordSourceSelectorProxy.js.flow +7 -2
  76. package/mutations/commitMutation.js.flow +3 -1
  77. package/mutations/validateMutation.js.flow +42 -16
  78. package/network/RelayNetworkTypes.js.flow +17 -8
  79. package/network/RelayObservable.js.flow +2 -0
  80. package/network/RelayQueryResponseCache.js.flow +31 -17
  81. package/network/wrapNetworkWithLogObserver.js.flow +99 -0
  82. package/package.json +3 -2
  83. package/relay-runtime.js +2 -2
  84. package/relay-runtime.min.js +2 -2
  85. package/store/ClientID.js.flow +5 -1
  86. package/store/DataChecker.js.flow +148 -44
  87. package/store/{RelayModernQueryExecutor.js.flow → OperationExecutor.js.flow} +578 -237
  88. package/store/RelayConcreteVariables.js.flow +31 -1
  89. package/store/RelayModernEnvironment.js.flow +132 -220
  90. package/store/RelayModernFragmentSpecResolver.js.flow +40 -14
  91. package/store/RelayModernOperationDescriptor.js.flow +9 -3
  92. package/store/RelayModernRecord.js.flow +49 -0
  93. package/store/RelayModernStore.js.flow +57 -17
  94. package/store/RelayOperationTracker.js.flow +56 -34
  95. package/store/RelayPublishQueue.js.flow +37 -11
  96. package/store/RelayReader.js.flow +186 -27
  97. package/store/RelayRecordSource.js.flow +72 -6
  98. package/store/RelayReferenceMarker.js.flow +51 -21
  99. package/store/RelayResponseNormalizer.js.flow +251 -67
  100. package/store/RelayStoreReactFlightUtils.js.flow +6 -9
  101. package/store/RelayStoreSubscriptions.js.flow +10 -3
  102. package/store/RelayStoreTypes.js.flow +144 -21
  103. package/store/RelayStoreUtils.js.flow +19 -4
  104. package/store/ResolverCache.js.flow +247 -0
  105. package/store/ResolverFragments.js.flow +128 -0
  106. package/store/createRelayContext.js.flow +1 -1
  107. package/store/defaultGetDataID.js.flow +3 -1
  108. package/subscription/requestSubscription.js.flow +43 -8
  109. package/util/NormalizationNode.js.flow +16 -3
  110. package/util/ReaderNode.js.flow +29 -2
  111. package/util/RelayConcreteNode.js.flow +3 -0
  112. package/util/RelayFeatureFlags.js.flow +10 -6
  113. package/util/RelayProfiler.js.flow +22 -194
  114. package/util/RelayReplaySubject.js.flow +7 -6
  115. package/util/RelayRuntimeTypes.js.flow +4 -2
  116. package/util/deepFreeze.js.flow +2 -1
  117. package/util/getPaginationMetadata.js.flow +74 -0
  118. package/util/getPaginationVariables.js.flow +112 -0
  119. package/util/getPendingOperationsForFragment.js.flow +62 -0
  120. package/util/getRefetchMetadata.js.flow +80 -0
  121. package/util/getValueAtPath.js.flow +46 -0
  122. package/util/isEmptyObject.js.flow +2 -1
  123. package/util/registerEnvironmentWithDevTools.js.flow +33 -0
  124. package/util/withDuration.js.flow +32 -0
  125. package/lib/store/RelayRecordSourceMapImpl.js +0 -107
  126. package/lib/store/RelayStoreSubscriptionsUsingMapByID.js +0 -318
  127. package/store/RelayRecordSourceMapImpl.js.flow +0 -91
  128. package/store/RelayStoreSubscriptionsUsingMapByID.js.flow +0 -283
@@ -14,7 +14,10 @@ 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
+
19
+ var _require = require('./RelayStoreUtils'),
20
+ getArgumentValues = _require.getArgumentValues;
18
21
 
19
22
  /**
20
23
  * Determines the variables that are in scope for a fragment given the variables
@@ -28,7 +31,8 @@ function getFragmentVariables(fragment, rootVariables, argumentVariables) {
28
31
  fragment.argumentDefinitions.forEach(function (definition) {
29
32
  if (argumentVariables.hasOwnProperty(definition.name)) {
30
33
  return;
31
- }
34
+ } // $FlowFixMe[cannot-spread-interface]
35
+
32
36
 
33
37
  variables = variables || (0, _objectSpread2["default"])({}, argumentVariables);
34
38
 
@@ -48,9 +52,12 @@ function getFragmentVariables(fragment, rootVariables, argumentVariables) {
48
52
  * RelayStoreUtils.getStableVariableValue() that variable keys are all
49
53
  * present.
50
54
  */
55
+ // $FlowFixMe[incompatible-use]
51
56
  variables[definition.name] = undefined;
52
57
  break;
53
- }
58
+ } // $FlowFixMe[incompatible-use]
59
+ // $FlowFixMe[cannot-write]
60
+
54
61
 
55
62
  variables[definition.name] = rootVariables[definition.name];
56
63
  break;
@@ -73,7 +80,7 @@ function getFragmentVariables(fragment, rootVariables, argumentVariables) {
73
80
  function getOperationVariables(operation, variables) {
74
81
  var operationVariables = {};
75
82
  operation.argumentDefinitions.forEach(function (def) {
76
- var value = def.defaultValue;
83
+ var value = def.defaultValue; // $FlowFixMe[cannot-write]
77
84
 
78
85
  if (variables[def.name] != null) {
79
86
  value = variables[def.name];
@@ -84,7 +91,25 @@ function getOperationVariables(operation, variables) {
84
91
  return operationVariables;
85
92
  }
86
93
 
94
+ function getLocalVariables(currentVariables, argumentDefinitions, args) {
95
+ if (argumentDefinitions == null) {
96
+ return currentVariables;
97
+ }
98
+
99
+ var nextVariables = (0, _objectSpread2["default"])({}, currentVariables);
100
+ var nextArgs = args ? getArgumentValues(args, currentVariables) : {};
101
+ argumentDefinitions.forEach(function (def) {
102
+ var _nextArgs$def$name;
103
+
104
+ // $FlowFixMe[cannot-write]
105
+ var value = (_nextArgs$def$name = nextArgs[def.name]) !== null && _nextArgs$def$name !== void 0 ? _nextArgs$def$name : def.defaultValue;
106
+ nextVariables[def.name] = value;
107
+ });
108
+ return nextVariables;
109
+ }
110
+
87
111
  module.exports = {
112
+ getLocalVariables: getLocalVariables,
88
113
  getFragmentVariables: getFragmentVariables,
89
114
  getOperationVariables: getOperationVariables
90
115
  };
@@ -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');
@@ -33,18 +33,23 @@ var defaultGetDataID = require('./defaultGetDataID');
33
33
 
34
34
  var defaultRequiredFieldLogger = require('./defaultRequiredFieldLogger');
35
35
 
36
- var generateID = require('../util/generateID');
36
+ var invariant = require('invariant');
37
+
38
+ var registerEnvironmentWithDevTools = require('../util/registerEnvironmentWithDevTools');
37
39
 
38
- var invariant = require("fbjs/lib/invariant");
40
+ var wrapNetworkWithLogObserver = require('../network/wrapNetworkWithLogObserver');
41
+
42
+ var _require = require('../multi-actor-environment/ActorIdentifier'),
43
+ INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE = _require.INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE,
44
+ assertInternalActorIndentifier = _require.assertInternalActorIndentifier;
39
45
 
40
46
  var RelayModernEnvironment = /*#__PURE__*/function () {
41
47
  function RelayModernEnvironment(config) {
42
48
  var _this = this;
43
49
 
44
- var _config$log, _config$requiredField, _config$UNSTABLE_defa, _config$getDataID, _config$scheduler, _config$isServer, _config$operationTrac;
50
+ var _config$log, _config$requiredField, _config$UNSTABLE_defa, _config$getDataID, _config$handlerProvid, _config$scheduler, _config$isServer, _config$operationTrac;
45
51
 
46
52
  this.configName = config.configName;
47
- var handlerProvider = config.handlerProvider ? config.handlerProvider : RelayDefaultHandlerProvider;
48
53
  this._treatMissingFieldsAsNull = config.treatMissingFieldsAsNull === true;
49
54
  var operationLoader = config.operationLoader;
50
55
  var reactFlightPayloadDeserializer = config.reactFlightPayloadDeserializer;
@@ -65,41 +70,35 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
65
70
  this._defaultRenderPolicy = ((_config$UNSTABLE_defa = config.UNSTABLE_defaultRenderPolicy) !== null && _config$UNSTABLE_defa !== void 0 ? _config$UNSTABLE_defa : RelayFeatureFlags.ENABLE_PARTIAL_RENDERING_DEFAULT === true) ? 'partial' : 'full';
66
71
  this._operationLoader = operationLoader;
67
72
  this._operationExecutions = new Map();
68
- this._network = this.__wrapNetworkWithLogObserver(config.network);
73
+ this._network = wrapNetworkWithLogObserver(this, config.network);
69
74
  this._getDataID = (_config$getDataID = config.getDataID) !== null && _config$getDataID !== void 0 ? _config$getDataID : defaultGetDataID;
70
- this._publishQueue = new RelayPublishQueue(config.store, handlerProvider, this._getDataID);
75
+ this._publishQueue = new RelayPublishQueue(config.store, (_config$handlerProvid = config.handlerProvider) !== null && _config$handlerProvid !== void 0 ? _config$handlerProvid : RelayDefaultHandlerProvider, this._getDataID);
71
76
  this._scheduler = (_config$scheduler = config.scheduler) !== null && _config$scheduler !== void 0 ? _config$scheduler : null;
72
77
  this._store = config.store;
73
78
  this.options = config.options;
74
79
  this._isServer = (_config$isServer = config.isServer) !== null && _config$isServer !== void 0 ? _config$isServer : false;
75
80
 
76
81
  this.__setNet = function (newNet) {
77
- return _this._network = _this.__wrapNetworkWithLogObserver(newNet);
82
+ return _this._network = wrapNetworkWithLogObserver(_this, newNet);
78
83
  };
79
84
 
80
85
  if (process.env.NODE_ENV !== "production") {
81
- var _require = require('./StoreInspector'),
82
- inspect = _require.inspect;
86
+ var _require2 = require('./StoreInspector'),
87
+ inspect = _require2.inspect;
83
88
 
84
89
  this.DEBUG_inspect = function (dataID) {
85
90
  return inspect(_this, dataID);
86
91
  };
87
- } // Register this Relay Environment with Relay DevTools if it exists.
88
- // Note: this must always be the last step in the constructor.
89
-
90
-
91
- var _global = typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : undefined;
92
-
93
- var devToolsHook = _global && _global.__RELAY_DEVTOOLS_HOOK__;
94
-
95
- if (devToolsHook) {
96
- devToolsHook.registerEnvironment(this);
97
92
  }
98
93
 
99
94
  this._missingFieldHandlers = config.missingFieldHandlers;
100
95
  this._operationTracker = (_config$operationTrac = config.operationTracker) !== null && _config$operationTrac !== void 0 ? _config$operationTrac : new RelayOperationTracker();
101
96
  this._reactFlightPayloadDeserializer = reactFlightPayloadDeserializer;
102
97
  this._reactFlightServerErrorHandler = reactFlightServerErrorHandler;
98
+ this._shouldProcessClientComponents = config.shouldProcessClientComponents; // Register this Relay Environment with Relay DevTools if it exists.
99
+ // Note: this must always be the last step in the constructor.
100
+
101
+ registerEnvironmentWithDevTools(this);
103
102
  }
104
103
 
105
104
  var _proto = RelayModernEnvironment.prototype;
@@ -171,31 +170,16 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
171
170
  };
172
171
 
173
172
  _proto.applyMutation = function applyMutation(optimisticConfig) {
174
- var _this5 = this;
175
-
176
- var subscription = RelayObservable.create(function (sink) {
177
- var source = RelayObservable.create(function (_sink) {});
178
- var executor = RelayModernQueryExecutor.execute({
179
- operation: optimisticConfig.operation,
180
- operationExecutions: _this5._operationExecutions,
181
- operationLoader: _this5._operationLoader,
182
- optimisticConfig: optimisticConfig,
183
- publishQueue: _this5._publishQueue,
184
- reactFlightPayloadDeserializer: _this5._reactFlightPayloadDeserializer,
185
- reactFlightServerErrorHandler: _this5._reactFlightServerErrorHandler,
186
- scheduler: _this5._scheduler,
187
- sink: sink,
188
- source: source,
189
- store: _this5._store,
190
- updater: null,
191
- operationTracker: _this5._operationTracker,
192
- getDataID: _this5._getDataID,
193
- treatMissingFieldsAsNull: _this5._treatMissingFieldsAsNull
194
- });
195
- return function () {
196
- return executor.cancel();
197
- };
173
+ var subscription = this._execute({
174
+ createSource: function createSource() {
175
+ return RelayObservable.create(function (_sink) {});
176
+ },
177
+ isClientPayload: false,
178
+ operation: optimisticConfig.operation,
179
+ optimisticConfig: optimisticConfig,
180
+ updater: null
198
181
  }).subscribe({});
182
+
199
183
  return {
200
184
  dispose: function dispose() {
201
185
  return subscription.unsubscribe();
@@ -212,42 +196,26 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
212
196
  };
213
197
 
214
198
  _proto.commitPayload = function commitPayload(operation, payload) {
215
- var _this6 = this;
216
-
217
- RelayObservable.create(function (sink) {
218
- var executor = RelayModernQueryExecutor.execute({
219
- operation: operation,
220
- operationExecutions: _this6._operationExecutions,
221
- operationLoader: _this6._operationLoader,
222
- optimisticConfig: null,
223
- publishQueue: _this6._publishQueue,
224
- reactFlightPayloadDeserializer: _this6._reactFlightPayloadDeserializer,
225
- reactFlightServerErrorHandler: _this6._reactFlightServerErrorHandler,
226
- scheduler: _this6._scheduler,
227
- sink: sink,
228
- source: RelayObservable.from({
199
+ this._execute({
200
+ createSource: function createSource() {
201
+ return RelayObservable.from({
229
202
  data: payload
230
- }),
231
- store: _this6._store,
232
- updater: null,
233
- operationTracker: _this6._operationTracker,
234
- getDataID: _this6._getDataID,
235
- isClientPayload: true,
236
- treatMissingFieldsAsNull: _this6._treatMissingFieldsAsNull
237
- });
238
- return function () {
239
- return executor.cancel();
240
- };
203
+ });
204
+ },
205
+ isClientPayload: true,
206
+ operation: operation,
207
+ optimisticConfig: null,
208
+ updater: null
241
209
  }).subscribe({});
242
210
  };
243
211
 
244
212
  _proto.commitUpdate = function commitUpdate(updater) {
245
- var _this7 = this;
213
+ var _this5 = this;
246
214
 
247
215
  this._scheduleUpdates(function () {
248
- _this7._publishQueue.commitUpdate(updater);
216
+ _this5._publishQueue.commitUpdate(updater);
249
217
 
250
- _this7._publishQueue.run();
218
+ _this5._publishQueue.run();
251
219
  });
252
220
  };
253
221
 
@@ -268,20 +236,30 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
268
236
  };
269
237
 
270
238
  _proto._checkSelectorAndHandleMissingFields = function _checkSelectorAndHandleMissingFields(operation, handlers) {
271
- var _this8 = this;
239
+ var _this6 = this;
272
240
 
273
241
  var target = RelayRecordSource.create();
274
242
 
243
+ var source = this._store.getSource();
244
+
275
245
  var result = this._store.check(operation, {
276
- target: target,
277
- handlers: handlers
246
+ handlers: handlers,
247
+ defaultActorIdentifier: INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE,
248
+ getSourceForActor: function getSourceForActor(actorIdentifier) {
249
+ assertInternalActorIndentifier(actorIdentifier);
250
+ return source;
251
+ },
252
+ getTargetForActor: function getTargetForActor(actorIdentifier) {
253
+ assertInternalActorIndentifier(actorIdentifier);
254
+ return target;
255
+ }
278
256
  });
279
257
 
280
258
  if (target.size() > 0) {
281
259
  this._scheduleUpdates(function () {
282
- _this8._publishQueue.commitSource(target);
260
+ _this6._publishQueue.commitSource(target);
283
261
 
284
- _this8._publishQueue.run();
262
+ _this6._publishQueue.run();
285
263
  });
286
264
  }
287
265
 
@@ -308,33 +286,18 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
308
286
  ;
309
287
 
310
288
  _proto.execute = function execute(_ref) {
311
- var _this9 = this;
289
+ var _this7 = this;
312
290
 
313
291
  var operation = _ref.operation,
314
292
  updater = _ref.updater;
315
- return RelayObservable.create(function (sink) {
316
- var source = _this9._network.execute(operation.request.node.params, operation.request.variables, operation.request.cacheConfig || {}, null);
317
-
318
- var executor = RelayModernQueryExecutor.execute({
319
- operation: operation,
320
- operationExecutions: _this9._operationExecutions,
321
- operationLoader: _this9._operationLoader,
322
- optimisticConfig: null,
323
- publishQueue: _this9._publishQueue,
324
- reactFlightPayloadDeserializer: _this9._reactFlightPayloadDeserializer,
325
- reactFlightServerErrorHandler: _this9._reactFlightServerErrorHandler,
326
- scheduler: _this9._scheduler,
327
- sink: sink,
328
- source: source,
329
- store: _this9._store,
330
- updater: updater,
331
- operationTracker: _this9._operationTracker,
332
- getDataID: _this9._getDataID,
333
- treatMissingFieldsAsNull: _this9._treatMissingFieldsAsNull
334
- });
335
- return function () {
336
- return executor.cancel();
337
- };
293
+ return this._execute({
294
+ createSource: function createSource() {
295
+ return _this7._network.execute(operation.request.node.params, operation.request.variables, operation.request.cacheConfig || {}, null);
296
+ },
297
+ isClientPayload: false,
298
+ operation: operation,
299
+ optimisticConfig: null,
300
+ updater: updater
338
301
  });
339
302
  }
340
303
  /**
@@ -350,54 +313,39 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
350
313
  ;
351
314
 
352
315
  _proto.executeMutation = function executeMutation(_ref2) {
353
- var _this10 = this;
316
+ var _this8 = this;
354
317
 
355
318
  var operation = _ref2.operation,
356
319
  optimisticResponse = _ref2.optimisticResponse,
357
320
  optimisticUpdater = _ref2.optimisticUpdater,
358
321
  updater = _ref2.updater,
359
322
  uploadables = _ref2.uploadables;
360
- return RelayObservable.create(function (sink) {
361
- var optimisticConfig;
362
-
363
- if (optimisticResponse || optimisticUpdater) {
364
- optimisticConfig = {
365
- operation: operation,
366
- response: optimisticResponse,
367
- updater: optimisticUpdater
368
- };
369
- }
323
+ var optimisticConfig;
370
324
 
371
- var source = _this10._network.execute(operation.request.node.params, operation.request.variables, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, operation.request.cacheConfig), {}, {
372
- force: true
373
- }), uploadables);
374
-
375
- var executor = RelayModernQueryExecutor.execute({
325
+ if (optimisticResponse || optimisticUpdater) {
326
+ optimisticConfig = {
376
327
  operation: operation,
377
- operationExecutions: _this10._operationExecutions,
378
- operationLoader: _this10._operationLoader,
379
- optimisticConfig: optimisticConfig,
380
- publishQueue: _this10._publishQueue,
381
- reactFlightPayloadDeserializer: _this10._reactFlightPayloadDeserializer,
382
- reactFlightServerErrorHandler: _this10._reactFlightServerErrorHandler,
383
- scheduler: _this10._scheduler,
384
- sink: sink,
385
- source: source,
386
- store: _this10._store,
387
- updater: updater,
388
- operationTracker: _this10._operationTracker,
389
- getDataID: _this10._getDataID,
390
- treatMissingFieldsAsNull: _this10._treatMissingFieldsAsNull
391
- });
392
- return function () {
393
- return executor.cancel();
328
+ response: optimisticResponse,
329
+ updater: optimisticUpdater
394
330
  };
331
+ }
332
+
333
+ return this._execute({
334
+ createSource: function createSource() {
335
+ return _this8._network.execute(operation.request.node.params, operation.request.variables, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, operation.request.cacheConfig), {}, {
336
+ force: true
337
+ }), uploadables);
338
+ },
339
+ isClientPayload: false,
340
+ operation: operation,
341
+ optimisticConfig: optimisticConfig,
342
+ updater: updater
395
343
  });
396
344
  }
397
345
  /**
398
346
  * Returns an Observable of GraphQLResponse resulting from executing the
399
347
  * provided Query or Subscription operation responses, the result of which is
400
- * then normalized and comitted to the publish queue.
348
+ * then normalized and committed to the publish queue.
401
349
  *
402
350
  * Note: Observables are lazy, so calling this method will do nothing until
403
351
  * the result is subscribed to:
@@ -406,30 +354,16 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
406
354
  ;
407
355
 
408
356
  _proto.executeWithSource = function executeWithSource(_ref3) {
409
- var _this11 = this;
410
-
411
357
  var operation = _ref3.operation,
412
358
  source = _ref3.source;
413
- return RelayObservable.create(function (sink) {
414
- var executor = RelayModernQueryExecutor.execute({
415
- operation: operation,
416
- operationExecutions: _this11._operationExecutions,
417
- operationLoader: _this11._operationLoader,
418
- operationTracker: _this11._operationTracker,
419
- optimisticConfig: null,
420
- publishQueue: _this11._publishQueue,
421
- reactFlightPayloadDeserializer: _this11._reactFlightPayloadDeserializer,
422
- reactFlightServerErrorHandler: _this11._reactFlightServerErrorHandler,
423
- scheduler: _this11._scheduler,
424
- sink: sink,
425
- source: source,
426
- store: _this11._store,
427
- getDataID: _this11._getDataID,
428
- treatMissingFieldsAsNull: _this11._treatMissingFieldsAsNull
429
- });
430
- return function () {
431
- return executor.cancel();
432
- };
359
+ return this._execute({
360
+ createSource: function createSource() {
361
+ return source;
362
+ },
363
+ isClientPayload: false,
364
+ operation: operation,
365
+ optimisticConfig: null,
366
+ updater: null
433
367
  });
434
368
  };
435
369
 
@@ -437,69 +371,52 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
437
371
  var _this$configName;
438
372
 
439
373
  return "RelayModernEnvironment(".concat((_this$configName = this.configName) !== null && _this$configName !== void 0 ? _this$configName : '', ")");
440
- }
441
- /**
442
- * Wraps the network with logging to ensure that network requests are
443
- * always logged. Relying on each network callsite to be wrapped is
444
- * untenable and will eventually lead to holes in the logging.
445
- */
446
- ;
374
+ };
447
375
 
448
- _proto.__wrapNetworkWithLogObserver = function __wrapNetworkWithLogObserver(network) {
449
- var that = this;
450
- return {
451
- execute: function execute(params, variables, cacheConfig, uploadables) {
452
- var transactionID = generateID();
453
- var log = that.__log;
454
- var logObserver = {
455
- start: function start(subscription) {
456
- log({
457
- name: 'network.start',
458
- transactionID: transactionID,
459
- params: params,
460
- variables: variables,
461
- cacheConfig: cacheConfig
462
- });
463
- },
464
- next: function next(response) {
465
- log({
466
- name: 'network.next',
467
- transactionID: transactionID,
468
- response: response
469
- });
470
- },
471
- error: function error(_error) {
472
- log({
473
- name: 'network.error',
474
- transactionID: transactionID,
475
- error: _error
476
- });
477
- },
478
- complete: function complete() {
479
- log({
480
- name: 'network.complete',
481
- transactionID: transactionID
482
- });
483
- },
484
- unsubscribe: function unsubscribe() {
485
- log({
486
- name: 'network.unsubscribe',
487
- transactionID: transactionID
488
- });
489
- }
490
- };
491
-
492
- var logRequestInfo = function logRequestInfo(info) {
493
- log({
494
- name: 'network.info',
495
- transactionID: transactionID,
496
- info: info
497
- });
498
- };
499
-
500
- return network.execute(params, variables, cacheConfig, uploadables, logRequestInfo)["do"](logObserver);
501
- }
502
- };
376
+ _proto._execute = function _execute(_ref4) {
377
+ var _this9 = this;
378
+
379
+ var createSource = _ref4.createSource,
380
+ isClientPayload = _ref4.isClientPayload,
381
+ operation = _ref4.operation,
382
+ optimisticConfig = _ref4.optimisticConfig,
383
+ updater = _ref4.updater;
384
+ var publishQueue = this._publishQueue;
385
+ var store = this._store;
386
+ return RelayObservable.create(function (sink) {
387
+ var executor = OperationExecutor.execute({
388
+ actorIdentifier: INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE,
389
+ getDataID: _this9._getDataID,
390
+ isClientPayload: isClientPayload,
391
+ log: _this9.__log,
392
+ operation: operation,
393
+ operationExecutions: _this9._operationExecutions,
394
+ operationLoader: _this9._operationLoader,
395
+ operationTracker: _this9._operationTracker,
396
+ optimisticConfig: optimisticConfig,
397
+ getPublishQueue: function getPublishQueue(actorIdentifier) {
398
+ assertInternalActorIndentifier(actorIdentifier);
399
+ return publishQueue;
400
+ },
401
+ reactFlightPayloadDeserializer: _this9._reactFlightPayloadDeserializer,
402
+ reactFlightServerErrorHandler: _this9._reactFlightServerErrorHandler,
403
+ scheduler: _this9._scheduler,
404
+ shouldProcessClientComponents: _this9._shouldProcessClientComponents,
405
+ sink: sink,
406
+ // NOTE: Some product tests expect `Network.execute` to be called only
407
+ // when the Observable is executed.
408
+ source: createSource(),
409
+ getStore: function getStore(actorIdentifier) {
410
+ assertInternalActorIndentifier(actorIdentifier);
411
+ return store;
412
+ },
413
+ treatMissingFieldsAsNull: _this9._treatMissingFieldsAsNull,
414
+ updater: updater
415
+ });
416
+ return function () {
417
+ return executor.cancel();
418
+ };
419
+ });
503
420
  };
504
421
 
505
422
  return RelayModernEnvironment;