relay-runtime 11.0.0 → 13.0.0-rc.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 (169) hide show
  1. package/handlers/RelayDefaultHandlerProvider.js.flow +2 -2
  2. package/handlers/connection/ConnectionHandler.js.flow +8 -10
  3. package/handlers/connection/MutationHandlers.js.flow +31 -7
  4. package/index.js +1 -1
  5. package/index.js.flow +60 -36
  6. package/lib/handlers/RelayDefaultHandlerProvider.js +1 -1
  7. package/lib/handlers/connection/ConnectionHandler.js +8 -8
  8. package/lib/handlers/connection/MutationHandlers.js +61 -5
  9. package/lib/index.js +58 -43
  10. package/lib/multi-actor-environment/ActorIdentifier.js +33 -0
  11. package/lib/multi-actor-environment/ActorSpecificEnvironment.js +152 -0
  12. package/lib/multi-actor-environment/ActorUtils.js +27 -0
  13. package/lib/multi-actor-environment/MultiActorEnvironment.js +419 -0
  14. package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +11 -0
  15. package/lib/multi-actor-environment/index.js +21 -0
  16. package/lib/mutations/RelayDeclarativeMutationConfig.js +4 -1
  17. package/lib/mutations/RelayRecordProxy.js +3 -2
  18. package/lib/mutations/RelayRecordSourceMutator.js +3 -2
  19. package/lib/mutations/RelayRecordSourceProxy.js +12 -4
  20. package/lib/mutations/RelayRecordSourceSelectorProxy.js +18 -5
  21. package/lib/mutations/applyOptimisticMutation.js +6 -6
  22. package/lib/mutations/commitMutation.js +14 -10
  23. package/lib/mutations/readUpdatableQuery_EXPERIMENTAL.js +238 -0
  24. package/lib/mutations/validateMutation.js +12 -5
  25. package/lib/network/ConvertToExecuteFunction.js +2 -1
  26. package/lib/network/RelayNetwork.js +3 -2
  27. package/lib/network/RelayQueryResponseCache.js +21 -4
  28. package/lib/network/wrapNetworkWithLogObserver.js +79 -0
  29. package/lib/query/GraphQLTag.js +3 -2
  30. package/lib/query/fetchQuery.js +6 -5
  31. package/lib/query/fetchQueryInternal.js +1 -1
  32. package/lib/query/fetchQuery_DEPRECATED.js +2 -1
  33. package/lib/store/ClientID.js +7 -1
  34. package/lib/store/DataChecker.js +141 -60
  35. package/lib/store/{RelayModernQueryExecutor.js → OperationExecutor.js} +532 -195
  36. package/lib/store/RelayConcreteVariables.js +24 -4
  37. package/lib/store/RelayModernEnvironment.js +175 -234
  38. package/lib/store/RelayModernFragmentSpecResolver.js +52 -26
  39. package/lib/store/RelayModernOperationDescriptor.js +2 -1
  40. package/lib/store/RelayModernRecord.js +47 -12
  41. package/lib/store/RelayModernSelector.js +14 -8
  42. package/lib/store/RelayModernStore.js +58 -29
  43. package/lib/store/RelayOperationTracker.js +34 -24
  44. package/lib/store/RelayPublishQueue.js +41 -13
  45. package/lib/store/RelayReader.js +287 -46
  46. package/lib/store/RelayRecordSource.js +87 -3
  47. package/lib/store/RelayReferenceMarker.js +55 -31
  48. package/lib/store/RelayResponseNormalizer.js +250 -108
  49. package/lib/store/RelayStoreReactFlightUtils.js +8 -12
  50. package/lib/store/RelayStoreSubscriptions.js +14 -9
  51. package/lib/store/RelayStoreUtils.js +11 -5
  52. package/lib/store/ResolverCache.js +213 -0
  53. package/lib/store/ResolverFragments.js +61 -0
  54. package/lib/store/cloneRelayHandleSourceField.js +5 -4
  55. package/lib/store/cloneRelayScalarHandleSourceField.js +5 -4
  56. package/lib/store/createRelayContext.js +4 -2
  57. package/lib/store/defaultGetDataID.js +3 -1
  58. package/lib/store/readInlineData.js +6 -2
  59. package/lib/subscription/requestSubscription.js +35 -9
  60. package/lib/util/RelayConcreteNode.js +4 -0
  61. package/lib/util/RelayFeatureFlags.js +11 -4
  62. package/lib/util/RelayProfiler.js +17 -187
  63. package/lib/util/RelayReplaySubject.js +22 -7
  64. package/lib/util/RelayRuntimeTypes.js +0 -6
  65. package/lib/util/StringInterner.js +71 -0
  66. package/lib/util/deepFreeze.js +1 -0
  67. package/lib/util/getFragmentIdentifier.js +15 -7
  68. package/lib/util/getOperation.js +2 -1
  69. package/lib/util/getPaginationMetadata.js +41 -0
  70. package/lib/util/getPaginationVariables.js +66 -0
  71. package/lib/util/getPendingOperationsForFragment.js +55 -0
  72. package/lib/util/getRefetchMetadata.js +36 -0
  73. package/lib/util/getRelayHandleKey.js +2 -2
  74. package/lib/util/getRequestIdentifier.js +2 -2
  75. package/lib/util/getValueAtPath.js +51 -0
  76. package/lib/util/isEmptyObject.js +1 -1
  77. package/lib/util/registerEnvironmentWithDevTools.js +26 -0
  78. package/lib/util/withDuration.js +31 -0
  79. package/multi-actor-environment/ActorIdentifier.js.flow +43 -0
  80. package/multi-actor-environment/ActorSpecificEnvironment.js.flow +225 -0
  81. package/multi-actor-environment/ActorUtils.js.flow +33 -0
  82. package/multi-actor-environment/MultiActorEnvironment.js.flow +506 -0
  83. package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +261 -0
  84. package/multi-actor-environment/index.js.flow +26 -0
  85. package/mutations/RelayDeclarativeMutationConfig.js.flow +32 -26
  86. package/mutations/RelayRecordProxy.js.flow +4 -5
  87. package/mutations/RelayRecordSourceMutator.js.flow +4 -6
  88. package/mutations/RelayRecordSourceProxy.js.flow +19 -10
  89. package/mutations/RelayRecordSourceSelectorProxy.js.flow +22 -7
  90. package/mutations/applyOptimisticMutation.js.flow +13 -14
  91. package/mutations/commitLocalUpdate.js.flow +1 -1
  92. package/mutations/commitMutation.js.flow +35 -46
  93. package/mutations/readUpdatableQuery_EXPERIMENTAL.js.flow +309 -0
  94. package/mutations/validateMutation.js.flow +28 -16
  95. package/network/ConvertToExecuteFunction.js.flow +2 -2
  96. package/network/RelayNetwork.js.flow +4 -5
  97. package/network/RelayNetworkTypes.js.flow +17 -8
  98. package/network/RelayObservable.js.flow +1 -1
  99. package/network/RelayQueryResponseCache.js.flow +34 -20
  100. package/network/wrapNetworkWithLogObserver.js.flow +100 -0
  101. package/package.json +3 -2
  102. package/query/GraphQLTag.js.flow +9 -9
  103. package/query/PreloadableQueryRegistry.js.flow +2 -1
  104. package/query/fetchQuery.js.flow +11 -13
  105. package/query/fetchQueryInternal.js.flow +6 -9
  106. package/query/fetchQuery_DEPRECATED.js.flow +6 -6
  107. package/relay-runtime.js +2 -2
  108. package/relay-runtime.min.js +2 -2
  109. package/store/ClientID.js.flow +14 -3
  110. package/store/DataChecker.js.flow +162 -67
  111. package/store/{RelayModernQueryExecutor.js.flow → OperationExecutor.js.flow} +616 -283
  112. package/store/RelayConcreteVariables.js.flow +27 -5
  113. package/store/RelayModernEnvironment.js.flow +176 -235
  114. package/store/RelayModernFragmentSpecResolver.js.flow +55 -31
  115. package/store/RelayModernOperationDescriptor.js.flow +12 -7
  116. package/store/RelayModernRecord.js.flow +67 -11
  117. package/store/RelayModernSelector.js.flow +24 -14
  118. package/store/RelayModernStore.js.flow +72 -36
  119. package/store/RelayOperationTracker.js.flow +59 -43
  120. package/store/RelayOptimisticRecordSource.js.flow +2 -2
  121. package/store/RelayPublishQueue.js.flow +79 -34
  122. package/store/RelayReader.js.flow +351 -72
  123. package/store/RelayRecordSource.js.flow +72 -6
  124. package/store/RelayReferenceMarker.js.flow +60 -33
  125. package/store/RelayResponseNormalizer.js.flow +288 -102
  126. package/store/RelayStoreReactFlightUtils.js.flow +9 -13
  127. package/store/RelayStoreSubscriptions.js.flow +19 -11
  128. package/store/RelayStoreTypes.js.flow +210 -44
  129. package/store/RelayStoreUtils.js.flow +25 -11
  130. package/store/ResolverCache.js.flow +249 -0
  131. package/store/ResolverFragments.js.flow +121 -0
  132. package/store/StoreInspector.js.flow +2 -2
  133. package/store/TypeID.js.flow +1 -1
  134. package/store/ViewerPattern.js.flow +2 -2
  135. package/store/cloneRelayHandleSourceField.js.flow +5 -6
  136. package/store/cloneRelayScalarHandleSourceField.js.flow +5 -6
  137. package/store/createFragmentSpecResolver.js.flow +3 -4
  138. package/store/createRelayContext.js.flow +3 -3
  139. package/store/defaultGetDataID.js.flow +3 -1
  140. package/store/normalizeRelayPayload.js.flow +6 -7
  141. package/store/readInlineData.js.flow +7 -8
  142. package/subscription/requestSubscription.js.flow +54 -27
  143. package/util/NormalizationNode.js.flow +16 -3
  144. package/util/ReaderNode.js.flow +38 -2
  145. package/util/RelayConcreteNode.js.flow +4 -0
  146. package/util/RelayFeatureFlags.js.flow +24 -8
  147. package/util/RelayProfiler.js.flow +22 -194
  148. package/util/RelayReplaySubject.js.flow +9 -9
  149. package/util/RelayRuntimeTypes.js.flow +73 -4
  150. package/util/StringInterner.js.flow +69 -0
  151. package/util/createPayloadFor3DField.js.flow +3 -3
  152. package/util/deepFreeze.js.flow +2 -1
  153. package/util/getFragmentIdentifier.js.flow +27 -15
  154. package/util/getOperation.js.flow +2 -2
  155. package/util/getPaginationMetadata.js.flow +72 -0
  156. package/util/getPaginationVariables.js.flow +108 -0
  157. package/util/getPendingOperationsForFragment.js.flow +62 -0
  158. package/util/getRefetchMetadata.js.flow +79 -0
  159. package/util/getRelayHandleKey.js.flow +1 -2
  160. package/util/getRequestIdentifier.js.flow +3 -3
  161. package/util/getValueAtPath.js.flow +46 -0
  162. package/util/isEmptyObject.js.flow +2 -1
  163. package/util/registerEnvironmentWithDevTools.js.flow +33 -0
  164. package/util/resolveImmediate.js.flow +1 -1
  165. package/util/withDuration.js.flow +32 -0
  166. package/lib/store/RelayRecordSourceMapImpl.js +0 -107
  167. package/lib/store/RelayStoreSubscriptionsUsingMapByID.js +0 -318
  168. package/store/RelayRecordSourceMapImpl.js.flow +0 -91
  169. package/store/RelayStoreSubscriptionsUsingMapByID.js.flow +0 -283
