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.
- package/handlers/connection/ConnectionHandler.js.flow +7 -0
- package/handlers/connection/MutationHandlers.js.flow +28 -0
- package/index.js +1 -1
- package/index.js.flow +20 -3
- package/lib/handlers/RelayDefaultHandlerProvider.js +1 -1
- package/lib/handlers/connection/ConnectionHandler.js +12 -6
- package/lib/handlers/connection/MutationHandlers.js +67 -8
- package/lib/index.js +15 -0
- package/lib/multi-actor-environment/ActorIdentifier.js +33 -0
- package/lib/multi-actor-environment/ActorSpecificEnvironment.js +148 -0
- package/lib/multi-actor-environment/ActorUtils.js +27 -0
- package/lib/multi-actor-environment/MultiActorEnvironment.js +406 -0
- package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +11 -0
- package/lib/multi-actor-environment/index.js +21 -0
- package/lib/mutations/RelayRecordProxy.js +1 -1
- package/lib/mutations/RelayRecordSourceMutator.js +1 -1
- package/lib/mutations/RelayRecordSourceProxy.js +1 -1
- package/lib/mutations/RelayRecordSourceSelectorProxy.js +7 -2
- package/lib/mutations/applyOptimisticMutation.js +1 -1
- package/lib/mutations/commitMutation.js +5 -2
- package/lib/mutations/validateMutation.js +39 -17
- package/lib/network/RelayNetwork.js +1 -1
- package/lib/network/RelayObservable.js +3 -1
- package/lib/network/RelayQueryResponseCache.js +20 -3
- package/lib/network/wrapNetworkWithLogObserver.js +78 -0
- package/lib/query/GraphQLTag.js +1 -1
- package/lib/query/fetchQuery.js +1 -1
- package/lib/query/fetchQueryInternal.js +1 -1
- package/lib/store/DataChecker.js +132 -50
- package/lib/store/{RelayModernQueryExecutor.js → OperationExecutor.js} +524 -187
- package/lib/store/RelayConcreteVariables.js +29 -4
- package/lib/store/RelayModernEnvironment.js +137 -220
- package/lib/store/RelayModernFragmentSpecResolver.js +49 -23
- package/lib/store/RelayModernRecord.js +36 -2
- package/lib/store/RelayModernSelector.js +1 -1
- package/lib/store/RelayModernStore.js +53 -22
- package/lib/store/RelayOperationTracker.js +34 -24
- package/lib/store/RelayPublishQueue.js +30 -8
- package/lib/store/RelayReader.js +177 -29
- package/lib/store/RelayRecordSource.js +87 -3
- package/lib/store/RelayReferenceMarker.js +53 -28
- package/lib/store/RelayResponseNormalizer.js +247 -108
- package/lib/store/RelayStoreReactFlightUtils.js +7 -11
- package/lib/store/RelayStoreSubscriptions.js +8 -5
- package/lib/store/RelayStoreUtils.js +10 -4
- package/lib/store/ResolverCache.js +213 -0
- package/lib/store/ResolverFragments.js +57 -0
- package/lib/store/cloneRelayHandleSourceField.js +1 -1
- package/lib/store/cloneRelayScalarHandleSourceField.js +1 -1
- package/lib/store/createRelayContext.js +2 -2
- package/lib/store/defaultGetDataID.js +3 -1
- package/lib/store/readInlineData.js +1 -1
- package/lib/subscription/requestSubscription.js +32 -6
- package/lib/util/RelayConcreteNode.js +3 -0
- package/lib/util/RelayFeatureFlags.js +5 -4
- package/lib/util/RelayProfiler.js +17 -187
- package/lib/util/RelayReplaySubject.js +22 -7
- package/lib/util/deepFreeze.js +1 -0
- package/lib/util/getPaginationMetadata.js +41 -0
- package/lib/util/getPaginationVariables.js +67 -0
- package/lib/util/getPendingOperationsForFragment.js +55 -0
- package/lib/util/getRefetchMetadata.js +36 -0
- package/lib/util/getRelayHandleKey.js +1 -1
- package/lib/util/getRequestIdentifier.js +1 -1
- package/lib/util/getValueAtPath.js +51 -0
- package/lib/util/isEmptyObject.js +1 -1
- package/lib/util/registerEnvironmentWithDevTools.js +26 -0
- package/lib/util/withDuration.js +31 -0
- package/multi-actor-environment/ActorIdentifier.js.flow +43 -0
- package/multi-actor-environment/ActorSpecificEnvironment.js.flow +217 -0
- package/multi-actor-environment/ActorUtils.js.flow +33 -0
- package/multi-actor-environment/MultiActorEnvironment.js.flow +485 -0
- package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +245 -0
- package/multi-actor-environment/index.js.flow +27 -0
- package/mutations/RelayRecordSourceSelectorProxy.js.flow +7 -2
- package/mutations/commitMutation.js.flow +3 -1
- package/mutations/validateMutation.js.flow +42 -16
- package/network/RelayNetworkTypes.js.flow +17 -8
- package/network/RelayObservable.js.flow +2 -0
- package/network/RelayQueryResponseCache.js.flow +31 -17
- package/network/wrapNetworkWithLogObserver.js.flow +99 -0
- package/package.json +3 -2
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/ClientID.js.flow +5 -1
- package/store/DataChecker.js.flow +148 -44
- package/store/{RelayModernQueryExecutor.js.flow → OperationExecutor.js.flow} +578 -237
- package/store/RelayConcreteVariables.js.flow +31 -1
- package/store/RelayModernEnvironment.js.flow +132 -220
- package/store/RelayModernFragmentSpecResolver.js.flow +40 -14
- package/store/RelayModernOperationDescriptor.js.flow +9 -3
- package/store/RelayModernRecord.js.flow +49 -0
- package/store/RelayModernStore.js.flow +57 -17
- package/store/RelayOperationTracker.js.flow +56 -34
- package/store/RelayPublishQueue.js.flow +37 -11
- package/store/RelayReader.js.flow +186 -27
- package/store/RelayRecordSource.js.flow +72 -6
- package/store/RelayReferenceMarker.js.flow +51 -21
- package/store/RelayResponseNormalizer.js.flow +251 -67
- package/store/RelayStoreReactFlightUtils.js.flow +6 -9
- package/store/RelayStoreSubscriptions.js.flow +10 -3
- package/store/RelayStoreTypes.js.flow +144 -21
- package/store/RelayStoreUtils.js.flow +19 -4
- package/store/ResolverCache.js.flow +247 -0
- package/store/ResolverFragments.js.flow +128 -0
- package/store/createRelayContext.js.flow +1 -1
- package/store/defaultGetDataID.js.flow +3 -1
- package/subscription/requestSubscription.js.flow +43 -8
- package/util/NormalizationNode.js.flow +16 -3
- package/util/ReaderNode.js.flow +29 -2
- package/util/RelayConcreteNode.js.flow +3 -0
- package/util/RelayFeatureFlags.js.flow +10 -6
- package/util/RelayProfiler.js.flow +22 -194
- package/util/RelayReplaySubject.js.flow +7 -6
- package/util/RelayRuntimeTypes.js.flow +4 -2
- package/util/deepFreeze.js.flow +2 -1
- package/util/getPaginationMetadata.js.flow +74 -0
- package/util/getPaginationVariables.js.flow +112 -0
- package/util/getPendingOperationsForFragment.js.flow +62 -0
- package/util/getRefetchMetadata.js.flow +80 -0
- package/util/getValueAtPath.js.flow +46 -0
- package/util/isEmptyObject.js.flow +2 -1
- package/util/registerEnvironmentWithDevTools.js.flow +33 -0
- package/util/withDuration.js.flow +32 -0
- package/lib/store/RelayRecordSourceMapImpl.js +0 -107
- package/lib/store/RelayStoreSubscriptionsUsingMapByID.js +0 -318
- package/store/RelayRecordSourceMapImpl.js.flow +0 -91
- package/store/RelayStoreSubscriptionsUsingMapByID.js.flow +0 -283
|
@@ -17,10 +17,14 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
|
|
|
17
17
|
|
|
18
18
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
19
19
|
|
|
20
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
+
|
|
20
22
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
21
23
|
|
|
22
24
|
var RelayError = require('../util/RelayError');
|
|
23
25
|
|
|
26
|
+
var RelayFeatureFlags = require('../util/RelayFeatureFlags');
|
|
27
|
+
|
|
24
28
|
var RelayModernRecord = require('./RelayModernRecord');
|
|
25
29
|
|
|
26
30
|
var RelayObservable = require('../network/RelayObservable');
|
|
@@ -29,24 +33,33 @@ var RelayRecordSource = require('./RelayRecordSource');
|
|
|
29
33
|
|
|
30
34
|
var RelayResponseNormalizer = require('./RelayResponseNormalizer');
|
|
31
35
|
|
|
36
|
+
var generateID = require('../util/generateID');
|
|
37
|
+
|
|
32
38
|
var getOperation = require('../util/getOperation');
|
|
33
39
|
|
|
34
|
-
var invariant = require(
|
|
40
|
+
var invariant = require('invariant');
|
|
35
41
|
|
|
36
42
|
var stableCopy = require('../util/stableCopy');
|
|
37
43
|
|
|
38
44
|
var warning = require("fbjs/lib/warning");
|
|
39
45
|
|
|
46
|
+
var withDuration = require('../util/withDuration');
|
|
47
|
+
|
|
40
48
|
var _require = require('./ClientID'),
|
|
41
|
-
generateClientID = _require.generateClientID
|
|
49
|
+
generateClientID = _require.generateClientID,
|
|
50
|
+
generateUniqueClientID = _require.generateUniqueClientID;
|
|
51
|
+
|
|
52
|
+
var _require2 = require('./RelayConcreteVariables'),
|
|
53
|
+
getLocalVariables = _require2.getLocalVariables;
|
|
42
54
|
|
|
43
|
-
var
|
|
44
|
-
createNormalizationSelector =
|
|
55
|
+
var _require3 = require('./RelayModernSelector'),
|
|
56
|
+
createNormalizationSelector = _require3.createNormalizationSelector,
|
|
57
|
+
createReaderSelector = _require3.createReaderSelector;
|
|
45
58
|
|
|
46
|
-
var
|
|
47
|
-
ROOT_TYPE =
|
|
48
|
-
TYPENAME_KEY =
|
|
49
|
-
getStorageKey =
|
|
59
|
+
var _require4 = require('./RelayStoreUtils'),
|
|
60
|
+
ROOT_TYPE = _require4.ROOT_TYPE,
|
|
61
|
+
TYPENAME_KEY = _require4.TYPENAME_KEY,
|
|
62
|
+
getStorageKey = _require4.getStorageKey;
|
|
50
63
|
|
|
51
64
|
function execute(config) {
|
|
52
65
|
return new Executor(config);
|
|
@@ -62,26 +75,51 @@ var Executor = /*#__PURE__*/function () {
|
|
|
62
75
|
function Executor(_ref) {
|
|
63
76
|
var _this = this;
|
|
64
77
|
|
|
65
|
-
var
|
|
78
|
+
var actorIdentifier = _ref.actorIdentifier,
|
|
79
|
+
getDataID = _ref.getDataID,
|
|
80
|
+
getPublishQueue = _ref.getPublishQueue,
|
|
81
|
+
getStore = _ref.getStore,
|
|
82
|
+
isClientPayload = _ref.isClientPayload,
|
|
83
|
+
operation = _ref.operation,
|
|
66
84
|
operationExecutions = _ref.operationExecutions,
|
|
67
85
|
operationLoader = _ref.operationLoader,
|
|
86
|
+
operationTracker = _ref.operationTracker,
|
|
68
87
|
optimisticConfig = _ref.optimisticConfig,
|
|
69
|
-
|
|
88
|
+
_reactFlightPayloadDeserializer = _ref.reactFlightPayloadDeserializer,
|
|
89
|
+
reactFlightServerErrorHandler = _ref.reactFlightServerErrorHandler,
|
|
70
90
|
scheduler = _ref.scheduler,
|
|
91
|
+
shouldProcessClientComponents = _ref.shouldProcessClientComponents,
|
|
71
92
|
sink = _ref.sink,
|
|
72
93
|
source = _ref.source,
|
|
73
|
-
store = _ref.store,
|
|
74
|
-
updater = _ref.updater,
|
|
75
|
-
operationTracker = _ref.operationTracker,
|
|
76
94
|
treatMissingFieldsAsNull = _ref.treatMissingFieldsAsNull,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
95
|
+
updater = _ref.updater,
|
|
96
|
+
log = _ref.log;
|
|
97
|
+
(0, _defineProperty2["default"])(this, "_deserializeReactFlightPayloadWithLogging", function (tree) {
|
|
98
|
+
var reactFlightPayloadDeserializer = _this._reactFlightPayloadDeserializer;
|
|
99
|
+
!(typeof reactFlightPayloadDeserializer === 'function') ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Expected reactFlightPayloadDeserializer to be available when calling _deserializeReactFlightPayloadWithLogging.') : invariant(false) : void 0;
|
|
100
|
+
|
|
101
|
+
var _withDuration = withDuration(function () {
|
|
102
|
+
return reactFlightPayloadDeserializer(tree);
|
|
103
|
+
}),
|
|
104
|
+
duration = _withDuration[0],
|
|
105
|
+
result = _withDuration[1];
|
|
106
|
+
|
|
107
|
+
_this._log({
|
|
108
|
+
name: 'execute.flight.payload_deserialize',
|
|
109
|
+
executeId: _this._executeId,
|
|
110
|
+
operationName: _this._operation.request.node.params.name,
|
|
111
|
+
duration: duration
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
return result;
|
|
115
|
+
});
|
|
116
|
+
this._actorIdentifier = actorIdentifier;
|
|
81
117
|
this._getDataID = getDataID;
|
|
82
118
|
this._treatMissingFieldsAsNull = treatMissingFieldsAsNull;
|
|
83
119
|
this._incrementalPayloadsPending = false;
|
|
84
120
|
this._incrementalResults = new Map();
|
|
121
|
+
this._log = log;
|
|
122
|
+
this._executeId = generateID();
|
|
85
123
|
this._nextSubscriptionId = 0;
|
|
86
124
|
this._operation = operation;
|
|
87
125
|
this._operationExecutions = operationExecutions;
|
|
@@ -90,17 +128,22 @@ var Executor = /*#__PURE__*/function () {
|
|
|
90
128
|
this._operationUpdateEpochs = new Map();
|
|
91
129
|
this._optimisticUpdates = null;
|
|
92
130
|
this._pendingModulePayloadsCount = 0;
|
|
93
|
-
this.
|
|
131
|
+
this._getPublishQueue = getPublishQueue;
|
|
94
132
|
this._scheduler = scheduler;
|
|
95
133
|
this._sink = sink;
|
|
96
134
|
this._source = new Map();
|
|
97
135
|
this._state = 'started';
|
|
98
|
-
this.
|
|
136
|
+
this._getStore = getStore;
|
|
99
137
|
this._subscriptions = new Map();
|
|
100
138
|
this._updater = updater;
|
|
101
139
|
this._isClientPayload = isClientPayload === true;
|
|
102
|
-
this._reactFlightPayloadDeserializer =
|
|
140
|
+
this._reactFlightPayloadDeserializer = _reactFlightPayloadDeserializer;
|
|
103
141
|
this._reactFlightServerErrorHandler = reactFlightServerErrorHandler;
|
|
142
|
+
this._isSubscriptionOperation = this._operation.request.node.params.operationKind === 'subscription';
|
|
143
|
+
this._shouldProcessClientComponents = shouldProcessClientComponents;
|
|
144
|
+
this._retainDisposables = new Map();
|
|
145
|
+
this._seenActors = new Set();
|
|
146
|
+
this._completeFns = [];
|
|
104
147
|
var id = this._nextSubscriptionId++;
|
|
105
148
|
source.subscribe({
|
|
106
149
|
complete: function complete() {
|
|
@@ -117,7 +160,17 @@ var Executor = /*#__PURE__*/function () {
|
|
|
117
160
|
}
|
|
118
161
|
},
|
|
119
162
|
start: function start(subscription) {
|
|
120
|
-
|
|
163
|
+
var _this$_operation$requ;
|
|
164
|
+
|
|
165
|
+
_this._start(id, subscription);
|
|
166
|
+
|
|
167
|
+
_this._log({
|
|
168
|
+
name: 'execute.start',
|
|
169
|
+
executeId: _this._executeId,
|
|
170
|
+
params: _this._operation.request.node.params,
|
|
171
|
+
variables: _this._operation.request.variables,
|
|
172
|
+
cacheConfig: (_this$_operation$requ = _this._operation.request.cacheConfig) !== null && _this$_operation$requ !== void 0 ? _this$_operation$requ : {}
|
|
173
|
+
});
|
|
121
174
|
}
|
|
122
175
|
});
|
|
123
176
|
|
|
@@ -155,21 +208,25 @@ var Executor = /*#__PURE__*/function () {
|
|
|
155
208
|
if (optimisticUpdates !== null) {
|
|
156
209
|
this._optimisticUpdates = null;
|
|
157
210
|
optimisticUpdates.forEach(function (update) {
|
|
158
|
-
return _this2.
|
|
159
|
-
});
|
|
211
|
+
return _this2._getPublishQueueAndSaveActor().revertUpdate(update);
|
|
212
|
+
}); // OK: run revert on cancel
|
|
160
213
|
|
|
161
|
-
this.
|
|
214
|
+
this._runPublishQueue();
|
|
162
215
|
}
|
|
163
216
|
|
|
164
217
|
this._incrementalResults.clear();
|
|
165
218
|
|
|
166
|
-
this.
|
|
167
|
-
|
|
168
|
-
if (this._retainDisposable) {
|
|
169
|
-
this._retainDisposable.dispose();
|
|
219
|
+
if (this._asyncStoreUpdateDisposable != null) {
|
|
220
|
+
this._asyncStoreUpdateDisposable.dispose();
|
|
170
221
|
|
|
171
|
-
this.
|
|
222
|
+
this._asyncStoreUpdateDisposable = null;
|
|
172
223
|
}
|
|
224
|
+
|
|
225
|
+
this._completeFns = [];
|
|
226
|
+
|
|
227
|
+
this._completeOperationTracker();
|
|
228
|
+
|
|
229
|
+
this._disposeRetainedData();
|
|
173
230
|
};
|
|
174
231
|
|
|
175
232
|
_proto._updateActiveState = function _updateActiveState() {
|
|
@@ -202,7 +259,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
202
259
|
|
|
203
260
|
default:
|
|
204
261
|
this._state;
|
|
205
|
-
!false ? process.env.NODE_ENV !== "production" ? invariant(false, '
|
|
262
|
+
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: invalid executor state.') : invariant(false) : void 0;
|
|
206
263
|
}
|
|
207
264
|
|
|
208
265
|
this._operationExecutions.set(this._operation.request.identifier, activeState);
|
|
@@ -251,6 +308,11 @@ var Executor = /*#__PURE__*/function () {
|
|
|
251
308
|
this.cancel();
|
|
252
309
|
|
|
253
310
|
this._sink.complete();
|
|
311
|
+
|
|
312
|
+
this._log({
|
|
313
|
+
name: 'execute.complete',
|
|
314
|
+
executeId: this._executeId
|
|
315
|
+
});
|
|
254
316
|
}
|
|
255
317
|
};
|
|
256
318
|
|
|
@@ -258,6 +320,12 @@ var Executor = /*#__PURE__*/function () {
|
|
|
258
320
|
this.cancel();
|
|
259
321
|
|
|
260
322
|
this._sink.error(error);
|
|
323
|
+
|
|
324
|
+
this._log({
|
|
325
|
+
name: 'execute.error',
|
|
326
|
+
executeId: this._executeId,
|
|
327
|
+
error: error
|
|
328
|
+
});
|
|
261
329
|
};
|
|
262
330
|
|
|
263
331
|
_proto._start = function _start(id, subscription) {
|
|
@@ -271,9 +339,19 @@ var Executor = /*#__PURE__*/function () {
|
|
|
271
339
|
var _this4 = this;
|
|
272
340
|
|
|
273
341
|
this._schedule(function () {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
342
|
+
var _withDuration2 = withDuration(function () {
|
|
343
|
+
_this4._handleNext(response);
|
|
344
|
+
|
|
345
|
+
_this4._maybeCompleteSubscriptionOperationTracking();
|
|
346
|
+
}),
|
|
347
|
+
duration = _withDuration2[0];
|
|
348
|
+
|
|
349
|
+
_this4._log({
|
|
350
|
+
name: 'execute.next',
|
|
351
|
+
executeId: _this4._executeId,
|
|
352
|
+
response: response,
|
|
353
|
+
duration: duration
|
|
354
|
+
});
|
|
277
355
|
});
|
|
278
356
|
};
|
|
279
357
|
|
|
@@ -325,7 +403,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
325
403
|
|
|
326
404
|
return ((_responsePart$extensi = responsePart.extensions) === null || _responsePart$extensi === void 0 ? void 0 : _responsePart$extensi.isOptimistic) === true;
|
|
327
405
|
})) {
|
|
328
|
-
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'Optimistic responses cannot be batched.') : invariant(false) : void 0;
|
|
406
|
+
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Optimistic responses cannot be batched.') : invariant(false) : void 0;
|
|
329
407
|
}
|
|
330
408
|
|
|
331
409
|
return false;
|
|
@@ -335,7 +413,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
335
413
|
var isOptimistic = ((_response$extensions = response.extensions) === null || _response$extensions === void 0 ? void 0 : _response$extensions.isOptimistic) === true;
|
|
336
414
|
|
|
337
415
|
if (isOptimistic && this._state !== 'started') {
|
|
338
|
-
!false ? process.env.NODE_ENV !== "production" ? invariant(false, '
|
|
416
|
+
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: optimistic payload received after server payload.') : invariant(false) : void 0;
|
|
339
417
|
}
|
|
340
418
|
|
|
341
419
|
if (isOptimistic) {
|
|
@@ -354,6 +432,8 @@ var Executor = /*#__PURE__*/function () {
|
|
|
354
432
|
return;
|
|
355
433
|
}
|
|
356
434
|
|
|
435
|
+
this._seenActors.clear();
|
|
436
|
+
|
|
357
437
|
var responses = Array.isArray(response) ? response : [response];
|
|
358
438
|
|
|
359
439
|
var responsesWithData = this._handleErrorResponse(responses);
|
|
@@ -389,7 +469,9 @@ var Executor = /*#__PURE__*/function () {
|
|
|
389
469
|
|
|
390
470
|
var _partitionGraphQLResp = partitionGraphQLResponses(responsesWithData),
|
|
391
471
|
nonIncrementalResponses = _partitionGraphQLResp[0],
|
|
392
|
-
incrementalResponses = _partitionGraphQLResp[1];
|
|
472
|
+
incrementalResponses = _partitionGraphQLResp[1];
|
|
473
|
+
|
|
474
|
+
var hasNonIncrementalResponses = nonIncrementalResponses.length > 0; // In theory this doesn't preserve the ordering of the batch.
|
|
393
475
|
// The idea is that a batch is always:
|
|
394
476
|
// * at most one non-incremental payload
|
|
395
477
|
// * followed by zero or more incremental payloads
|
|
@@ -397,44 +479,64 @@ var Executor = /*#__PURE__*/function () {
|
|
|
397
479
|
// with the initial payload followed by some early-to-resolve incremental
|
|
398
480
|
// payloads (although, can that even happen?)
|
|
399
481
|
|
|
482
|
+
if (hasNonIncrementalResponses) {
|
|
483
|
+
// For subscriptions, to avoid every new payload from overwriting existing
|
|
484
|
+
// data from previous payloads, assign a unique rootID for every new
|
|
485
|
+
// non-incremental payload.
|
|
486
|
+
if (this._isSubscriptionOperation) {
|
|
487
|
+
var nextID = generateUniqueClientID();
|
|
488
|
+
this._operation = {
|
|
489
|
+
request: this._operation.request,
|
|
490
|
+
fragment: createReaderSelector(this._operation.fragment.node, nextID, this._operation.fragment.variables, this._operation.fragment.owner),
|
|
491
|
+
root: createNormalizationSelector(this._operation.root.node, nextID, this._operation.root.variables)
|
|
492
|
+
};
|
|
493
|
+
}
|
|
400
494
|
|
|
401
|
-
|
|
402
|
-
var payloadFollowups = this._processResponses(nonIncrementalResponses); // Please note that we're passing `this._operation` to the publish
|
|
403
|
-
// queue here, which will later passed to the store (via notify)
|
|
404
|
-
// to indicate that this is an operation that caused the store to update
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
var updatedOwners = this._publishQueue.run(this._operation);
|
|
408
|
-
|
|
409
|
-
this._updateOperationTracker(updatedOwners);
|
|
495
|
+
var payloadFollowups = this._processResponses(nonIncrementalResponses);
|
|
410
496
|
|
|
411
497
|
this._processPayloadFollowups(payloadFollowups);
|
|
412
|
-
|
|
413
|
-
if (this._incrementalPayloadsPending && !this._retainDisposable) {
|
|
414
|
-
this._retainDisposable = this._store.retain(this._operation);
|
|
415
|
-
}
|
|
416
498
|
}
|
|
417
499
|
|
|
418
500
|
if (incrementalResponses.length > 0) {
|
|
419
|
-
var _payloadFollowups = this._processIncrementalResponses(incrementalResponses);
|
|
420
|
-
|
|
421
|
-
|
|
501
|
+
var _payloadFollowups = this._processIncrementalResponses(incrementalResponses);
|
|
502
|
+
|
|
503
|
+
this._processPayloadFollowups(_payloadFollowups);
|
|
504
|
+
}
|
|
422
505
|
|
|
506
|
+
if (this._isSubscriptionOperation) {
|
|
507
|
+
// We attach the id to allow the `requestSubscription` to read from the store using
|
|
508
|
+
// the current id in its `onNext` callback
|
|
509
|
+
if (responsesWithData[0].extensions == null) {
|
|
510
|
+
// $FlowFixMe[cannot-write]
|
|
511
|
+
responsesWithData[0].extensions = {
|
|
512
|
+
__relay_subscription_root_id: this._operation.fragment.dataID
|
|
513
|
+
};
|
|
514
|
+
} else {
|
|
515
|
+
responsesWithData[0].extensions.__relay_subscription_root_id = this._operation.fragment.dataID;
|
|
516
|
+
}
|
|
517
|
+
} // OK: run once after each new payload
|
|
518
|
+
// If we have non-incremental responses, we passing `this._operation` to
|
|
519
|
+
// the publish queue here, which will later be passed to the store (via
|
|
520
|
+
// notify) to indicate that this operation caused the store to update
|
|
423
521
|
|
|
424
|
-
var _updatedOwners = this._publishQueue.run();
|
|
425
522
|
|
|
426
|
-
|
|
523
|
+
var updatedOwners = this._runPublishQueue(hasNonIncrementalResponses ? this._operation : undefined);
|
|
427
524
|
|
|
428
|
-
|
|
525
|
+
if (hasNonIncrementalResponses) {
|
|
526
|
+
if (this._incrementalPayloadsPending) {
|
|
527
|
+
this._retainData();
|
|
528
|
+
}
|
|
429
529
|
}
|
|
430
530
|
|
|
531
|
+
this._updateOperationTracker(updatedOwners);
|
|
532
|
+
|
|
431
533
|
this._sink.next(response);
|
|
432
534
|
};
|
|
433
535
|
|
|
434
536
|
_proto._processOptimisticResponse = function _processOptimisticResponse(response, updater, treatMissingFieldsAsNull) {
|
|
435
537
|
var _this6 = this;
|
|
436
538
|
|
|
437
|
-
!(this._optimisticUpdates === null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'environment.execute: only support one optimistic response per ' + 'execute.') : invariant(false) : void 0;
|
|
539
|
+
!(this._optimisticUpdates === null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: environment.execute: only support one optimistic response per ' + 'execute.') : invariant(false) : void 0;
|
|
438
540
|
|
|
439
541
|
if (response == null && updater == null) {
|
|
440
542
|
return;
|
|
@@ -444,10 +546,12 @@ var Executor = /*#__PURE__*/function () {
|
|
|
444
546
|
|
|
445
547
|
if (response) {
|
|
446
548
|
var payload = normalizeResponse(response, this._operation.root, ROOT_TYPE, {
|
|
549
|
+
actorIdentifier: this._actorIdentifier,
|
|
447
550
|
getDataID: this._getDataID,
|
|
448
551
|
path: [],
|
|
449
|
-
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer,
|
|
552
|
+
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer != null ? this._deserializeReactFlightPayloadWithLogging : null,
|
|
450
553
|
reactFlightServerErrorHandler: this._reactFlightServerErrorHandler,
|
|
554
|
+
shouldProcessClientComponents: this._shouldProcessClientComponents,
|
|
451
555
|
treatMissingFieldsAsNull: treatMissingFieldsAsNull
|
|
452
556
|
});
|
|
453
557
|
validateOptimisticResponsePayload(payload);
|
|
@@ -465,7 +569,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
465
569
|
errors: null,
|
|
466
570
|
fieldPayloads: null,
|
|
467
571
|
incrementalPlaceholders: null,
|
|
468
|
-
|
|
572
|
+
followupPayloads: null,
|
|
469
573
|
source: RelayRecordSource.create(),
|
|
470
574
|
isFinal: false
|
|
471
575
|
},
|
|
@@ -475,32 +579,47 @@ var Executor = /*#__PURE__*/function () {
|
|
|
475
579
|
|
|
476
580
|
this._optimisticUpdates = optimisticUpdates;
|
|
477
581
|
optimisticUpdates.forEach(function (update) {
|
|
478
|
-
return _this6.
|
|
479
|
-
});
|
|
582
|
+
return _this6._getPublishQueueAndSaveActor().applyUpdate(update);
|
|
583
|
+
}); // OK: only called on construction and when receiving an optimistic payload from network,
|
|
584
|
+
// which doesn't fall-through to the regular next() handling
|
|
480
585
|
|
|
481
|
-
this.
|
|
586
|
+
this._runPublishQueue();
|
|
482
587
|
};
|
|
483
588
|
|
|
484
589
|
_proto._processOptimisticFollowups = function _processOptimisticFollowups(payload, optimisticUpdates) {
|
|
485
|
-
if (payload.
|
|
486
|
-
var
|
|
487
|
-
var operationLoader = this._operationLoader;
|
|
488
|
-
!operationLoader ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayModernEnvironment: Expected an operationLoader to be ' + 'configured when using `@match`.') : invariant(false) : void 0;
|
|
590
|
+
if (payload.followupPayloads && payload.followupPayloads.length) {
|
|
591
|
+
var followupPayloads = payload.followupPayloads;
|
|
489
592
|
|
|
490
|
-
var _iterator = (0, _createForOfIteratorHelper2["default"])(
|
|
593
|
+
var _iterator = (0, _createForOfIteratorHelper2["default"])(followupPayloads),
|
|
491
594
|
_step;
|
|
492
595
|
|
|
493
596
|
try {
|
|
494
597
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
495
|
-
var
|
|
496
|
-
|
|
598
|
+
var followupPayload = _step.value;
|
|
599
|
+
|
|
600
|
+
switch (followupPayload.kind) {
|
|
601
|
+
case 'ModuleImportPayload':
|
|
602
|
+
var operationLoader = this._expectOperationLoader();
|
|
603
|
+
|
|
604
|
+
var operation = operationLoader.get(followupPayload.operationReference);
|
|
605
|
+
|
|
606
|
+
if (operation == null) {
|
|
607
|
+
this._processAsyncOptimisticModuleImport(followupPayload);
|
|
608
|
+
} else {
|
|
609
|
+
var moduleImportOptimisticUpdates = this._processOptimisticModuleImport(operation, followupPayload);
|
|
610
|
+
|
|
611
|
+
optimisticUpdates.push.apply(optimisticUpdates, (0, _toConsumableArray2["default"])(moduleImportOptimisticUpdates));
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
break;
|
|
497
615
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
var moduleImportOptimisticUpdates = this._processOptimisticModuleImport(operation, moduleImportPayload);
|
|
616
|
+
case 'ActorPayload':
|
|
617
|
+
process.env.NODE_ENV !== "production" ? warning(false, 'OperationExecutor: Unexpected optimistic ActorPayload. These updates are not supported.') : void 0;
|
|
618
|
+
break;
|
|
502
619
|
|
|
503
|
-
|
|
620
|
+
default:
|
|
621
|
+
followupPayload;
|
|
622
|
+
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Unexpected followup kind `%s`. when processing optimistic updates.', followupPayload.kind) : invariant(false) : void 0;
|
|
504
623
|
}
|
|
505
624
|
}
|
|
506
625
|
} catch (err) {
|
|
@@ -509,18 +628,32 @@ var Executor = /*#__PURE__*/function () {
|
|
|
509
628
|
_iterator.f();
|
|
510
629
|
}
|
|
511
630
|
}
|
|
512
|
-
}
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Normalize Data for @module payload, and actor-specific payload
|
|
634
|
+
*/
|
|
635
|
+
;
|
|
636
|
+
|
|
637
|
+
_proto._normalizeFollowupPayload = function _normalizeFollowupPayload(followupPayload, normalizationNode) {
|
|
638
|
+
var variables;
|
|
639
|
+
|
|
640
|
+
if (normalizationNode.kind === 'SplitOperation' && followupPayload.kind === 'ModuleImportPayload') {
|
|
641
|
+
variables = getLocalVariables(followupPayload.variables, normalizationNode.argumentDefinitions, followupPayload.args);
|
|
642
|
+
} else {
|
|
643
|
+
variables = followupPayload.variables;
|
|
644
|
+
}
|
|
513
645
|
|
|
514
|
-
|
|
515
|
-
var selector = createNormalizationSelector(operation, moduleImportPayload.dataID, moduleImportPayload.variables);
|
|
646
|
+
var selector = createNormalizationSelector(normalizationNode, followupPayload.dataID, variables);
|
|
516
647
|
return normalizeResponse({
|
|
517
|
-
data:
|
|
518
|
-
}, selector,
|
|
648
|
+
data: followupPayload.data
|
|
649
|
+
}, selector, followupPayload.typeName, {
|
|
650
|
+
actorIdentifier: this._actorIdentifier,
|
|
519
651
|
getDataID: this._getDataID,
|
|
520
|
-
path:
|
|
521
|
-
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer,
|
|
652
|
+
path: followupPayload.path,
|
|
653
|
+
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer != null ? this._deserializeReactFlightPayloadWithLogging : null,
|
|
522
654
|
reactFlightServerErrorHandler: this._reactFlightServerErrorHandler,
|
|
523
|
-
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull
|
|
655
|
+
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
656
|
+
shouldProcessClientComponents: this._shouldProcessClientComponents
|
|
524
657
|
});
|
|
525
658
|
};
|
|
526
659
|
|
|
@@ -528,7 +661,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
528
661
|
var operation = getOperation(normalizationRootNode);
|
|
529
662
|
var optimisticUpdates = [];
|
|
530
663
|
|
|
531
|
-
var modulePayload = this.
|
|
664
|
+
var modulePayload = this._normalizeFollowupPayload(moduleImportPayload, operation);
|
|
532
665
|
|
|
533
666
|
validateOptimisticResponsePayload(modulePayload);
|
|
534
667
|
optimisticUpdates.push({
|
|
@@ -542,10 +675,10 @@ var Executor = /*#__PURE__*/function () {
|
|
|
542
675
|
return optimisticUpdates;
|
|
543
676
|
};
|
|
544
677
|
|
|
545
|
-
_proto._processAsyncOptimisticModuleImport = function _processAsyncOptimisticModuleImport(
|
|
678
|
+
_proto._processAsyncOptimisticModuleImport = function _processAsyncOptimisticModuleImport(moduleImportPayload) {
|
|
546
679
|
var _this7 = this;
|
|
547
680
|
|
|
548
|
-
|
|
681
|
+
this._expectOperationLoader().load(moduleImportPayload.operationReference).then(function (operation) {
|
|
549
682
|
if (operation == null || _this7._state !== 'started') {
|
|
550
683
|
return;
|
|
551
684
|
}
|
|
@@ -553,17 +686,18 @@ var Executor = /*#__PURE__*/function () {
|
|
|
553
686
|
var moduleImportOptimisticUpdates = _this7._processOptimisticModuleImport(operation, moduleImportPayload);
|
|
554
687
|
|
|
555
688
|
moduleImportOptimisticUpdates.forEach(function (update) {
|
|
556
|
-
return _this7.
|
|
689
|
+
return _this7._getPublishQueueAndSaveActor().applyUpdate(update);
|
|
557
690
|
});
|
|
558
691
|
|
|
559
692
|
if (_this7._optimisticUpdates == null) {
|
|
560
|
-
process.env.NODE_ENV !== "production" ? warning(false, '
|
|
693
|
+
process.env.NODE_ENV !== "production" ? warning(false, 'OperationExecutor: Unexpected ModuleImport optimistic ' + 'update in operation %s.' + _this7._operation.request.node.params.name) : void 0;
|
|
561
694
|
} else {
|
|
562
695
|
var _this$_optimisticUpda;
|
|
563
696
|
|
|
564
|
-
(_this$_optimisticUpda = _this7._optimisticUpdates).push.apply(_this$_optimisticUpda, (0, _toConsumableArray2["default"])(moduleImportOptimisticUpdates));
|
|
697
|
+
(_this$_optimisticUpda = _this7._optimisticUpdates).push.apply(_this$_optimisticUpda, (0, _toConsumableArray2["default"])(moduleImportOptimisticUpdates)); // OK: always have to run() after an module import resolves async
|
|
565
698
|
|
|
566
|
-
|
|
699
|
+
|
|
700
|
+
_this7._runPublishQueue();
|
|
567
701
|
}
|
|
568
702
|
});
|
|
569
703
|
};
|
|
@@ -573,7 +707,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
573
707
|
|
|
574
708
|
if (this._optimisticUpdates !== null) {
|
|
575
709
|
this._optimisticUpdates.forEach(function (update) {
|
|
576
|
-
|
|
710
|
+
_this8._getPublishQueueAndSaveActor().revertUpdate(update);
|
|
577
711
|
});
|
|
578
712
|
|
|
579
713
|
this._optimisticUpdates = null;
|
|
@@ -587,14 +721,16 @@ var Executor = /*#__PURE__*/function () {
|
|
|
587
721
|
|
|
588
722
|
return responses.map(function (payloadPart) {
|
|
589
723
|
var relayPayload = normalizeResponse(payloadPart, _this8._operation.root, ROOT_TYPE, {
|
|
724
|
+
actorIdentifier: _this8._actorIdentifier,
|
|
590
725
|
getDataID: _this8._getDataID,
|
|
591
726
|
path: [],
|
|
592
|
-
reactFlightPayloadDeserializer: _this8._reactFlightPayloadDeserializer,
|
|
727
|
+
reactFlightPayloadDeserializer: _this8._reactFlightPayloadDeserializer != null ? _this8._deserializeReactFlightPayloadWithLogging : null,
|
|
593
728
|
reactFlightServerErrorHandler: _this8._reactFlightServerErrorHandler,
|
|
594
|
-
treatMissingFieldsAsNull: _this8._treatMissingFieldsAsNull
|
|
729
|
+
treatMissingFieldsAsNull: _this8._treatMissingFieldsAsNull,
|
|
730
|
+
shouldProcessClientComponents: _this8._shouldProcessClientComponents
|
|
595
731
|
});
|
|
596
732
|
|
|
597
|
-
_this8.
|
|
733
|
+
_this8._getPublishQueueAndSaveActor().commitPayload(_this8._operation, relayPayload, _this8._updater);
|
|
598
734
|
|
|
599
735
|
return relayPayload;
|
|
600
736
|
});
|
|
@@ -614,7 +750,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
614
750
|
|
|
615
751
|
payloads.forEach(function (payload) {
|
|
616
752
|
var incrementalPlaceholders = payload.incrementalPlaceholders,
|
|
617
|
-
|
|
753
|
+
followupPayloads = payload.followupPayloads,
|
|
618
754
|
isFinal = payload.isFinal;
|
|
619
755
|
_this9._state = isFinal ? 'loading_final' : 'loading_incremental';
|
|
620
756
|
|
|
@@ -624,18 +760,30 @@ var Executor = /*#__PURE__*/function () {
|
|
|
624
760
|
_this9._incrementalPayloadsPending = false;
|
|
625
761
|
}
|
|
626
762
|
|
|
627
|
-
if (
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
_this9.
|
|
763
|
+
if (followupPayloads && followupPayloads.length !== 0) {
|
|
764
|
+
followupPayloads.forEach(function (followupPayload) {
|
|
765
|
+
var _followupPayload$acto;
|
|
766
|
+
|
|
767
|
+
var prevActorIdentifier = _this9._actorIdentifier;
|
|
768
|
+
_this9._actorIdentifier = (_followupPayload$acto = followupPayload.actorIdentifier) !== null && _followupPayload$acto !== void 0 ? _followupPayload$acto : _this9._actorIdentifier;
|
|
769
|
+
|
|
770
|
+
_this9._processFollowupPayload(followupPayload);
|
|
771
|
+
|
|
772
|
+
_this9._actorIdentifier = prevActorIdentifier;
|
|
632
773
|
});
|
|
633
774
|
}
|
|
634
775
|
|
|
635
776
|
if (incrementalPlaceholders && incrementalPlaceholders.length !== 0) {
|
|
636
777
|
_this9._incrementalPayloadsPending = _this9._state !== 'loading_final';
|
|
637
778
|
incrementalPlaceholders.forEach(function (incrementalPlaceholder) {
|
|
779
|
+
var _incrementalPlacehold;
|
|
780
|
+
|
|
781
|
+
var prevActorIdentifier = _this9._actorIdentifier;
|
|
782
|
+
_this9._actorIdentifier = (_incrementalPlacehold = incrementalPlaceholder.actorIdentifier) !== null && _incrementalPlacehold !== void 0 ? _incrementalPlacehold : _this9._actorIdentifier;
|
|
783
|
+
|
|
638
784
|
_this9._processIncrementalPlaceholder(payload, incrementalPlaceholder);
|
|
785
|
+
|
|
786
|
+
_this9._actorIdentifier = prevActorIdentifier;
|
|
639
787
|
});
|
|
640
788
|
|
|
641
789
|
if (_this9._isClientPayload || _this9._state === 'loading_final') {
|
|
@@ -657,10 +805,6 @@ var Executor = /*#__PURE__*/function () {
|
|
|
657
805
|
});
|
|
658
806
|
|
|
659
807
|
if (relayPayloads.length > 0) {
|
|
660
|
-
var updatedOwners = _this9._publishQueue.run();
|
|
661
|
-
|
|
662
|
-
_this9._updateOperationTracker(updatedOwners);
|
|
663
|
-
|
|
664
808
|
_this9._processPayloadFollowups(relayPayloads);
|
|
665
809
|
}
|
|
666
810
|
}
|
|
@@ -669,9 +813,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
669
813
|
};
|
|
670
814
|
|
|
671
815
|
_proto._maybeCompleteSubscriptionOperationTracking = function _maybeCompleteSubscriptionOperationTracking() {
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
if (!isSubscriptionOperation) {
|
|
816
|
+
if (!this._isSubscriptionOperation) {
|
|
675
817
|
return;
|
|
676
818
|
}
|
|
677
819
|
|
|
@@ -688,68 +830,140 @@ var Executor = /*#__PURE__*/function () {
|
|
|
688
830
|
*/
|
|
689
831
|
;
|
|
690
832
|
|
|
691
|
-
_proto.
|
|
833
|
+
_proto._processFollowupPayload = function _processFollowupPayload(followupPayload) {
|
|
692
834
|
var _this10 = this;
|
|
693
835
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
836
|
+
switch (followupPayload.kind) {
|
|
837
|
+
case 'ModuleImportPayload':
|
|
838
|
+
var operationLoader = this._expectOperationLoader();
|
|
839
|
+
|
|
840
|
+
var node = operationLoader.get(followupPayload.operationReference);
|
|
841
|
+
|
|
842
|
+
if (node != null) {
|
|
843
|
+
// If the operation module is available synchronously, normalize the
|
|
844
|
+
// data synchronously.
|
|
845
|
+
this._processFollowupPayloadWithNormalizationNode(followupPayload, getOperation(node));
|
|
846
|
+
} else {
|
|
847
|
+
// Otherwise load the operation module and schedule a task to normalize
|
|
848
|
+
// the data when the module is available.
|
|
849
|
+
var _id3 = this._nextSubscriptionId++;
|
|
850
|
+
|
|
851
|
+
this._pendingModulePayloadsCount++;
|
|
852
|
+
|
|
853
|
+
var decrementPendingCount = function decrementPendingCount() {
|
|
854
|
+
_this10._pendingModulePayloadsCount--;
|
|
855
|
+
|
|
856
|
+
_this10._maybeCompleteSubscriptionOperationTracking();
|
|
857
|
+
}; // Observable.from(operationLoader.load()) wouldn't catch synchronous
|
|
858
|
+
// errors thrown by the load function, which is user-defined. Guard
|
|
859
|
+
// against that with Observable.from(new Promise(<work>)).
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
var networkObservable = RelayObservable.from(new Promise(function (resolve, reject) {
|
|
863
|
+
operationLoader.load(followupPayload.operationReference).then(resolve, reject);
|
|
864
|
+
}));
|
|
865
|
+
RelayObservable.create(function (sink) {
|
|
866
|
+
var cancellationToken;
|
|
867
|
+
var subscription = networkObservable.subscribe({
|
|
868
|
+
next: function next(loadedNode) {
|
|
869
|
+
if (loadedNode != null) {
|
|
870
|
+
var publishModuleImportPayload = function publishModuleImportPayload() {
|
|
871
|
+
try {
|
|
872
|
+
var operation = getOperation(loadedNode);
|
|
873
|
+
var batchAsyncModuleUpdatesFN = RelayFeatureFlags.BATCH_ASYNC_MODULE_UPDATES_FN;
|
|
874
|
+
var shouldScheduleAsyncStoreUpdate = batchAsyncModuleUpdatesFN != null && _this10._pendingModulePayloadsCount > 1;
|
|
875
|
+
|
|
876
|
+
var _withDuration3 = withDuration(function () {
|
|
877
|
+
_this10._handleFollowupPayload(followupPayload, operation); // OK: always have to run after an async module import resolves
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
// OK: always have to run after an async module import resolves
|
|
881
|
+
if (shouldScheduleAsyncStoreUpdate) {
|
|
882
|
+
_this10._scheduleAsyncStoreUpdate( // $FlowFixMe[incompatible-call] `shouldScheduleAsyncStoreUpdate` check should cover `null` case
|
|
883
|
+
batchAsyncModuleUpdatesFN, sink.complete);
|
|
884
|
+
} else {
|
|
885
|
+
var updatedOwners = _this10._runPublishQueue();
|
|
886
|
+
|
|
887
|
+
_this10._updateOperationTracker(updatedOwners);
|
|
888
|
+
}
|
|
889
|
+
}),
|
|
890
|
+
duration = _withDuration3[0];
|
|
891
|
+
|
|
892
|
+
_this10._log({
|
|
893
|
+
name: 'execute.async.module',
|
|
894
|
+
executeId: _this10._executeId,
|
|
895
|
+
operationName: operation.name,
|
|
896
|
+
duration: duration
|
|
897
|
+
});
|
|
898
|
+
|
|
899
|
+
if (!shouldScheduleAsyncStoreUpdate) {
|
|
900
|
+
sink.complete();
|
|
901
|
+
}
|
|
902
|
+
} catch (error) {
|
|
903
|
+
sink.error(error);
|
|
904
|
+
}
|
|
905
|
+
};
|
|
906
|
+
|
|
907
|
+
var scheduler = _this10._scheduler;
|
|
908
|
+
|
|
909
|
+
if (scheduler == null) {
|
|
910
|
+
publishModuleImportPayload();
|
|
911
|
+
} else {
|
|
912
|
+
cancellationToken = scheduler.schedule(publishModuleImportPayload);
|
|
913
|
+
}
|
|
914
|
+
} else {
|
|
915
|
+
sink.complete();
|
|
916
|
+
}
|
|
917
|
+
},
|
|
918
|
+
error: sink.error
|
|
919
|
+
});
|
|
920
|
+
return function () {
|
|
921
|
+
subscription.unsubscribe();
|
|
922
|
+
|
|
923
|
+
if (_this10._scheduler != null && cancellationToken != null) {
|
|
924
|
+
_this10._scheduler.cancel(cancellationToken);
|
|
925
|
+
}
|
|
926
|
+
};
|
|
927
|
+
}).subscribe({
|
|
928
|
+
complete: function complete() {
|
|
929
|
+
_this10._complete(_id3);
|
|
930
|
+
|
|
931
|
+
decrementPendingCount();
|
|
932
|
+
},
|
|
933
|
+
error: function error(_error4) {
|
|
934
|
+
_this10._error(_error4);
|
|
935
|
+
|
|
936
|
+
decrementPendingCount();
|
|
937
|
+
},
|
|
938
|
+
start: function start(subscription) {
|
|
939
|
+
return _this10._start(_id3, subscription);
|
|
940
|
+
}
|
|
725
941
|
});
|
|
726
942
|
}
|
|
727
|
-
}).subscribe({
|
|
728
|
-
complete: function complete() {
|
|
729
|
-
_this10._complete(_id3);
|
|
730
943
|
|
|
731
|
-
|
|
732
|
-
},
|
|
733
|
-
error: function error(_error4) {
|
|
734
|
-
_this10._error(_error4);
|
|
944
|
+
break;
|
|
735
945
|
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
946
|
+
case 'ActorPayload':
|
|
947
|
+
this._processFollowupPayloadWithNormalizationNode(followupPayload, followupPayload.node);
|
|
948
|
+
|
|
949
|
+
break;
|
|
950
|
+
|
|
951
|
+
default:
|
|
952
|
+
followupPayload;
|
|
953
|
+
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Unexpected followup kind `%s`.', followupPayload.kind) : invariant(false) : void 0;
|
|
742
954
|
}
|
|
743
955
|
};
|
|
744
956
|
|
|
745
|
-
_proto.
|
|
746
|
-
|
|
957
|
+
_proto._processFollowupPayloadWithNormalizationNode = function _processFollowupPayloadWithNormalizationNode(followupPayload, normalizationNode) {
|
|
958
|
+
this._handleFollowupPayload(followupPayload, normalizationNode);
|
|
747
959
|
|
|
748
|
-
this.
|
|
960
|
+
this._maybeCompleteSubscriptionOperationTracking();
|
|
961
|
+
};
|
|
749
962
|
|
|
750
|
-
|
|
963
|
+
_proto._handleFollowupPayload = function _handleFollowupPayload(followupPayload, normalizationNode) {
|
|
964
|
+
var relayPayload = this._normalizeFollowupPayload(followupPayload, normalizationNode);
|
|
751
965
|
|
|
752
|
-
this.
|
|
966
|
+
this._getPublishQueueAndSaveActor().commitPayload(this._operation, relayPayload);
|
|
753
967
|
|
|
754
968
|
this._processPayloadFollowups([relayPayload]);
|
|
755
969
|
}
|
|
@@ -799,7 +1013,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
799
1013
|
parentID = placeholder.selector.dataID;
|
|
800
1014
|
} else {
|
|
801
1015
|
placeholder;
|
|
802
|
-
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'Unsupported incremental placeholder kind `%s`.', placeholder.kind) : invariant(false) : void 0;
|
|
1016
|
+
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Unsupported incremental placeholder kind `%s`.', placeholder.kind) : invariant(false) : void 0;
|
|
803
1017
|
}
|
|
804
1018
|
|
|
805
1019
|
var parentRecord = relayPayload.source.get(parentID);
|
|
@@ -813,7 +1027,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
813
1027
|
}); // If an incremental payload exists for some id that record should also
|
|
814
1028
|
// exist.
|
|
815
1029
|
|
|
816
|
-
!(parentRecord != null) ? process.env.NODE_ENV !== "production" ? invariant(false, '
|
|
1030
|
+
!(parentRecord != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Expected record `%s` to exist.', parentID) : invariant(false) : void 0;
|
|
817
1031
|
var nextParentRecord;
|
|
818
1032
|
var nextParentPayloads;
|
|
819
1033
|
|
|
@@ -848,10 +1062,6 @@ var Executor = /*#__PURE__*/function () {
|
|
|
848
1062
|
if (pendingResponses != null) {
|
|
849
1063
|
var payloadFollowups = this._processIncrementalResponses(pendingResponses);
|
|
850
1064
|
|
|
851
|
-
var updatedOwners = this._publishQueue.run();
|
|
852
|
-
|
|
853
|
-
this._updateOperationTracker(updatedOwners);
|
|
854
|
-
|
|
855
1065
|
this._processPayloadFollowups(payloadFollowups);
|
|
856
1066
|
}
|
|
857
1067
|
}
|
|
@@ -896,7 +1106,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
896
1106
|
}
|
|
897
1107
|
|
|
898
1108
|
var placeholder = resultForPath.placeholder;
|
|
899
|
-
!(placeholder.kind === 'defer') ? process.env.NODE_ENV !== "production" ? invariant(false, '
|
|
1109
|
+
!(placeholder.kind === 'defer') ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Expected data for path `%s` for label `%s` ' + 'to be data for @defer, was `@%s`.', pathKey, label, placeholder.kind) : invariant(false) : void 0;
|
|
900
1110
|
relayPayloads.push(_this11._processDeferResponse(label, path, placeholder, response));
|
|
901
1111
|
} else {
|
|
902
1112
|
// @stream payload path values end in the field name and item index,
|
|
@@ -921,7 +1131,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
921
1131
|
}
|
|
922
1132
|
|
|
923
1133
|
var _placeholder = _resultForPath.placeholder;
|
|
924
|
-
!(_placeholder.kind === 'stream') ? process.env.NODE_ENV !== "production" ? invariant(false, '
|
|
1134
|
+
!(_placeholder.kind === 'stream') ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Expected data for path `%s` for label `%s` ' + 'to be data for @stream, was `@%s`.', _pathKey, label, _placeholder.kind) : invariant(false) : void 0;
|
|
925
1135
|
relayPayloads.push(_this11._processStreamResponse(label, path, _placeholder, response));
|
|
926
1136
|
}
|
|
927
1137
|
});
|
|
@@ -929,22 +1139,28 @@ var Executor = /*#__PURE__*/function () {
|
|
|
929
1139
|
};
|
|
930
1140
|
|
|
931
1141
|
_proto._processDeferResponse = function _processDeferResponse(label, path, placeholder, response) {
|
|
1142
|
+
var _placeholder$actorIde;
|
|
1143
|
+
|
|
932
1144
|
var parentID = placeholder.selector.dataID;
|
|
1145
|
+
var prevActorIdentifier = this._actorIdentifier;
|
|
1146
|
+
this._actorIdentifier = (_placeholder$actorIde = placeholder.actorIdentifier) !== null && _placeholder$actorIde !== void 0 ? _placeholder$actorIde : this._actorIdentifier;
|
|
933
1147
|
var relayPayload = normalizeResponse(response, placeholder.selector, placeholder.typeName, {
|
|
1148
|
+
actorIdentifier: this._actorIdentifier,
|
|
934
1149
|
getDataID: this._getDataID,
|
|
935
1150
|
path: placeholder.path,
|
|
936
|
-
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer,
|
|
1151
|
+
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer != null ? this._deserializeReactFlightPayloadWithLogging : null,
|
|
937
1152
|
reactFlightServerErrorHandler: this._reactFlightServerErrorHandler,
|
|
938
|
-
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull
|
|
1153
|
+
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
1154
|
+
shouldProcessClientComponents: this._shouldProcessClientComponents
|
|
939
1155
|
});
|
|
940
1156
|
|
|
941
|
-
this.
|
|
1157
|
+
this._getPublishQueueAndSaveActor().commitPayload(this._operation, relayPayload); // Load the version of the parent record from which this incremental data
|
|
942
1158
|
// was derived
|
|
943
1159
|
|
|
944
1160
|
|
|
945
1161
|
var parentEntry = this._source.get(parentID);
|
|
946
1162
|
|
|
947
|
-
!(parentEntry != null) ? process.env.NODE_ENV !== "production" ? invariant(false, '
|
|
1163
|
+
!(parentEntry != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Expected the parent record `%s` for @defer ' + 'data to exist.', parentID) : invariant(false) : void 0;
|
|
948
1164
|
var fieldPayloads = parentEntry.fieldPayloads;
|
|
949
1165
|
|
|
950
1166
|
if (fieldPayloads.length !== 0) {
|
|
@@ -954,14 +1170,15 @@ var Executor = /*#__PURE__*/function () {
|
|
|
954
1170
|
errors: null,
|
|
955
1171
|
fieldPayloads: fieldPayloads,
|
|
956
1172
|
incrementalPlaceholders: null,
|
|
957
|
-
|
|
1173
|
+
followupPayloads: null,
|
|
958
1174
|
source: RelayRecordSource.create(),
|
|
959
1175
|
isFinal: ((_response$extensions2 = response.extensions) === null || _response$extensions2 === void 0 ? void 0 : _response$extensions2.is_final) === true
|
|
960
1176
|
};
|
|
961
1177
|
|
|
962
|
-
this.
|
|
1178
|
+
this._getPublishQueueAndSaveActor().commitPayload(this._operation, handleFieldsRelayPayload);
|
|
963
1179
|
}
|
|
964
1180
|
|
|
1181
|
+
this._actorIdentifier = prevActorIdentifier;
|
|
965
1182
|
return relayPayload;
|
|
966
1183
|
}
|
|
967
1184
|
/**
|
|
@@ -972,10 +1189,13 @@ var Executor = /*#__PURE__*/function () {
|
|
|
972
1189
|
_proto._processStreamResponse = function _processStreamResponse(label, path, placeholder, response) {
|
|
973
1190
|
var parentID = placeholder.parentID,
|
|
974
1191
|
node = placeholder.node,
|
|
975
|
-
variables = placeholder.variables
|
|
1192
|
+
variables = placeholder.variables,
|
|
1193
|
+
actorIdentifier = placeholder.actorIdentifier;
|
|
1194
|
+
var prevActorIdentifier = this._actorIdentifier;
|
|
1195
|
+
this._actorIdentifier = actorIdentifier !== null && actorIdentifier !== void 0 ? actorIdentifier : this._actorIdentifier; // Find the LinkedField where @stream was applied
|
|
976
1196
|
|
|
977
1197
|
var field = node.selections[0];
|
|
978
|
-
!(field != null && field.kind === 'LinkedField' && field.plural === true) ? process.env.NODE_ENV !== "production" ? invariant(false, '
|
|
1198
|
+
!(field != null && field.kind === 'LinkedField' && field.plural === true) ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Expected @stream to be used on a plural field.') : invariant(false) : void 0;
|
|
979
1199
|
|
|
980
1200
|
var _this$_normalizeStrea = this._normalizeStreamItem(response, parentID, field, variables, path, placeholder.path),
|
|
981
1201
|
fieldPayloads = _this$_normalizeStrea.fieldPayloads,
|
|
@@ -988,7 +1208,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
988
1208
|
// modified.
|
|
989
1209
|
|
|
990
1210
|
|
|
991
|
-
this.
|
|
1211
|
+
this._getPublishQueueAndSaveActor().commitPayload(this._operation, relayPayload, function (store) {
|
|
992
1212
|
var currentParentRecord = store.get(parentID);
|
|
993
1213
|
|
|
994
1214
|
if (currentParentRecord == null) {
|
|
@@ -1025,14 +1245,15 @@ var Executor = /*#__PURE__*/function () {
|
|
|
1025
1245
|
errors: null,
|
|
1026
1246
|
fieldPayloads: fieldPayloads,
|
|
1027
1247
|
incrementalPlaceholders: null,
|
|
1028
|
-
|
|
1248
|
+
followupPayloads: null,
|
|
1029
1249
|
source: RelayRecordSource.create(),
|
|
1030
1250
|
isFinal: false
|
|
1031
1251
|
};
|
|
1032
1252
|
|
|
1033
|
-
this.
|
|
1253
|
+
this._getPublishQueueAndSaveActor().commitPayload(this._operation, handleFieldsRelayPayload);
|
|
1034
1254
|
}
|
|
1035
1255
|
|
|
1256
|
+
this._actorIdentifier = prevActorIdentifier;
|
|
1036
1257
|
return relayPayload;
|
|
1037
1258
|
};
|
|
1038
1259
|
|
|
@@ -1040,34 +1261,34 @@ var Executor = /*#__PURE__*/function () {
|
|
|
1040
1261
|
var _field$alias, _field$concreteType, _this$_getDataID;
|
|
1041
1262
|
|
|
1042
1263
|
var data = response.data;
|
|
1043
|
-
!(typeof data === 'object') ? process.env.NODE_ENV !== "production" ? invariant(false, '
|
|
1264
|
+
!(typeof data === 'object') ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Expected the GraphQL @stream payload `data` ' + 'value to be an object.') : invariant(false) : void 0;
|
|
1044
1265
|
var responseKey = (_field$alias = field.alias) !== null && _field$alias !== void 0 ? _field$alias : field.name;
|
|
1045
1266
|
var storageKey = getStorageKey(field, variables); // Load the version of the parent record from which this incremental data
|
|
1046
1267
|
// was derived
|
|
1047
1268
|
|
|
1048
1269
|
var parentEntry = this._source.get(parentID);
|
|
1049
1270
|
|
|
1050
|
-
!(parentEntry != null) ? process.env.NODE_ENV !== "production" ? invariant(false, '
|
|
1271
|
+
!(parentEntry != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Expected the parent record `%s` for @stream ' + 'data to exist.', parentID) : invariant(false) : void 0;
|
|
1051
1272
|
var parentRecord = parentEntry.record,
|
|
1052
1273
|
fieldPayloads = parentEntry.fieldPayloads; // Load the field value (items) that were created by *this* query executor
|
|
1053
1274
|
// in order to check if there has been any concurrent modifications by some
|
|
1054
1275
|
// other operation.
|
|
1055
1276
|
|
|
1056
1277
|
var prevIDs = RelayModernRecord.getLinkedRecordIDs(parentRecord, storageKey);
|
|
1057
|
-
!(prevIDs != null) ? process.env.NODE_ENV !== "production" ? invariant(false, '
|
|
1278
|
+
!(prevIDs != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Expected record `%s` to have fetched field ' + '`%s` with @stream.', parentID, field.name) : invariant(false) : void 0; // Determine the index in the field of the new item
|
|
1058
1279
|
|
|
1059
1280
|
var finalPathEntry = path[path.length - 1];
|
|
1060
1281
|
var itemIndex = parseInt(finalPathEntry, 10);
|
|
1061
|
-
!(itemIndex === finalPathEntry && itemIndex >= 0) ? process.env.NODE_ENV !== "production" ? invariant(false, '
|
|
1282
|
+
!(itemIndex === finalPathEntry && itemIndex >= 0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Expected path for @stream to end in a ' + 'positive integer index, got `%s`', finalPathEntry) : invariant(false) : void 0;
|
|
1062
1283
|
var typeName = (_field$concreteType = field.concreteType) !== null && _field$concreteType !== void 0 ? _field$concreteType : data[TYPENAME_KEY];
|
|
1063
|
-
!(typeof typeName === 'string') ? process.env.NODE_ENV !== "production" ? invariant(false, '
|
|
1284
|
+
!(typeof typeName === 'string') ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Expected @stream field `%s` to have a ' + '__typename.', field.name) : invariant(false) : void 0; // Determine the __id of the new item: this must equal the value that would
|
|
1064
1285
|
// be assigned had the item not been streamed
|
|
1065
1286
|
|
|
1066
1287
|
var itemID = // https://github.com/prettier/prettier/issues/6403
|
|
1067
1288
|
// prettier-ignore
|
|
1068
1289
|
((_this$_getDataID = this._getDataID(data, typeName)) !== null && _this$_getDataID !== void 0 ? _this$_getDataID : prevIDs && prevIDs[itemIndex]) || // Reuse previously generated client IDs
|
|
1069
1290
|
generateClientID(parentID, storageKey, itemIndex);
|
|
1070
|
-
!(typeof itemID === 'string') ? process.env.NODE_ENV !== "production" ? invariant(false, '
|
|
1291
|
+
!(typeof itemID === 'string') ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Expected id of elements of field `%s` to ' + 'be strings.', storageKey) : invariant(false) : void 0; // Build a selector to normalize the item data with
|
|
1071
1292
|
|
|
1072
1293
|
var selector = createNormalizationSelector(field, itemID, variables); // Update the cached version of the parent record to reflect the new item:
|
|
1073
1294
|
// this is used when subsequent stream payloads arrive to see if there
|
|
@@ -1084,11 +1305,13 @@ var Executor = /*#__PURE__*/function () {
|
|
|
1084
1305
|
});
|
|
1085
1306
|
|
|
1086
1307
|
var relayPayload = normalizeResponse(response, selector, typeName, {
|
|
1308
|
+
actorIdentifier: this._actorIdentifier,
|
|
1087
1309
|
getDataID: this._getDataID,
|
|
1088
1310
|
path: [].concat((0, _toConsumableArray2["default"])(normalizationPath), [responseKey, String(itemIndex)]),
|
|
1089
|
-
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer,
|
|
1311
|
+
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer != null ? this._deserializeReactFlightPayloadWithLogging : null,
|
|
1090
1312
|
reactFlightServerErrorHandler: this._reactFlightServerErrorHandler,
|
|
1091
|
-
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull
|
|
1313
|
+
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
1314
|
+
shouldProcessClientComponents: this._shouldProcessClientComponents
|
|
1092
1315
|
});
|
|
1093
1316
|
return {
|
|
1094
1317
|
fieldPayloads: fieldPayloads,
|
|
@@ -1100,18 +1323,132 @@ var Executor = /*#__PURE__*/function () {
|
|
|
1100
1323
|
};
|
|
1101
1324
|
};
|
|
1102
1325
|
|
|
1326
|
+
_proto._scheduleAsyncStoreUpdate = function _scheduleAsyncStoreUpdate(scheduleFn, completeFn) {
|
|
1327
|
+
var _this12 = this;
|
|
1328
|
+
|
|
1329
|
+
this._completeFns.push(completeFn);
|
|
1330
|
+
|
|
1331
|
+
if (this._asyncStoreUpdateDisposable != null) {
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
this._asyncStoreUpdateDisposable = scheduleFn(function () {
|
|
1336
|
+
_this12._asyncStoreUpdateDisposable = null;
|
|
1337
|
+
|
|
1338
|
+
var updatedOwners = _this12._runPublishQueue();
|
|
1339
|
+
|
|
1340
|
+
_this12._updateOperationTracker(updatedOwners);
|
|
1341
|
+
|
|
1342
|
+
var _iterator2 = (0, _createForOfIteratorHelper2["default"])(_this12._completeFns),
|
|
1343
|
+
_step2;
|
|
1344
|
+
|
|
1345
|
+
try {
|
|
1346
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1347
|
+
var complete = _step2.value;
|
|
1348
|
+
complete();
|
|
1349
|
+
}
|
|
1350
|
+
} catch (err) {
|
|
1351
|
+
_iterator2.e(err);
|
|
1352
|
+
} finally {
|
|
1353
|
+
_iterator2.f();
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
_this12._completeFns = [];
|
|
1357
|
+
});
|
|
1358
|
+
};
|
|
1359
|
+
|
|
1103
1360
|
_proto._updateOperationTracker = function _updateOperationTracker(updatedOwners) {
|
|
1104
|
-
if (
|
|
1361
|
+
if (updatedOwners != null && updatedOwners.length > 0) {
|
|
1105
1362
|
this._operationTracker.update(this._operation.request, new Set(updatedOwners));
|
|
1106
1363
|
}
|
|
1107
1364
|
};
|
|
1108
1365
|
|
|
1109
1366
|
_proto._completeOperationTracker = function _completeOperationTracker() {
|
|
1110
|
-
|
|
1111
|
-
|
|
1367
|
+
this._operationTracker.complete(this._operation.request);
|
|
1368
|
+
};
|
|
1369
|
+
|
|
1370
|
+
_proto._getPublishQueueAndSaveActor = function _getPublishQueueAndSaveActor() {
|
|
1371
|
+
this._seenActors.add(this._actorIdentifier);
|
|
1372
|
+
|
|
1373
|
+
return this._getPublishQueue(this._actorIdentifier);
|
|
1374
|
+
};
|
|
1375
|
+
|
|
1376
|
+
_proto._getActorsToVisit = function _getActorsToVisit() {
|
|
1377
|
+
if (this._seenActors.size === 0) {
|
|
1378
|
+
return new Set([this._actorIdentifier]);
|
|
1379
|
+
} else {
|
|
1380
|
+
return this._seenActors;
|
|
1112
1381
|
}
|
|
1113
1382
|
};
|
|
1114
1383
|
|
|
1384
|
+
_proto._runPublishQueue = function _runPublishQueue(operation) {
|
|
1385
|
+
var updatedOwners = new Set();
|
|
1386
|
+
|
|
1387
|
+
var _iterator3 = (0, _createForOfIteratorHelper2["default"])(this._getActorsToVisit()),
|
|
1388
|
+
_step3;
|
|
1389
|
+
|
|
1390
|
+
try {
|
|
1391
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
1392
|
+
var _actorIdentifier = _step3.value;
|
|
1393
|
+
|
|
1394
|
+
var owners = this._getPublishQueue(_actorIdentifier).run(operation);
|
|
1395
|
+
|
|
1396
|
+
owners.forEach(function (owner) {
|
|
1397
|
+
return updatedOwners.add(owner);
|
|
1398
|
+
});
|
|
1399
|
+
}
|
|
1400
|
+
} catch (err) {
|
|
1401
|
+
_iterator3.e(err);
|
|
1402
|
+
} finally {
|
|
1403
|
+
_iterator3.f();
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
return Array.from(updatedOwners);
|
|
1407
|
+
};
|
|
1408
|
+
|
|
1409
|
+
_proto._retainData = function _retainData() {
|
|
1410
|
+
var _iterator4 = (0, _createForOfIteratorHelper2["default"])(this._getActorsToVisit()),
|
|
1411
|
+
_step4;
|
|
1412
|
+
|
|
1413
|
+
try {
|
|
1414
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
1415
|
+
var _actorIdentifier2 = _step4.value;
|
|
1416
|
+
|
|
1417
|
+
if (!this._retainDisposables.has(_actorIdentifier2)) {
|
|
1418
|
+
this._retainDisposables.set(_actorIdentifier2, this._getStore(_actorIdentifier2).retain(this._operation));
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
} catch (err) {
|
|
1422
|
+
_iterator4.e(err);
|
|
1423
|
+
} finally {
|
|
1424
|
+
_iterator4.f();
|
|
1425
|
+
}
|
|
1426
|
+
};
|
|
1427
|
+
|
|
1428
|
+
_proto._disposeRetainedData = function _disposeRetainedData() {
|
|
1429
|
+
var _iterator5 = (0, _createForOfIteratorHelper2["default"])(this._retainDisposables.values()),
|
|
1430
|
+
_step5;
|
|
1431
|
+
|
|
1432
|
+
try {
|
|
1433
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
1434
|
+
var disposable = _step5.value;
|
|
1435
|
+
disposable.dispose();
|
|
1436
|
+
}
|
|
1437
|
+
} catch (err) {
|
|
1438
|
+
_iterator5.e(err);
|
|
1439
|
+
} finally {
|
|
1440
|
+
_iterator5.f();
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
this._retainDisposables.clear();
|
|
1444
|
+
};
|
|
1445
|
+
|
|
1446
|
+
_proto._expectOperationLoader = function _expectOperationLoader() {
|
|
1447
|
+
var operationLoader = this._operationLoader;
|
|
1448
|
+
!operationLoader ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Expected an operationLoader to be ' + 'configured when using `@match`.') : invariant(false) : void 0;
|
|
1449
|
+
return operationLoader;
|
|
1450
|
+
};
|
|
1451
|
+
|
|
1115
1452
|
return Executor;
|
|
1116
1453
|
}();
|
|
1117
1454
|
|
|
@@ -1124,7 +1461,7 @@ function partitionGraphQLResponses(responses) {
|
|
|
1124
1461
|
path = response.path;
|
|
1125
1462
|
|
|
1126
1463
|
if (label == null || path == null) {
|
|
1127
|
-
!false ? process.env.NODE_ENV !== "production" ? invariant(false, '
|
|
1464
|
+
!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;
|
|
1128
1465
|
}
|
|
1129
1466
|
|
|
1130
1467
|
incrementalResponses.push({
|
|
@@ -1164,7 +1501,7 @@ function validateOptimisticResponsePayload(payload) {
|
|
|
1164
1501
|
var incrementalPlaceholders = payload.incrementalPlaceholders;
|
|
1165
1502
|
|
|
1166
1503
|
if (incrementalPlaceholders != null && incrementalPlaceholders.length !== 0) {
|
|
1167
|
-
!false ? process.env.NODE_ENV !== "production" ? invariant(false, '
|
|
1504
|
+
!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;
|
|
1168
1505
|
}
|
|
1169
1506
|
}
|
|
1170
1507
|
|