relay-runtime 11.0.1 → 13.0.0-rc.1
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/RelayDefaultHandlerProvider.js.flow +2 -2
- package/handlers/connection/ConnectionHandler.js.flow +8 -17
- package/handlers/connection/MutationHandlers.js.flow +7 -11
- package/index.js +1 -1
- package/index.js.flow +60 -36
- package/lib/handlers/RelayDefaultHandlerProvider.js +1 -1
- package/lib/handlers/connection/ConnectionHandler.js +13 -19
- package/lib/handlers/connection/MutationHandlers.js +4 -7
- package/lib/index.js +58 -43
- package/lib/multi-actor-environment/ActorIdentifier.js +33 -0
- package/lib/multi-actor-environment/ActorSpecificEnvironment.js +152 -0
- package/lib/multi-actor-environment/ActorUtils.js +27 -0
- package/lib/multi-actor-environment/MultiActorEnvironment.js +419 -0
- package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +11 -0
- package/lib/multi-actor-environment/index.js +21 -0
- package/lib/mutations/RelayDeclarativeMutationConfig.js +4 -1
- package/lib/mutations/RelayRecordProxy.js +3 -2
- package/lib/mutations/RelayRecordSourceMutator.js +3 -2
- package/lib/mutations/RelayRecordSourceProxy.js +12 -4
- package/lib/mutations/RelayRecordSourceSelectorProxy.js +18 -5
- package/lib/mutations/applyOptimisticMutation.js +6 -6
- package/lib/mutations/commitMutation.js +14 -10
- package/lib/mutations/readUpdatableQuery_EXPERIMENTAL.js +238 -0
- package/lib/mutations/validateMutation.js +10 -5
- package/lib/network/ConvertToExecuteFunction.js +2 -1
- package/lib/network/RelayNetwork.js +3 -2
- package/lib/network/RelayQueryResponseCache.js +21 -5
- package/lib/network/wrapNetworkWithLogObserver.js +79 -0
- package/lib/query/GraphQLTag.js +3 -2
- package/lib/query/fetchQuery.js +6 -5
- package/lib/query/fetchQueryInternal.js +1 -1
- package/lib/query/fetchQuery_DEPRECATED.js +2 -1
- package/lib/store/ClientID.js +7 -1
- package/lib/store/DataChecker.js +123 -54
- package/lib/store/{RelayModernQueryExecutor.js → OperationExecutor.js} +518 -200
- package/lib/store/RelayConcreteVariables.js +26 -8
- package/lib/store/RelayExperimentalGraphResponseHandler.js +153 -0
- package/lib/store/RelayExperimentalGraphResponseTransform.js +391 -0
- package/lib/store/RelayModernEnvironment.js +175 -240
- package/lib/store/RelayModernFragmentSpecResolver.js +52 -26
- package/lib/store/RelayModernOperationDescriptor.js +2 -1
- package/lib/store/RelayModernRecord.js +47 -12
- package/lib/store/RelayModernSelector.js +14 -8
- package/lib/store/RelayModernStore.js +56 -28
- package/lib/store/RelayOperationTracker.js +34 -24
- package/lib/store/RelayPublishQueue.js +41 -13
- package/lib/store/RelayReader.js +288 -48
- package/lib/store/RelayRecordSource.js +87 -3
- package/lib/store/RelayReferenceMarker.js +34 -22
- package/lib/store/RelayResponseNormalizer.js +211 -110
- package/lib/store/RelayStoreReactFlightUtils.js +4 -10
- package/lib/store/RelayStoreSubscriptions.js +14 -9
- package/lib/store/RelayStoreUtils.js +12 -7
- package/lib/store/ResolverCache.js +213 -0
- package/lib/store/ResolverFragments.js +61 -0
- package/lib/store/cloneRelayHandleSourceField.js +5 -4
- package/lib/store/cloneRelayScalarHandleSourceField.js +5 -4
- package/lib/store/createRelayContext.js +4 -2
- package/lib/store/readInlineData.js +6 -2
- package/lib/subscription/requestSubscription.js +34 -25
- package/lib/util/RelayConcreteNode.js +3 -0
- package/lib/util/RelayFeatureFlags.js +10 -4
- package/lib/util/RelayProfiler.js +17 -187
- package/lib/util/RelayReplaySubject.js +22 -7
- package/lib/util/RelayRuntimeTypes.js +0 -6
- package/lib/util/StringInterner.js +71 -0
- package/lib/util/getFragmentIdentifier.js +15 -7
- package/lib/util/getOperation.js +2 -1
- package/lib/util/getPaginationMetadata.js +41 -0
- package/lib/util/getPaginationVariables.js +66 -0
- package/lib/util/getPendingOperationsForFragment.js +55 -0
- package/lib/util/getRefetchMetadata.js +36 -0
- package/lib/util/getRelayHandleKey.js +2 -2
- package/lib/util/getRequestIdentifier.js +2 -2
- 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 +225 -0
- package/multi-actor-environment/ActorUtils.js.flow +33 -0
- package/multi-actor-environment/MultiActorEnvironment.js.flow +506 -0
- package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +261 -0
- package/multi-actor-environment/index.js.flow +26 -0
- package/mutations/RelayDeclarativeMutationConfig.js.flow +32 -26
- package/mutations/RelayRecordProxy.js.flow +4 -5
- package/mutations/RelayRecordSourceMutator.js.flow +4 -6
- package/mutations/RelayRecordSourceProxy.js.flow +19 -10
- package/mutations/RelayRecordSourceSelectorProxy.js.flow +22 -7
- package/mutations/applyOptimisticMutation.js.flow +13 -14
- package/mutations/commitLocalUpdate.js.flow +1 -1
- package/mutations/commitMutation.js.flow +35 -46
- package/mutations/readUpdatableQuery_EXPERIMENTAL.js.flow +309 -0
- package/mutations/validateMutation.js.flow +26 -16
- package/network/ConvertToExecuteFunction.js.flow +2 -2
- package/network/RelayNetwork.js.flow +4 -5
- package/network/RelayNetworkTypes.js.flow +5 -4
- package/network/RelayObservable.js.flow +1 -1
- package/network/RelayQueryResponseCache.js.flow +34 -21
- package/network/wrapNetworkWithLogObserver.js.flow +100 -0
- package/package.json +3 -2
- package/query/GraphQLTag.js.flow +9 -9
- package/query/PreloadableQueryRegistry.js.flow +2 -1
- package/query/fetchQuery.js.flow +11 -13
- package/query/fetchQueryInternal.js.flow +6 -9
- package/query/fetchQuery_DEPRECATED.js.flow +6 -6
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/ClientID.js.flow +14 -3
- package/store/DataChecker.js.flow +141 -59
- package/store/{RelayModernQueryExecutor.js.flow → OperationExecutor.js.flow} +605 -303
- package/store/RelayConcreteVariables.js.flow +27 -8
- package/store/RelayExperimentalGraphResponseHandler.js.flow +124 -0
- package/store/RelayExperimentalGraphResponseTransform.js.flow +475 -0
- package/store/RelayModernEnvironment.js.flow +173 -240
- package/store/RelayModernFragmentSpecResolver.js.flow +55 -31
- package/store/RelayModernOperationDescriptor.js.flow +12 -7
- package/store/RelayModernRecord.js.flow +67 -11
- package/store/RelayModernSelector.js.flow +24 -14
- package/store/RelayModernStore.js.flow +66 -36
- package/store/RelayOperationTracker.js.flow +59 -43
- package/store/RelayOptimisticRecordSource.js.flow +2 -2
- package/store/RelayPublishQueue.js.flow +79 -34
- package/store/RelayReader.js.flow +351 -73
- package/store/RelayRecordSource.js.flow +72 -6
- package/store/RelayReferenceMarker.js.flow +40 -26
- package/store/RelayResponseNormalizer.js.flow +258 -99
- package/store/RelayStoreReactFlightUtils.js.flow +4 -11
- package/store/RelayStoreSubscriptions.js.flow +19 -11
- package/store/RelayStoreTypes.js.flow +209 -43
- package/store/RelayStoreUtils.js.flow +24 -11
- package/store/ResolverCache.js.flow +249 -0
- package/store/ResolverFragments.js.flow +121 -0
- package/store/StoreInspector.js.flow +2 -2
- package/store/TypeID.js.flow +1 -1
- package/store/ViewerPattern.js.flow +2 -2
- package/store/cloneRelayHandleSourceField.js.flow +5 -6
- package/store/cloneRelayScalarHandleSourceField.js.flow +5 -6
- package/store/createFragmentSpecResolver.js.flow +3 -4
- package/store/createRelayContext.js.flow +3 -3
- package/store/normalizeRelayPayload.js.flow +6 -7
- package/store/readInlineData.js.flow +7 -8
- package/subscription/requestSubscription.js.flow +53 -41
- package/util/NormalizationNode.js.flow +10 -3
- package/util/ReaderNode.js.flow +38 -2
- package/util/RelayConcreteNode.js.flow +5 -0
- package/util/RelayFeatureFlags.js.flow +24 -10
- package/util/RelayProfiler.js.flow +22 -194
- package/util/RelayReplaySubject.js.flow +9 -9
- package/util/RelayRuntimeTypes.js.flow +72 -3
- package/util/StringInterner.js.flow +69 -0
- package/util/createPayloadFor3DField.js.flow +3 -3
- package/util/getFragmentIdentifier.js.flow +27 -15
- package/util/getOperation.js.flow +2 -2
- package/util/getPaginationMetadata.js.flow +72 -0
- package/util/getPaginationVariables.js.flow +108 -0
- package/util/getPendingOperationsForFragment.js.flow +62 -0
- package/util/getRefetchMetadata.js.flow +79 -0
- package/util/getRelayHandleKey.js.flow +1 -2
- package/util/getRequestIdentifier.js.flow +3 -3
- package/util/getValueAtPath.js.flow +46 -0
- package/util/isEmptyObject.js.flow +1 -0
- package/util/registerEnvironmentWithDevTools.js.flow +33 -0
- package/util/resolveImmediate.js.flow +1 -1
- 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,40 +17,49 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
|
|
|
17
17
|
|
|
18
18
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
19
19
|
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
var RelayError = require('../util/RelayError');
|
|
20
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
21
|
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
var RelayModernRecord = require('./RelayModernRecord');
|
|
22
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
27
23
|
|
|
28
24
|
var RelayObservable = require('../network/RelayObservable');
|
|
29
25
|
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
var RelayResponseNormalizer = require('./RelayResponseNormalizer');
|
|
26
|
+
var generateID = require('../util/generateID');
|
|
33
27
|
|
|
34
28
|
var getOperation = require('../util/getOperation');
|
|
35
29
|
|
|
36
|
-
var
|
|
30
|
+
var RelayError = require('../util/RelayError');
|
|
31
|
+
|
|
32
|
+
var RelayFeatureFlags = require('../util/RelayFeatureFlags');
|
|
37
33
|
|
|
38
34
|
var stableCopy = require('../util/stableCopy');
|
|
39
35
|
|
|
40
|
-
var
|
|
36
|
+
var withDuration = require('../util/withDuration');
|
|
41
37
|
|
|
42
38
|
var _require = require('./ClientID'),
|
|
43
39
|
generateClientID = _require.generateClientID,
|
|
44
40
|
generateUniqueClientID = _require.generateUniqueClientID;
|
|
45
41
|
|
|
46
|
-
var _require2 = require('./
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
var _require2 = require('./RelayConcreteVariables'),
|
|
43
|
+
getLocalVariables = _require2.getLocalVariables;
|
|
44
|
+
|
|
45
|
+
var RelayModernRecord = require('./RelayModernRecord');
|
|
46
|
+
|
|
47
|
+
var _require3 = require('./RelayModernSelector'),
|
|
48
|
+
createNormalizationSelector = _require3.createNormalizationSelector,
|
|
49
|
+
createReaderSelector = _require3.createReaderSelector;
|
|
50
|
+
|
|
51
|
+
var RelayRecordSource = require('./RelayRecordSource');
|
|
52
|
+
|
|
53
|
+
var RelayResponseNormalizer = require('./RelayResponseNormalizer');
|
|
54
|
+
|
|
55
|
+
var _require4 = require('./RelayStoreUtils'),
|
|
56
|
+
ROOT_TYPE = _require4.ROOT_TYPE,
|
|
57
|
+
TYPENAME_KEY = _require4.TYPENAME_KEY,
|
|
58
|
+
getStorageKey = _require4.getStorageKey;
|
|
49
59
|
|
|
50
|
-
var
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
getStorageKey = _require3.getStorageKey;
|
|
60
|
+
var invariant = require('invariant');
|
|
61
|
+
|
|
62
|
+
var warning = require("fbjs/lib/warning");
|
|
54
63
|
|
|
55
64
|
function execute(config) {
|
|
56
65
|
return new Executor(config);
|
|
@@ -66,27 +75,51 @@ var Executor = /*#__PURE__*/function () {
|
|
|
66
75
|
function Executor(_ref) {
|
|
67
76
|
var _this = this;
|
|
68
77
|
|
|
69
|
-
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,
|
|
70
84
|
operationExecutions = _ref.operationExecutions,
|
|
71
85
|
operationLoader = _ref.operationLoader,
|
|
86
|
+
operationTracker = _ref.operationTracker,
|
|
72
87
|
optimisticConfig = _ref.optimisticConfig,
|
|
73
|
-
|
|
88
|
+
_reactFlightPayloadDeserializer = _ref.reactFlightPayloadDeserializer,
|
|
89
|
+
reactFlightServerErrorHandler = _ref.reactFlightServerErrorHandler,
|
|
74
90
|
scheduler = _ref.scheduler,
|
|
91
|
+
shouldProcessClientComponents = _ref.shouldProcessClientComponents,
|
|
75
92
|
sink = _ref.sink,
|
|
76
93
|
source = _ref.source,
|
|
77
|
-
store = _ref.store,
|
|
78
|
-
updater = _ref.updater,
|
|
79
|
-
operationTracker = _ref.operationTracker,
|
|
80
94
|
treatMissingFieldsAsNull = _ref.treatMissingFieldsAsNull,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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;
|
|
86
117
|
this._getDataID = getDataID;
|
|
87
118
|
this._treatMissingFieldsAsNull = treatMissingFieldsAsNull;
|
|
88
119
|
this._incrementalPayloadsPending = false;
|
|
89
120
|
this._incrementalResults = new Map();
|
|
121
|
+
this._log = log;
|
|
122
|
+
this._executeId = generateID();
|
|
90
123
|
this._nextSubscriptionId = 0;
|
|
91
124
|
this._operation = operation;
|
|
92
125
|
this._operationExecutions = operationExecutions;
|
|
@@ -95,19 +128,22 @@ var Executor = /*#__PURE__*/function () {
|
|
|
95
128
|
this._operationUpdateEpochs = new Map();
|
|
96
129
|
this._optimisticUpdates = null;
|
|
97
130
|
this._pendingModulePayloadsCount = 0;
|
|
98
|
-
this.
|
|
131
|
+
this._getPublishQueue = getPublishQueue;
|
|
99
132
|
this._scheduler = scheduler;
|
|
100
133
|
this._sink = sink;
|
|
101
134
|
this._source = new Map();
|
|
102
135
|
this._state = 'started';
|
|
103
|
-
this.
|
|
136
|
+
this._getStore = getStore;
|
|
104
137
|
this._subscriptions = new Map();
|
|
105
138
|
this._updater = updater;
|
|
106
139
|
this._isClientPayload = isClientPayload === true;
|
|
107
|
-
this._reactFlightPayloadDeserializer =
|
|
140
|
+
this._reactFlightPayloadDeserializer = _reactFlightPayloadDeserializer;
|
|
108
141
|
this._reactFlightServerErrorHandler = reactFlightServerErrorHandler;
|
|
109
142
|
this._isSubscriptionOperation = this._operation.request.node.params.operationKind === 'subscription';
|
|
110
143
|
this._shouldProcessClientComponents = shouldProcessClientComponents;
|
|
144
|
+
this._retainDisposables = new Map();
|
|
145
|
+
this._seenActors = new Set();
|
|
146
|
+
this._completeFns = [];
|
|
111
147
|
var id = this._nextSubscriptionId++;
|
|
112
148
|
source.subscribe({
|
|
113
149
|
complete: function complete() {
|
|
@@ -124,7 +160,17 @@ var Executor = /*#__PURE__*/function () {
|
|
|
124
160
|
}
|
|
125
161
|
},
|
|
126
162
|
start: function start(subscription) {
|
|
127
|
-
|
|
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
|
+
});
|
|
128
174
|
}
|
|
129
175
|
});
|
|
130
176
|
|
|
@@ -162,21 +208,25 @@ var Executor = /*#__PURE__*/function () {
|
|
|
162
208
|
if (optimisticUpdates !== null) {
|
|
163
209
|
this._optimisticUpdates = null;
|
|
164
210
|
optimisticUpdates.forEach(function (update) {
|
|
165
|
-
return _this2.
|
|
166
|
-
});
|
|
211
|
+
return _this2._getPublishQueueAndSaveActor().revertUpdate(update);
|
|
212
|
+
}); // OK: run revert on cancel
|
|
167
213
|
|
|
168
|
-
this.
|
|
214
|
+
this._runPublishQueue();
|
|
169
215
|
}
|
|
170
216
|
|
|
171
217
|
this._incrementalResults.clear();
|
|
172
218
|
|
|
173
|
-
this.
|
|
219
|
+
if (this._asyncStoreUpdateDisposable != null) {
|
|
220
|
+
this._asyncStoreUpdateDisposable.dispose();
|
|
174
221
|
|
|
175
|
-
|
|
176
|
-
this._retainDisposable.dispose();
|
|
177
|
-
|
|
178
|
-
this._retainDisposable = null;
|
|
222
|
+
this._asyncStoreUpdateDisposable = null;
|
|
179
223
|
}
|
|
224
|
+
|
|
225
|
+
this._completeFns = [];
|
|
226
|
+
|
|
227
|
+
this._completeOperationTracker();
|
|
228
|
+
|
|
229
|
+
this._disposeRetainedData();
|
|
180
230
|
};
|
|
181
231
|
|
|
182
232
|
_proto._updateActiveState = function _updateActiveState() {
|
|
@@ -209,7 +259,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
209
259
|
|
|
210
260
|
default:
|
|
211
261
|
this._state;
|
|
212
|
-
!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;
|
|
213
263
|
}
|
|
214
264
|
|
|
215
265
|
this._operationExecutions.set(this._operation.request.identifier, activeState);
|
|
@@ -258,6 +308,11 @@ var Executor = /*#__PURE__*/function () {
|
|
|
258
308
|
this.cancel();
|
|
259
309
|
|
|
260
310
|
this._sink.complete();
|
|
311
|
+
|
|
312
|
+
this._log({
|
|
313
|
+
name: 'execute.complete',
|
|
314
|
+
executeId: this._executeId
|
|
315
|
+
});
|
|
261
316
|
}
|
|
262
317
|
};
|
|
263
318
|
|
|
@@ -265,6 +320,12 @@ var Executor = /*#__PURE__*/function () {
|
|
|
265
320
|
this.cancel();
|
|
266
321
|
|
|
267
322
|
this._sink.error(error);
|
|
323
|
+
|
|
324
|
+
this._log({
|
|
325
|
+
name: 'execute.error',
|
|
326
|
+
executeId: this._executeId,
|
|
327
|
+
error: error
|
|
328
|
+
});
|
|
268
329
|
};
|
|
269
330
|
|
|
270
331
|
_proto._start = function _start(id, subscription) {
|
|
@@ -278,9 +339,19 @@ var Executor = /*#__PURE__*/function () {
|
|
|
278
339
|
var _this4 = this;
|
|
279
340
|
|
|
280
341
|
this._schedule(function () {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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
|
+
});
|
|
284
355
|
});
|
|
285
356
|
};
|
|
286
357
|
|
|
@@ -332,7 +403,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
332
403
|
|
|
333
404
|
return ((_responsePart$extensi = responsePart.extensions) === null || _responsePart$extensi === void 0 ? void 0 : _responsePart$extensi.isOptimistic) === true;
|
|
334
405
|
})) {
|
|
335
|
-
!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;
|
|
336
407
|
}
|
|
337
408
|
|
|
338
409
|
return false;
|
|
@@ -342,7 +413,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
342
413
|
var isOptimistic = ((_response$extensions = response.extensions) === null || _response$extensions === void 0 ? void 0 : _response$extensions.isOptimistic) === true;
|
|
343
414
|
|
|
344
415
|
if (isOptimistic && this._state !== 'started') {
|
|
345
|
-
!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;
|
|
346
417
|
}
|
|
347
418
|
|
|
348
419
|
if (isOptimistic) {
|
|
@@ -361,6 +432,8 @@ var Executor = /*#__PURE__*/function () {
|
|
|
361
432
|
return;
|
|
362
433
|
}
|
|
363
434
|
|
|
435
|
+
this._seenActors.clear();
|
|
436
|
+
|
|
364
437
|
var responses = Array.isArray(response) ? response : [response];
|
|
365
438
|
|
|
366
439
|
var responsesWithData = this._handleErrorResponse(responses);
|
|
@@ -396,7 +469,9 @@ var Executor = /*#__PURE__*/function () {
|
|
|
396
469
|
|
|
397
470
|
var _partitionGraphQLResp = partitionGraphQLResponses(responsesWithData),
|
|
398
471
|
nonIncrementalResponses = _partitionGraphQLResp[0],
|
|
399
|
-
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.
|
|
400
475
|
// The idea is that a batch is always:
|
|
401
476
|
// * at most one non-incremental payload
|
|
402
477
|
// * followed by zero or more incremental payloads
|
|
@@ -404,44 +479,64 @@ var Executor = /*#__PURE__*/function () {
|
|
|
404
479
|
// with the initial payload followed by some early-to-resolve incremental
|
|
405
480
|
// payloads (although, can that even happen?)
|
|
406
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
|
+
}
|
|
407
494
|
|
|
408
|
-
|
|
409
|
-
var payloadFollowups = this._processResponses(nonIncrementalResponses); // Please note that we're passing `this._operation` to the publish
|
|
410
|
-
// queue here, which will later passed to the store (via notify)
|
|
411
|
-
// to indicate that this is an operation that caused the store to update
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
var updatedOwners = this._publishQueue.run(this._operation);
|
|
415
|
-
|
|
416
|
-
this._updateOperationTracker(updatedOwners);
|
|
495
|
+
var payloadFollowups = this._processResponses(nonIncrementalResponses);
|
|
417
496
|
|
|
418
497
|
this._processPayloadFollowups(payloadFollowups);
|
|
419
|
-
|
|
420
|
-
if (this._incrementalPayloadsPending && !this._retainDisposable) {
|
|
421
|
-
this._retainDisposable = this._store.retain(this._operation);
|
|
422
|
-
}
|
|
423
498
|
}
|
|
424
499
|
|
|
425
500
|
if (incrementalResponses.length > 0) {
|
|
426
|
-
var _payloadFollowups = this._processIncrementalResponses(incrementalResponses);
|
|
427
|
-
// for already initiated operation (and we're not passing it to
|
|
428
|
-
// the run(...) call)
|
|
501
|
+
var _payloadFollowups = this._processIncrementalResponses(incrementalResponses);
|
|
429
502
|
|
|
503
|
+
this._processPayloadFollowups(_payloadFollowups);
|
|
504
|
+
}
|
|
430
505
|
|
|
431
|
-
|
|
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
|
|
432
521
|
|
|
433
|
-
this._updateOperationTracker(_updatedOwners);
|
|
434
522
|
|
|
435
|
-
|
|
523
|
+
var updatedOwners = this._runPublishQueue(hasNonIncrementalResponses ? this._operation : undefined);
|
|
524
|
+
|
|
525
|
+
if (hasNonIncrementalResponses) {
|
|
526
|
+
if (this._incrementalPayloadsPending) {
|
|
527
|
+
this._retainData();
|
|
528
|
+
}
|
|
436
529
|
}
|
|
437
530
|
|
|
531
|
+
this._updateOperationTracker(updatedOwners);
|
|
532
|
+
|
|
438
533
|
this._sink.next(response);
|
|
439
534
|
};
|
|
440
535
|
|
|
441
536
|
_proto._processOptimisticResponse = function _processOptimisticResponse(response, updater, treatMissingFieldsAsNull) {
|
|
442
537
|
var _this6 = this;
|
|
443
538
|
|
|
444
|
-
!(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;
|
|
445
540
|
|
|
446
541
|
if (response == null && updater == null) {
|
|
447
542
|
return;
|
|
@@ -451,9 +546,10 @@ var Executor = /*#__PURE__*/function () {
|
|
|
451
546
|
|
|
452
547
|
if (response) {
|
|
453
548
|
var payload = normalizeResponse(response, this._operation.root, ROOT_TYPE, {
|
|
549
|
+
actorIdentifier: this._actorIdentifier,
|
|
454
550
|
getDataID: this._getDataID,
|
|
455
551
|
path: [],
|
|
456
|
-
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer,
|
|
552
|
+
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer != null ? this._deserializeReactFlightPayloadWithLogging : null,
|
|
457
553
|
reactFlightServerErrorHandler: this._reactFlightServerErrorHandler,
|
|
458
554
|
shouldProcessClientComponents: this._shouldProcessClientComponents,
|
|
459
555
|
treatMissingFieldsAsNull: treatMissingFieldsAsNull
|
|
@@ -473,7 +569,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
473
569
|
errors: null,
|
|
474
570
|
fieldPayloads: null,
|
|
475
571
|
incrementalPlaceholders: null,
|
|
476
|
-
|
|
572
|
+
followupPayloads: null,
|
|
477
573
|
source: RelayRecordSource.create(),
|
|
478
574
|
isFinal: false
|
|
479
575
|
},
|
|
@@ -483,32 +579,47 @@ var Executor = /*#__PURE__*/function () {
|
|
|
483
579
|
|
|
484
580
|
this._optimisticUpdates = optimisticUpdates;
|
|
485
581
|
optimisticUpdates.forEach(function (update) {
|
|
486
|
-
return _this6.
|
|
487
|
-
});
|
|
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
|
|
488
585
|
|
|
489
|
-
this.
|
|
586
|
+
this._runPublishQueue();
|
|
490
587
|
};
|
|
491
588
|
|
|
492
589
|
_proto._processOptimisticFollowups = function _processOptimisticFollowups(payload, optimisticUpdates) {
|
|
493
|
-
if (payload.
|
|
494
|
-
var
|
|
495
|
-
var operationLoader = this._operationLoader;
|
|
496
|
-
!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;
|
|
497
592
|
|
|
498
|
-
var _iterator = (0, _createForOfIteratorHelper2["default"])(
|
|
593
|
+
var _iterator = (0, _createForOfIteratorHelper2["default"])(followupPayloads),
|
|
499
594
|
_step;
|
|
500
595
|
|
|
501
596
|
try {
|
|
502
597
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
503
|
-
var
|
|
504
|
-
|
|
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
|
+
}
|
|
505
613
|
|
|
506
|
-
|
|
507
|
-
this._processAsyncOptimisticModuleImport(operationLoader, moduleImportPayload);
|
|
508
|
-
} else {
|
|
509
|
-
var moduleImportOptimisticUpdates = this._processOptimisticModuleImport(operation, moduleImportPayload);
|
|
614
|
+
break;
|
|
510
615
|
|
|
511
|
-
|
|
616
|
+
case 'ActorPayload':
|
|
617
|
+
process.env.NODE_ENV !== "production" ? warning(false, 'OperationExecutor: Unexpected optimistic ActorPayload. These updates are not supported.') : void 0;
|
|
618
|
+
break;
|
|
619
|
+
|
|
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;
|
|
512
623
|
}
|
|
513
624
|
}
|
|
514
625
|
} catch (err) {
|
|
@@ -517,16 +628,29 @@ var Executor = /*#__PURE__*/function () {
|
|
|
517
628
|
_iterator.f();
|
|
518
629
|
}
|
|
519
630
|
}
|
|
520
|
-
}
|
|
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
|
+
}
|
|
521
645
|
|
|
522
|
-
|
|
523
|
-
var selector = createNormalizationSelector(operation, moduleImportPayload.dataID, moduleImportPayload.variables);
|
|
646
|
+
var selector = createNormalizationSelector(normalizationNode, followupPayload.dataID, variables);
|
|
524
647
|
return normalizeResponse({
|
|
525
|
-
data:
|
|
526
|
-
}, selector,
|
|
648
|
+
data: followupPayload.data
|
|
649
|
+
}, selector, followupPayload.typeName, {
|
|
650
|
+
actorIdentifier: this._actorIdentifier,
|
|
527
651
|
getDataID: this._getDataID,
|
|
528
|
-
path:
|
|
529
|
-
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer,
|
|
652
|
+
path: followupPayload.path,
|
|
653
|
+
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer != null ? this._deserializeReactFlightPayloadWithLogging : null,
|
|
530
654
|
reactFlightServerErrorHandler: this._reactFlightServerErrorHandler,
|
|
531
655
|
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
532
656
|
shouldProcessClientComponents: this._shouldProcessClientComponents
|
|
@@ -537,7 +661,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
537
661
|
var operation = getOperation(normalizationRootNode);
|
|
538
662
|
var optimisticUpdates = [];
|
|
539
663
|
|
|
540
|
-
var modulePayload = this.
|
|
664
|
+
var modulePayload = this._normalizeFollowupPayload(moduleImportPayload, operation);
|
|
541
665
|
|
|
542
666
|
validateOptimisticResponsePayload(modulePayload);
|
|
543
667
|
optimisticUpdates.push({
|
|
@@ -551,10 +675,10 @@ var Executor = /*#__PURE__*/function () {
|
|
|
551
675
|
return optimisticUpdates;
|
|
552
676
|
};
|
|
553
677
|
|
|
554
|
-
_proto._processAsyncOptimisticModuleImport = function _processAsyncOptimisticModuleImport(
|
|
678
|
+
_proto._processAsyncOptimisticModuleImport = function _processAsyncOptimisticModuleImport(moduleImportPayload) {
|
|
555
679
|
var _this7 = this;
|
|
556
680
|
|
|
557
|
-
|
|
681
|
+
this._expectOperationLoader().load(moduleImportPayload.operationReference).then(function (operation) {
|
|
558
682
|
if (operation == null || _this7._state !== 'started') {
|
|
559
683
|
return;
|
|
560
684
|
}
|
|
@@ -562,17 +686,18 @@ var Executor = /*#__PURE__*/function () {
|
|
|
562
686
|
var moduleImportOptimisticUpdates = _this7._processOptimisticModuleImport(operation, moduleImportPayload);
|
|
563
687
|
|
|
564
688
|
moduleImportOptimisticUpdates.forEach(function (update) {
|
|
565
|
-
return _this7.
|
|
689
|
+
return _this7._getPublishQueueAndSaveActor().applyUpdate(update);
|
|
566
690
|
});
|
|
567
691
|
|
|
568
692
|
if (_this7._optimisticUpdates == null) {
|
|
569
|
-
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;
|
|
570
694
|
} else {
|
|
571
695
|
var _this$_optimisticUpda;
|
|
572
696
|
|
|
573
|
-
(_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
|
|
574
698
|
|
|
575
|
-
|
|
699
|
+
|
|
700
|
+
_this7._runPublishQueue();
|
|
576
701
|
}
|
|
577
702
|
});
|
|
578
703
|
};
|
|
@@ -582,7 +707,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
582
707
|
|
|
583
708
|
if (this._optimisticUpdates !== null) {
|
|
584
709
|
this._optimisticUpdates.forEach(function (update) {
|
|
585
|
-
|
|
710
|
+
_this8._getPublishQueueAndSaveActor().revertUpdate(update);
|
|
586
711
|
});
|
|
587
712
|
|
|
588
713
|
this._optimisticUpdates = null;
|
|
@@ -596,15 +721,16 @@ var Executor = /*#__PURE__*/function () {
|
|
|
596
721
|
|
|
597
722
|
return responses.map(function (payloadPart) {
|
|
598
723
|
var relayPayload = normalizeResponse(payloadPart, _this8._operation.root, ROOT_TYPE, {
|
|
724
|
+
actorIdentifier: _this8._actorIdentifier,
|
|
599
725
|
getDataID: _this8._getDataID,
|
|
600
726
|
path: [],
|
|
601
|
-
reactFlightPayloadDeserializer: _this8._reactFlightPayloadDeserializer,
|
|
727
|
+
reactFlightPayloadDeserializer: _this8._reactFlightPayloadDeserializer != null ? _this8._deserializeReactFlightPayloadWithLogging : null,
|
|
602
728
|
reactFlightServerErrorHandler: _this8._reactFlightServerErrorHandler,
|
|
603
729
|
treatMissingFieldsAsNull: _this8._treatMissingFieldsAsNull,
|
|
604
730
|
shouldProcessClientComponents: _this8._shouldProcessClientComponents
|
|
605
731
|
});
|
|
606
732
|
|
|
607
|
-
_this8.
|
|
733
|
+
_this8._getPublishQueueAndSaveActor().commitPayload(_this8._operation, relayPayload, _this8._updater);
|
|
608
734
|
|
|
609
735
|
return relayPayload;
|
|
610
736
|
});
|
|
@@ -624,7 +750,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
624
750
|
|
|
625
751
|
payloads.forEach(function (payload) {
|
|
626
752
|
var incrementalPlaceholders = payload.incrementalPlaceholders,
|
|
627
|
-
|
|
753
|
+
followupPayloads = payload.followupPayloads,
|
|
628
754
|
isFinal = payload.isFinal;
|
|
629
755
|
_this9._state = isFinal ? 'loading_final' : 'loading_incremental';
|
|
630
756
|
|
|
@@ -634,18 +760,30 @@ var Executor = /*#__PURE__*/function () {
|
|
|
634
760
|
_this9._incrementalPayloadsPending = false;
|
|
635
761
|
}
|
|
636
762
|
|
|
637
|
-
if (
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
_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;
|
|
642
773
|
});
|
|
643
774
|
}
|
|
644
775
|
|
|
645
776
|
if (incrementalPlaceholders && incrementalPlaceholders.length !== 0) {
|
|
646
777
|
_this9._incrementalPayloadsPending = _this9._state !== 'loading_final';
|
|
647
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
|
+
|
|
648
784
|
_this9._processIncrementalPlaceholder(payload, incrementalPlaceholder);
|
|
785
|
+
|
|
786
|
+
_this9._actorIdentifier = prevActorIdentifier;
|
|
649
787
|
});
|
|
650
788
|
|
|
651
789
|
if (_this9._isClientPayload || _this9._state === 'loading_final') {
|
|
@@ -667,10 +805,6 @@ var Executor = /*#__PURE__*/function () {
|
|
|
667
805
|
});
|
|
668
806
|
|
|
669
807
|
if (relayPayloads.length > 0) {
|
|
670
|
-
var updatedOwners = _this9._publishQueue.run();
|
|
671
|
-
|
|
672
|
-
_this9._updateOperationTracker(updatedOwners);
|
|
673
|
-
|
|
674
808
|
_this9._processPayloadFollowups(relayPayloads);
|
|
675
809
|
}
|
|
676
810
|
}
|
|
@@ -686,15 +820,6 @@ var Executor = /*#__PURE__*/function () {
|
|
|
686
820
|
if (this._pendingModulePayloadsCount === 0 && this._incrementalPayloadsPending === false) {
|
|
687
821
|
this._completeOperationTracker();
|
|
688
822
|
}
|
|
689
|
-
|
|
690
|
-
if (RelayFeatureFlags.ENABLE_UNIQUE_SUBSCRIPTION_ROOT) {
|
|
691
|
-
var nextID = generateUniqueClientID();
|
|
692
|
-
this._operation = {
|
|
693
|
-
request: this._operation.request,
|
|
694
|
-
fragment: createReaderSelector(this._operation.fragment.node, nextID, this._operation.fragment.variables, this._operation.fragment.owner),
|
|
695
|
-
root: createNormalizationSelector(this._operation.root.node, nextID, this._operation.root.variables)
|
|
696
|
-
};
|
|
697
|
-
}
|
|
698
823
|
}
|
|
699
824
|
/**
|
|
700
825
|
* Processes a ModuleImportPayload, asynchronously resolving the normalization
|
|
@@ -705,68 +830,140 @@ var Executor = /*#__PURE__*/function () {
|
|
|
705
830
|
*/
|
|
706
831
|
;
|
|
707
832
|
|
|
708
|
-
_proto.
|
|
833
|
+
_proto._processFollowupPayload = function _processFollowupPayload(followupPayload) {
|
|
709
834
|
var _this10 = this;
|
|
710
835
|
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
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
|
+
}
|
|
742
941
|
});
|
|
743
942
|
}
|
|
744
|
-
}).subscribe({
|
|
745
|
-
complete: function complete() {
|
|
746
|
-
_this10._complete(_id3);
|
|
747
943
|
|
|
748
|
-
|
|
749
|
-
},
|
|
750
|
-
error: function error(_error4) {
|
|
751
|
-
_this10._error(_error4);
|
|
944
|
+
break;
|
|
752
945
|
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
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;
|
|
759
954
|
}
|
|
760
955
|
};
|
|
761
956
|
|
|
762
|
-
_proto.
|
|
763
|
-
|
|
957
|
+
_proto._processFollowupPayloadWithNormalizationNode = function _processFollowupPayloadWithNormalizationNode(followupPayload, normalizationNode) {
|
|
958
|
+
this._handleFollowupPayload(followupPayload, normalizationNode);
|
|
764
959
|
|
|
765
|
-
this.
|
|
960
|
+
this._maybeCompleteSubscriptionOperationTracking();
|
|
961
|
+
};
|
|
766
962
|
|
|
767
|
-
|
|
963
|
+
_proto._handleFollowupPayload = function _handleFollowupPayload(followupPayload, normalizationNode) {
|
|
964
|
+
var relayPayload = this._normalizeFollowupPayload(followupPayload, normalizationNode);
|
|
768
965
|
|
|
769
|
-
this.
|
|
966
|
+
this._getPublishQueueAndSaveActor().commitPayload(this._operation, relayPayload);
|
|
770
967
|
|
|
771
968
|
this._processPayloadFollowups([relayPayload]);
|
|
772
969
|
}
|
|
@@ -816,7 +1013,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
816
1013
|
parentID = placeholder.selector.dataID;
|
|
817
1014
|
} else {
|
|
818
1015
|
placeholder;
|
|
819
|
-
!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;
|
|
820
1017
|
}
|
|
821
1018
|
|
|
822
1019
|
var parentRecord = relayPayload.source.get(parentID);
|
|
@@ -830,7 +1027,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
830
1027
|
}); // If an incremental payload exists for some id that record should also
|
|
831
1028
|
// exist.
|
|
832
1029
|
|
|
833
|
-
!(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;
|
|
834
1031
|
var nextParentRecord;
|
|
835
1032
|
var nextParentPayloads;
|
|
836
1033
|
|
|
@@ -865,10 +1062,6 @@ var Executor = /*#__PURE__*/function () {
|
|
|
865
1062
|
if (pendingResponses != null) {
|
|
866
1063
|
var payloadFollowups = this._processIncrementalResponses(pendingResponses);
|
|
867
1064
|
|
|
868
|
-
var updatedOwners = this._publishQueue.run();
|
|
869
|
-
|
|
870
|
-
this._updateOperationTracker(updatedOwners);
|
|
871
|
-
|
|
872
1065
|
this._processPayloadFollowups(payloadFollowups);
|
|
873
1066
|
}
|
|
874
1067
|
}
|
|
@@ -913,7 +1106,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
913
1106
|
}
|
|
914
1107
|
|
|
915
1108
|
var placeholder = resultForPath.placeholder;
|
|
916
|
-
!(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;
|
|
917
1110
|
relayPayloads.push(_this11._processDeferResponse(label, path, placeholder, response));
|
|
918
1111
|
} else {
|
|
919
1112
|
// @stream payload path values end in the field name and item index,
|
|
@@ -938,7 +1131,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
938
1131
|
}
|
|
939
1132
|
|
|
940
1133
|
var _placeholder = _resultForPath.placeholder;
|
|
941
|
-
!(_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;
|
|
942
1135
|
relayPayloads.push(_this11._processStreamResponse(label, path, _placeholder, response));
|
|
943
1136
|
}
|
|
944
1137
|
});
|
|
@@ -946,23 +1139,28 @@ var Executor = /*#__PURE__*/function () {
|
|
|
946
1139
|
};
|
|
947
1140
|
|
|
948
1141
|
_proto._processDeferResponse = function _processDeferResponse(label, path, placeholder, response) {
|
|
1142
|
+
var _placeholder$actorIde;
|
|
1143
|
+
|
|
949
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;
|
|
950
1147
|
var relayPayload = normalizeResponse(response, placeholder.selector, placeholder.typeName, {
|
|
1148
|
+
actorIdentifier: this._actorIdentifier,
|
|
951
1149
|
getDataID: this._getDataID,
|
|
952
1150
|
path: placeholder.path,
|
|
953
|
-
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer,
|
|
1151
|
+
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer != null ? this._deserializeReactFlightPayloadWithLogging : null,
|
|
954
1152
|
reactFlightServerErrorHandler: this._reactFlightServerErrorHandler,
|
|
955
1153
|
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
956
1154
|
shouldProcessClientComponents: this._shouldProcessClientComponents
|
|
957
1155
|
});
|
|
958
1156
|
|
|
959
|
-
this.
|
|
1157
|
+
this._getPublishQueueAndSaveActor().commitPayload(this._operation, relayPayload); // Load the version of the parent record from which this incremental data
|
|
960
1158
|
// was derived
|
|
961
1159
|
|
|
962
1160
|
|
|
963
1161
|
var parentEntry = this._source.get(parentID);
|
|
964
1162
|
|
|
965
|
-
!(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;
|
|
966
1164
|
var fieldPayloads = parentEntry.fieldPayloads;
|
|
967
1165
|
|
|
968
1166
|
if (fieldPayloads.length !== 0) {
|
|
@@ -972,14 +1170,15 @@ var Executor = /*#__PURE__*/function () {
|
|
|
972
1170
|
errors: null,
|
|
973
1171
|
fieldPayloads: fieldPayloads,
|
|
974
1172
|
incrementalPlaceholders: null,
|
|
975
|
-
|
|
1173
|
+
followupPayloads: null,
|
|
976
1174
|
source: RelayRecordSource.create(),
|
|
977
1175
|
isFinal: ((_response$extensions2 = response.extensions) === null || _response$extensions2 === void 0 ? void 0 : _response$extensions2.is_final) === true
|
|
978
1176
|
};
|
|
979
1177
|
|
|
980
|
-
this.
|
|
1178
|
+
this._getPublishQueueAndSaveActor().commitPayload(this._operation, handleFieldsRelayPayload);
|
|
981
1179
|
}
|
|
982
1180
|
|
|
1181
|
+
this._actorIdentifier = prevActorIdentifier;
|
|
983
1182
|
return relayPayload;
|
|
984
1183
|
}
|
|
985
1184
|
/**
|
|
@@ -990,10 +1189,13 @@ var Executor = /*#__PURE__*/function () {
|
|
|
990
1189
|
_proto._processStreamResponse = function _processStreamResponse(label, path, placeholder, response) {
|
|
991
1190
|
var parentID = placeholder.parentID,
|
|
992
1191
|
node = placeholder.node,
|
|
993
|
-
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
|
|
994
1196
|
|
|
995
1197
|
var field = node.selections[0];
|
|
996
|
-
!(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;
|
|
997
1199
|
|
|
998
1200
|
var _this$_normalizeStrea = this._normalizeStreamItem(response, parentID, field, variables, path, placeholder.path),
|
|
999
1201
|
fieldPayloads = _this$_normalizeStrea.fieldPayloads,
|
|
@@ -1006,7 +1208,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
1006
1208
|
// modified.
|
|
1007
1209
|
|
|
1008
1210
|
|
|
1009
|
-
this.
|
|
1211
|
+
this._getPublishQueueAndSaveActor().commitPayload(this._operation, relayPayload, function (store) {
|
|
1010
1212
|
var currentParentRecord = store.get(parentID);
|
|
1011
1213
|
|
|
1012
1214
|
if (currentParentRecord == null) {
|
|
@@ -1043,14 +1245,15 @@ var Executor = /*#__PURE__*/function () {
|
|
|
1043
1245
|
errors: null,
|
|
1044
1246
|
fieldPayloads: fieldPayloads,
|
|
1045
1247
|
incrementalPlaceholders: null,
|
|
1046
|
-
|
|
1248
|
+
followupPayloads: null,
|
|
1047
1249
|
source: RelayRecordSource.create(),
|
|
1048
1250
|
isFinal: false
|
|
1049
1251
|
};
|
|
1050
1252
|
|
|
1051
|
-
this.
|
|
1253
|
+
this._getPublishQueueAndSaveActor().commitPayload(this._operation, handleFieldsRelayPayload);
|
|
1052
1254
|
}
|
|
1053
1255
|
|
|
1256
|
+
this._actorIdentifier = prevActorIdentifier;
|
|
1054
1257
|
return relayPayload;
|
|
1055
1258
|
};
|
|
1056
1259
|
|
|
@@ -1058,34 +1261,34 @@ var Executor = /*#__PURE__*/function () {
|
|
|
1058
1261
|
var _field$alias, _field$concreteType, _this$_getDataID;
|
|
1059
1262
|
|
|
1060
1263
|
var data = response.data;
|
|
1061
|
-
!(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;
|
|
1062
1265
|
var responseKey = (_field$alias = field.alias) !== null && _field$alias !== void 0 ? _field$alias : field.name;
|
|
1063
1266
|
var storageKey = getStorageKey(field, variables); // Load the version of the parent record from which this incremental data
|
|
1064
1267
|
// was derived
|
|
1065
1268
|
|
|
1066
1269
|
var parentEntry = this._source.get(parentID);
|
|
1067
1270
|
|
|
1068
|
-
!(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;
|
|
1069
1272
|
var parentRecord = parentEntry.record,
|
|
1070
1273
|
fieldPayloads = parentEntry.fieldPayloads; // Load the field value (items) that were created by *this* query executor
|
|
1071
1274
|
// in order to check if there has been any concurrent modifications by some
|
|
1072
1275
|
// other operation.
|
|
1073
1276
|
|
|
1074
1277
|
var prevIDs = RelayModernRecord.getLinkedRecordIDs(parentRecord, storageKey);
|
|
1075
|
-
!(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
|
|
1076
1279
|
|
|
1077
1280
|
var finalPathEntry = path[path.length - 1];
|
|
1078
1281
|
var itemIndex = parseInt(finalPathEntry, 10);
|
|
1079
|
-
!(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;
|
|
1080
1283
|
var typeName = (_field$concreteType = field.concreteType) !== null && _field$concreteType !== void 0 ? _field$concreteType : data[TYPENAME_KEY];
|
|
1081
|
-
!(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
|
|
1082
1285
|
// be assigned had the item not been streamed
|
|
1083
1286
|
|
|
1084
1287
|
var itemID = // https://github.com/prettier/prettier/issues/6403
|
|
1085
1288
|
// prettier-ignore
|
|
1086
1289
|
((_this$_getDataID = this._getDataID(data, typeName)) !== null && _this$_getDataID !== void 0 ? _this$_getDataID : prevIDs && prevIDs[itemIndex]) || // Reuse previously generated client IDs
|
|
1087
1290
|
generateClientID(parentID, storageKey, itemIndex);
|
|
1088
|
-
!(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
|
|
1089
1292
|
|
|
1090
1293
|
var selector = createNormalizationSelector(field, itemID, variables); // Update the cached version of the parent record to reflect the new item:
|
|
1091
1294
|
// this is used when subsequent stream payloads arrive to see if there
|
|
@@ -1102,9 +1305,10 @@ var Executor = /*#__PURE__*/function () {
|
|
|
1102
1305
|
});
|
|
1103
1306
|
|
|
1104
1307
|
var relayPayload = normalizeResponse(response, selector, typeName, {
|
|
1308
|
+
actorIdentifier: this._actorIdentifier,
|
|
1105
1309
|
getDataID: this._getDataID,
|
|
1106
1310
|
path: [].concat((0, _toConsumableArray2["default"])(normalizationPath), [responseKey, String(itemIndex)]),
|
|
1107
|
-
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer,
|
|
1311
|
+
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer != null ? this._deserializeReactFlightPayloadWithLogging : null,
|
|
1108
1312
|
reactFlightServerErrorHandler: this._reactFlightServerErrorHandler,
|
|
1109
1313
|
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
1110
1314
|
shouldProcessClientComponents: this._shouldProcessClientComponents
|
|
@@ -1119,18 +1323,132 @@ var Executor = /*#__PURE__*/function () {
|
|
|
1119
1323
|
};
|
|
1120
1324
|
};
|
|
1121
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
|
+
|
|
1122
1360
|
_proto._updateOperationTracker = function _updateOperationTracker(updatedOwners) {
|
|
1123
|
-
if (
|
|
1361
|
+
if (updatedOwners != null && updatedOwners.length > 0) {
|
|
1124
1362
|
this._operationTracker.update(this._operation.request, new Set(updatedOwners));
|
|
1125
1363
|
}
|
|
1126
1364
|
};
|
|
1127
1365
|
|
|
1128
1366
|
_proto._completeOperationTracker = function _completeOperationTracker() {
|
|
1129
|
-
|
|
1130
|
-
|
|
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;
|
|
1131
1381
|
}
|
|
1132
1382
|
};
|
|
1133
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
|
+
|
|
1134
1452
|
return Executor;
|
|
1135
1453
|
}();
|
|
1136
1454
|
|
|
@@ -1143,7 +1461,7 @@ function partitionGraphQLResponses(responses) {
|
|
|
1143
1461
|
path = response.path;
|
|
1144
1462
|
|
|
1145
1463
|
if (label == null || path == null) {
|
|
1146
|
-
!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;
|
|
1147
1465
|
}
|
|
1148
1466
|
|
|
1149
1467
|
incrementalResponses.push({
|
|
@@ -1183,7 +1501,7 @@ function validateOptimisticResponsePayload(payload) {
|
|
|
1183
1501
|
var incrementalPlaceholders = payload.incrementalPlaceholders;
|
|
1184
1502
|
|
|
1185
1503
|
if (incrementalPlaceholders != null && incrementalPlaceholders.length !== 0) {
|
|
1186
|
-
!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;
|
|
1187
1505
|
}
|
|
1188
1506
|
}
|
|
1189
1507
|
|