@@ -14,8 +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 _require = require('./RelayStoreUtils'),
18
+ getArgumentValues = _require.getArgumentValues;
18
19
 
20
+ var invariant = require('invariant');
19
21
  /**
20
22
  * Determines the variables that are in scope for a fragment given the variables
21
23
  * in scope at the root query as well as any arguments applied at the fragment
@@ -23,6 +25,8 @@ var invariant = require("fbjs/lib/invariant");
23
25
  *
24
26
  * Note that this is analagous to determining function arguments given a function call.
25
27
  */
28
+
29
+
26
30
  function getFragmentVariables(fragment, rootVariables, argumentVariables) {
27
31
  var variables;
28
32
  fragment.argumentDefinitions.forEach(function (definition) {
@@ -48,11 +52,9 @@ function getFragmentVariables(fragment, rootVariables, argumentVariables) {
48
52
  * RelayStoreUtils.getStableVariableValue() that variable keys are all
49
53
  * present.
50
54
  */
51
- // $FlowFixMe[incompatible-use]
52
55
  variables[definition.name] = undefined;
53
56
  break;
54
- } // $FlowFixMe[incompatible-use]
55
-
57
+ }
56
58
 
57
59
  variables[definition.name] = rootVariables[definition.name];
58
60
  break;
@@ -86,7 +88,25 @@ function getOperationVariables(operation, variables) {
86
88
  return operationVariables;
87
89
  }
88
90
 
91
+ function getLocalVariables(currentVariables, argumentDefinitions, args) {
92
+ if (argumentDefinitions == null) {
93
+ return currentVariables;
94
+ }
95
+
96
+ var nextVariables = (0, _objectSpread2["default"])({}, currentVariables);
97
+ var nextArgs = args ? getArgumentValues(args, currentVariables) : {};
98
+ argumentDefinitions.forEach(function (def) {
99
+ var _nextArgs$def$name;
100
+
101
+ // $FlowFixMe[cannot-write]
102
+ var value = (_nextArgs$def$name = nextArgs[def.name]) !== null && _nextArgs$def$name !== void 0 ? _nextArgs$def$name : def.defaultValue;
103
+ nextVariables[def.name] = value;
104
+ });
105
+ return nextVariables;
106
+ }
107
+
89
108
  module.exports = {
109
+ getLocalVariables: getLocalVariables,
90
110
  getFragmentVariables: getFragmentVariables,
91
111
  getOperationVariables: getOperationVariables
92
112
  };
@@ -17,34 +17,39 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
17
17
 
18
18
  var RelayDefaultHandlerProvider = require('../handlers/RelayDefaultHandlerProvider');
19
19
 
20
- var RelayFeatureFlags = require('../util/RelayFeatureFlags');
21
-
22
- var RelayModernQueryExecutor = require('./RelayModernQueryExecutor');
20
+ var _require = require('../multi-actor-environment/ActorIdentifier'),
21
+ INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE = _require.INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE,
22
+ assertInternalActorIndentifier = _require.assertInternalActorIndentifier;
23
23
 
24
24
  var RelayObservable = require('../network/RelayObservable');
25
25
 
26
+ var wrapNetworkWithLogObserver = require('../network/wrapNetworkWithLogObserver');
27
+
26
28
  var RelayOperationTracker = require('../store/RelayOperationTracker');
27
29
 
28
- var RelayPublishQueue = require('./RelayPublishQueue');
30
+ var registerEnvironmentWithDevTools = require('../util/registerEnvironmentWithDevTools');
29
31
 
30
- var RelayRecordSource = require('./RelayRecordSource');
32
+ var RelayFeatureFlags = require('../util/RelayFeatureFlags');
31
33
 
32
34
  var defaultGetDataID = require('./defaultGetDataID');
33
35
 
34
36
  var defaultRequiredFieldLogger = require('./defaultRequiredFieldLogger');
35
37
 
36
- var generateID = require('../util/generateID');
38
+ var OperationExecutor = require('./OperationExecutor');
37
39
 
38
- var invariant = require("fbjs/lib/invariant");
40
+ var RelayPublishQueue = require('./RelayPublishQueue');
41
+
42
+ var RelayRecordSource = require('./RelayRecordSource');
43
+
44
+ var invariant = require('invariant');
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
 
@@ -299,7 +277,7 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
299
277
  }
300
278
  /**
301
279
  * Returns an Observable of GraphQLResponse resulting from executing the
302
- * provided Query or Subscription operation, each result of which is then
280
+ * provided Query operation, each result of which is then
303
281
  * normalized and committed to the publish queue.
304
282
  *
305
283
  * Note: Observables are lazy, so calling this method will do nothing until
@@ -308,33 +286,42 @@ 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
- var operation = _ref.operation,
314
- 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);
291
+ var operation = _ref.operation;
292
+ return this._execute({
293
+ createSource: function createSource() {
294
+ return _this7._network.execute(operation.request.node.params, operation.request.variables, operation.request.cacheConfig || {}, null);
295
+ },
296
+ isClientPayload: false,
297
+ operation: operation,
298
+ optimisticConfig: null,
299
+ updater: null
300
+ });
301
+ }
302
+ /**
303
+ * Returns an Observable of GraphQLResponse resulting from executing the
304
+ * provided Subscription operation, each result of which is then
305
+ * normalized and committed to the publish queue.
306
+ *
307
+ * Note: Observables are lazy, so calling this method will do nothing until
308
+ * the result is subscribed to: environment.execute({...}).subscribe({...}).
309
+ */
310
+ ;
317
311
 
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
- };
312
+ _proto.executeSubscription = function executeSubscription(_ref2) {
313
+ var _this8 = this;
314
+
315
+ var operation = _ref2.operation,
316
+ updater = _ref2.updater;
317
+ return this._execute({
318
+ createSource: function createSource() {
319
+ return _this8._network.execute(operation.request.node.params, operation.request.variables, operation.request.cacheConfig || {}, null);
320
+ },
321
+ isClientPayload: false,
322
+ operation: operation,
323
+ optimisticConfig: null,
324
+ updater: updater
338
325
  });
339
326
  }
340
327
  /**
@@ -349,55 +336,40 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
349
336
  */
350
337
  ;
351
338
 
352
- _proto.executeMutation = function executeMutation(_ref2) {
353
- var _this10 = this;
354
-
355
- var operation = _ref2.operation,
356
- optimisticResponse = _ref2.optimisticResponse,
357
- optimisticUpdater = _ref2.optimisticUpdater,
358
- updater = _ref2.updater,
359
- 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
- }
370
-
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);
339
+ _proto.executeMutation = function executeMutation(_ref3) {
340
+ var _this9 = this;
374
341
 
375
- var executor = RelayModernQueryExecutor.execute({
342
+ var operation = _ref3.operation,
343
+ optimisticResponse = _ref3.optimisticResponse,
344
+ optimisticUpdater = _ref3.optimisticUpdater,
345
+ updater = _ref3.updater,
346
+ uploadables = _ref3.uploadables;
347
+ var optimisticConfig;
348
+
349
+ if (optimisticResponse || optimisticUpdater) {
350
+ optimisticConfig = {
376
351
  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();
352
+ response: optimisticResponse,
353
+ updater: optimisticUpdater
394
354
  };
355
+ }
356
+
357
+ return this._execute({
358
+ createSource: function createSource() {
359
+ return _this9._network.execute(operation.request.node.params, operation.request.variables, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, operation.request.cacheConfig), {}, {
360
+ force: true
361
+ }), uploadables);
362
+ },
363
+ isClientPayload: false,
364
+ operation: operation,
365
+ optimisticConfig: optimisticConfig,
366
+ updater: updater
395
367
  });
396
368
  }
397
369
  /**
398
370
  * Returns an Observable of GraphQLResponse resulting from executing the
399
371
  * provided Query or Subscription operation responses, the result of which is
400
- * then normalized and comitted to the publish queue.
372
+ * then normalized and committed to the publish queue.
401
373
  *
402
374
  * Note: Observables are lazy, so calling this method will do nothing until
403
375
  * the result is subscribed to:
@@ -405,27 +377,65 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
405
377
  */
406
378
  ;
407
379
 
408
- _proto.executeWithSource = function executeWithSource(_ref3) {
409
- var _this11 = this;
380
+ _proto.executeWithSource = function executeWithSource(_ref4) {
381
+ var operation = _ref4.operation,
382
+ source = _ref4.source;
383
+ return this._execute({
384
+ createSource: function createSource() {
385
+ return source;
386
+ },
387
+ isClientPayload: false,
388
+ operation: operation,
389
+ optimisticConfig: null,
390
+ updater: null
391
+ });
392
+ };
410
393
 
411
- var operation = _ref3.operation,
412
- source = _ref3.source;
394
+ _proto.toJSON = function toJSON() {
395
+ var _this$configName;
396
+
397
+ return "RelayModernEnvironment(".concat((_this$configName = this.configName) !== null && _this$configName !== void 0 ? _this$configName : '', ")");
398
+ };
399
+
400
+ _proto._execute = function _execute(_ref5) {
401
+ var _this10 = this;
402
+
403
+ var createSource = _ref5.createSource,
404
+ isClientPayload = _ref5.isClientPayload,
405
+ operation = _ref5.operation,
406
+ optimisticConfig = _ref5.optimisticConfig,
407
+ updater = _ref5.updater;
408
+ var publishQueue = this._publishQueue;
409
+ var store = this._store;
413
410
  return RelayObservable.create(function (sink) {
414
- var executor = RelayModernQueryExecutor.execute({
411
+ var executor = OperationExecutor.execute({
412
+ actorIdentifier: INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE,
413
+ getDataID: _this10._getDataID,
414
+ isClientPayload: isClientPayload,
415
+ log: _this10.__log,
415
416
  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,
417
+ operationExecutions: _this10._operationExecutions,
418
+ operationLoader: _this10._operationLoader,
419
+ operationTracker: _this10._operationTracker,
420
+ optimisticConfig: optimisticConfig,
421
+ getPublishQueue: function getPublishQueue(actorIdentifier) {
422
+ assertInternalActorIndentifier(actorIdentifier);
423
+ return publishQueue;
424
+ },
425
+ reactFlightPayloadDeserializer: _this10._reactFlightPayloadDeserializer,
426
+ reactFlightServerErrorHandler: _this10._reactFlightServerErrorHandler,
427
+ scheduler: _this10._scheduler,
428
+ shouldProcessClientComponents: _this10._shouldProcessClientComponents,
424
429
  sink: sink,
425
- source: source,
426
- store: _this11._store,
427
- getDataID: _this11._getDataID,
428
- treatMissingFieldsAsNull: _this11._treatMissingFieldsAsNull
430
+ // NOTE: Some product tests expect `Network.execute` to be called only
431
+ // when the Observable is executed.
432
+ source: createSource(),
433
+ getStore: function getStore(actorIdentifier) {
434
+ assertInternalActorIndentifier(actorIdentifier);
435
+ return store;
436
+ },
437
+ treatMissingFieldsAsNull: _this10._treatMissingFieldsAsNull,
438
+ updater: updater
429
439
  });
430
440
  return function () {
431
441
  return executor.cancel();
@@ -433,75 +443,6 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
433
443
  });
434
444
  };
435
445
 
436
- _proto.toJSON = function toJSON() {
437
- var _this$configName;
438
-
439
- 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
- ;
447
-
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
- };
503
- };
504
-
505
446
  return RelayModernEnvironment;
506
447
  }(); // Add a sigil for detection by `isRelayModernEnvironment()` to avoid a
507
448
  // realm-specific instanceof check, and to aid in module tree-shaking to