relay-runtime 11.0.2 → 13.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -0
- package/handlers/RelayDefaultHandlerProvider.js.flow +3 -3
- package/handlers/connection/ConnectionHandler.js.flow +9 -18
- package/handlers/connection/ConnectionInterface.js.flow +1 -1
- package/handlers/connection/MutationHandlers.js.flow +8 -12
- package/index.js +1 -1
- package/index.js.flow +57 -35
- package/lib/handlers/RelayDefaultHandlerProvider.js +1 -1
- package/lib/handlers/connection/ConnectionHandler.js +13 -19
- package/lib/handlers/connection/ConnectionInterface.js +1 -1
- package/lib/handlers/connection/MutationHandlers.js +4 -7
- package/lib/index.js +59 -44
- package/lib/multi-actor-environment/ActorIdentifier.js +12 -2
- package/lib/multi-actor-environment/ActorSpecificEnvironment.js +64 -20
- package/lib/multi-actor-environment/ActorUtils.js +27 -0
- package/lib/multi-actor-environment/MultiActorEnvironment.js +324 -61
- package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +1 -1
- package/lib/multi-actor-environment/index.js +6 -2
- package/lib/mutations/RelayDeclarativeMutationConfig.js +5 -2
- package/lib/mutations/RelayRecordProxy.js +4 -3
- package/lib/mutations/RelayRecordSourceMutator.js +4 -3
- package/lib/mutations/RelayRecordSourceProxy.js +13 -5
- package/lib/mutations/RelayRecordSourceSelectorProxy.js +19 -6
- package/lib/mutations/applyOptimisticMutation.js +7 -7
- package/lib/mutations/commitLocalUpdate.js +1 -1
- package/lib/mutations/commitMutation.js +15 -11
- package/lib/mutations/readUpdatableQuery_EXPERIMENTAL.js +242 -0
- package/lib/mutations/validateMutation.js +11 -6
- package/lib/network/ConvertToExecuteFunction.js +3 -2
- package/lib/network/RelayNetwork.js +4 -3
- package/lib/network/RelayNetworkTypes.js +1 -1
- package/lib/network/RelayObservable.js +1 -1
- package/lib/network/RelayQueryResponseCache.js +22 -6
- package/lib/network/wrapNetworkWithLogObserver.js +79 -0
- package/lib/query/GraphQLTag.js +3 -2
- package/lib/query/PreloadableQueryRegistry.js +1 -1
- package/lib/query/fetchQuery.js +7 -6
- package/lib/query/fetchQueryInternal.js +1 -1
- package/lib/query/fetchQuery_DEPRECATED.js +3 -2
- package/lib/store/ClientID.js +8 -2
- package/lib/store/DataChecker.js +124 -55
- package/lib/store/OperationExecutor.js +489 -215
- package/lib/store/RelayConcreteVariables.js +27 -9
- package/lib/store/RelayExperimentalGraphResponseHandler.js +153 -0
- package/lib/store/RelayExperimentalGraphResponseTransform.js +391 -0
- package/lib/store/RelayModernEnvironment.js +100 -120
- package/lib/store/RelayModernFragmentSpecResolver.js +53 -27
- package/lib/store/RelayModernOperationDescriptor.js +3 -2
- package/lib/store/RelayModernRecord.js +48 -13
- package/lib/store/RelayModernSelector.js +15 -9
- package/lib/store/RelayModernStore.js +56 -23
- package/lib/store/RelayOperationTracker.js +34 -24
- package/lib/store/RelayOptimisticRecordSource.js +1 -1
- package/lib/store/RelayPublishQueue.js +35 -11
- package/lib/store/RelayReader.js +257 -72
- package/lib/store/RelayRecordSource.js +88 -4
- package/lib/store/RelayRecordState.js +1 -1
- package/lib/store/RelayReferenceMarker.js +34 -22
- package/lib/store/RelayResponseNormalizer.js +172 -96
- package/lib/store/RelayStoreReactFlightUtils.js +5 -11
- package/lib/store/RelayStoreSubscriptions.js +15 -10
- package/lib/store/RelayStoreTypes.js +1 -1
- package/lib/store/RelayStoreUtils.js +13 -8
- package/lib/store/ResolverCache.js +213 -0
- package/lib/store/ResolverFragments.js +10 -6
- package/lib/store/StoreInspector.js +1 -1
- package/lib/store/TypeID.js +1 -1
- package/lib/store/ViewerPattern.js +1 -1
- package/lib/store/cloneRelayHandleSourceField.js +6 -5
- package/lib/store/cloneRelayScalarHandleSourceField.js +6 -5
- package/lib/store/createFragmentSpecResolver.js +1 -1
- package/lib/store/createRelayContext.js +5 -3
- package/lib/store/defaultGetDataID.js +1 -1
- package/lib/store/defaultRequiredFieldLogger.js +1 -1
- package/lib/store/hasOverlappingIDs.js +1 -1
- package/lib/store/isRelayModernEnvironment.js +1 -1
- package/lib/store/normalizeRelayPayload.js +1 -1
- package/lib/store/readInlineData.js +7 -3
- package/lib/subscription/requestSubscription.js +32 -34
- package/lib/util/JSResourceTypes.flow.js +1 -1
- package/lib/util/NormalizationNode.js +1 -1
- package/lib/util/ReaderNode.js +1 -1
- package/lib/util/RelayConcreteNode.js +3 -1
- package/lib/util/RelayDefaultHandleKey.js +1 -1
- package/lib/util/RelayError.js +1 -1
- package/lib/util/RelayFeatureFlags.js +10 -7
- package/lib/util/RelayProfiler.js +1 -1
- package/lib/util/RelayReplaySubject.js +22 -7
- package/lib/util/RelayRuntimeTypes.js +1 -7
- package/lib/util/StringInterner.js +71 -0
- package/lib/util/createPayloadFor3DField.js +1 -1
- package/lib/util/deepFreeze.js +1 -1
- package/lib/util/generateID.js +1 -1
- package/lib/util/getAllRootVariables.js +29 -0
- package/lib/util/getFragmentIdentifier.js +16 -8
- package/lib/util/getOperation.js +3 -2
- 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 +3 -3
- package/lib/util/getRequestIdentifier.js +3 -3
- package/lib/util/getValueAtPath.js +51 -0
- package/lib/util/isEmptyObject.js +2 -2
- package/lib/util/isPromise.js +1 -1
- package/lib/util/isScalarAndEqual.js +1 -1
- package/lib/util/recycleNodesInto.js +1 -1
- package/lib/util/registerEnvironmentWithDevTools.js +26 -0
- package/lib/util/reportMissingRequiredFields.js +1 -1
- package/lib/util/resolveImmediate.js +1 -1
- package/lib/util/stableCopy.js +1 -1
- package/lib/util/withDuration.js +31 -0
- package/multi-actor-environment/ActorIdentifier.js.flow +18 -2
- package/multi-actor-environment/ActorSpecificEnvironment.js.flow +94 -58
- package/multi-actor-environment/ActorUtils.js.flow +33 -0
- package/multi-actor-environment/MultiActorEnvironment.js.flow +366 -93
- package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +88 -23
- package/multi-actor-environment/index.js.flow +3 -1
- package/mutations/RelayDeclarativeMutationConfig.js.flow +33 -27
- package/mutations/RelayRecordProxy.js.flow +5 -6
- package/mutations/RelayRecordSourceMutator.js.flow +5 -7
- package/mutations/RelayRecordSourceProxy.js.flow +20 -11
- package/mutations/RelayRecordSourceSelectorProxy.js.flow +23 -8
- package/mutations/applyOptimisticMutation.js.flow +14 -15
- package/mutations/commitLocalUpdate.js.flow +2 -2
- package/mutations/commitMutation.js.flow +36 -47
- package/mutations/readUpdatableQuery_EXPERIMENTAL.js.flow +318 -0
- package/mutations/validateMutation.js.flow +27 -17
- package/network/ConvertToExecuteFunction.js.flow +3 -3
- package/network/RelayNetwork.js.flow +5 -6
- package/network/RelayNetworkTypes.js.flow +1 -1
- package/network/RelayObservable.js.flow +2 -2
- package/network/RelayQueryResponseCache.js.flow +35 -22
- package/network/wrapNetworkWithLogObserver.js.flow +99 -0
- package/package.json +2 -2
- package/query/GraphQLTag.js.flow +11 -11
- package/query/PreloadableQueryRegistry.js.flow +5 -3
- package/query/fetchQuery.js.flow +19 -19
- package/query/fetchQueryInternal.js.flow +7 -10
- package/query/fetchQuery_DEPRECATED.js.flow +7 -7
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/ClientID.js.flow +15 -4
- package/store/DataChecker.js.flow +142 -60
- package/store/OperationExecutor.js.flow +575 -320
- package/store/RelayConcreteVariables.js.flow +28 -9
- package/store/RelayExperimentalGraphResponseHandler.js.flow +121 -0
- package/store/RelayExperimentalGraphResponseTransform.js.flow +470 -0
- package/store/RelayModernEnvironment.js.flow +91 -115
- package/store/RelayModernFragmentSpecResolver.js.flow +56 -32
- package/store/RelayModernOperationDescriptor.js.flow +13 -8
- package/store/RelayModernRecord.js.flow +68 -12
- package/store/RelayModernSelector.js.flow +25 -15
- package/store/RelayModernStore.js.flow +67 -32
- package/store/RelayOperationTracker.js.flow +60 -44
- package/store/RelayOptimisticRecordSource.js.flow +3 -3
- package/store/RelayPublishQueue.js.flow +74 -32
- package/store/RelayReader.js.flow +319 -100
- package/store/RelayRecordSource.js.flow +73 -7
- package/store/RelayRecordState.js.flow +1 -1
- package/store/RelayReferenceMarker.js.flow +41 -27
- package/store/RelayResponseNormalizer.js.flow +204 -86
- package/store/RelayStoreReactFlightUtils.js.flow +5 -12
- package/store/RelayStoreSubscriptions.js.flow +20 -12
- package/store/RelayStoreTypes.js.flow +200 -41
- package/store/RelayStoreUtils.js.flow +25 -12
- package/store/ResolverCache.js.flow +249 -0
- package/store/ResolverFragments.js.flow +16 -20
- package/store/StoreInspector.js.flow +3 -3
- package/store/TypeID.js.flow +2 -2
- package/store/ViewerPattern.js.flow +3 -3
- package/store/cloneRelayHandleSourceField.js.flow +6 -7
- package/store/cloneRelayScalarHandleSourceField.js.flow +6 -7
- package/store/createFragmentSpecResolver.js.flow +4 -5
- package/store/createRelayContext.js.flow +4 -4
- package/store/defaultGetDataID.js.flow +1 -1
- package/store/defaultRequiredFieldLogger.js.flow +1 -1
- package/store/hasOverlappingIDs.js.flow +1 -1
- package/store/isRelayModernEnvironment.js.flow +1 -1
- package/store/normalizeRelayPayload.js.flow +7 -8
- package/store/readInlineData.js.flow +8 -9
- package/subscription/requestSubscription.js.flow +55 -51
- package/util/JSResourceTypes.flow.js.flow +1 -1
- package/util/NormalizationNode.js.flow +11 -4
- package/util/ReaderNode.js.flow +25 -2
- package/util/RelayConcreteNode.js.flow +5 -1
- package/util/RelayDefaultHandleKey.js.flow +1 -1
- package/util/RelayError.js.flow +1 -1
- package/util/RelayFeatureFlags.js.flow +23 -15
- package/util/RelayProfiler.js.flow +1 -1
- package/util/RelayReplaySubject.js.flow +10 -10
- package/util/RelayRuntimeTypes.js.flow +70 -3
- package/util/StringInterner.js.flow +69 -0
- package/util/createPayloadFor3DField.js.flow +4 -4
- package/util/deepFreeze.js.flow +1 -1
- package/util/generateID.js.flow +1 -1
- package/util/getAllRootVariables.js.flow +36 -0
- package/util/getFragmentIdentifier.js.flow +28 -16
- package/util/getOperation.js.flow +3 -3
- package/util/getPaginationMetadata.js.flow +69 -0
- package/util/getPaginationVariables.js.flow +108 -0
- package/util/getPendingOperationsForFragment.js.flow +62 -0
- package/util/getRefetchMetadata.js.flow +76 -0
- package/util/getRelayHandleKey.js.flow +2 -3
- package/util/getRequestIdentifier.js.flow +4 -4
- package/util/getValueAtPath.js.flow +46 -0
- package/util/isEmptyObject.js.flow +2 -1
- package/util/isPromise.js.flow +1 -1
- package/util/isScalarAndEqual.js.flow +1 -1
- package/util/recycleNodesInto.js.flow +1 -1
- package/util/registerEnvironmentWithDevTools.js.flow +33 -0
- package/util/reportMissingRequiredFields.js.flow +1 -1
- package/util/resolveImmediate.js.flow +2 -2
- package/util/stableCopy.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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -17,41 +17,50 @@ 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
|
|
|
24
|
+
var RelayObservable = require('../network/RelayObservable');
|
|
25
|
+
|
|
26
|
+
var generateID = require('../util/generateID');
|
|
27
|
+
|
|
28
|
+
var getOperation = require('../util/getOperation');
|
|
29
|
+
|
|
22
30
|
var RelayError = require('../util/RelayError');
|
|
23
31
|
|
|
24
32
|
var RelayFeatureFlags = require('../util/RelayFeatureFlags');
|
|
25
33
|
|
|
34
|
+
var stableCopy = require('../util/stableCopy');
|
|
35
|
+
|
|
36
|
+
var withDuration = require('../util/withDuration');
|
|
37
|
+
|
|
38
|
+
var _require = require('./ClientID'),
|
|
39
|
+
generateClientID = _require.generateClientID,
|
|
40
|
+
generateUniqueClientID = _require.generateUniqueClientID;
|
|
41
|
+
|
|
42
|
+
var _require2 = require('./RelayConcreteVariables'),
|
|
43
|
+
getLocalVariables = _require2.getLocalVariables;
|
|
44
|
+
|
|
26
45
|
var RelayModernRecord = require('./RelayModernRecord');
|
|
27
46
|
|
|
28
|
-
var
|
|
47
|
+
var _require3 = require('./RelayModernSelector'),
|
|
48
|
+
createNormalizationSelector = _require3.createNormalizationSelector,
|
|
49
|
+
createReaderSelector = _require3.createReaderSelector;
|
|
29
50
|
|
|
30
51
|
var RelayRecordSource = require('./RelayRecordSource');
|
|
31
52
|
|
|
32
53
|
var RelayResponseNormalizer = require('./RelayResponseNormalizer');
|
|
33
54
|
|
|
34
|
-
var
|
|
55
|
+
var _require4 = require('./RelayStoreUtils'),
|
|
56
|
+
ROOT_TYPE = _require4.ROOT_TYPE,
|
|
57
|
+
TYPENAME_KEY = _require4.TYPENAME_KEY,
|
|
58
|
+
getStorageKey = _require4.getStorageKey;
|
|
35
59
|
|
|
36
60
|
var invariant = require('invariant');
|
|
37
61
|
|
|
38
|
-
var stableCopy = require('../util/stableCopy');
|
|
39
|
-
|
|
40
62
|
var warning = require("fbjs/lib/warning");
|
|
41
63
|
|
|
42
|
-
var _require = require('./ClientID'),
|
|
43
|
-
generateClientID = _require.generateClientID,
|
|
44
|
-
generateUniqueClientID = _require.generateUniqueClientID;
|
|
45
|
-
|
|
46
|
-
var _require2 = require('./RelayModernSelector'),
|
|
47
|
-
createNormalizationSelector = _require2.createNormalizationSelector,
|
|
48
|
-
createReaderSelector = _require2.createReaderSelector;
|
|
49
|
-
|
|
50
|
-
var _require3 = require('./RelayStoreUtils'),
|
|
51
|
-
ROOT_TYPE = _require3.ROOT_TYPE,
|
|
52
|
-
TYPENAME_KEY = _require3.TYPENAME_KEY,
|
|
53
|
-
getStorageKey = _require3.getStorageKey;
|
|
54
|
-
|
|
55
64
|
function execute(config) {
|
|
56
65
|
return new Executor(config);
|
|
57
66
|
}
|
|
@@ -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.
|
|
211
|
+
return _this2._getPublishQueueAndSaveActor().revertUpdate(update);
|
|
166
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.
|
|
174
|
-
|
|
175
|
-
if (this._retainDisposable) {
|
|
176
|
-
this._retainDisposable.dispose();
|
|
219
|
+
if (this._asyncStoreUpdateDisposable != null) {
|
|
220
|
+
this._asyncStoreUpdateDisposable.dispose();
|
|
177
221
|
|
|
178
|
-
this.
|
|
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() {
|
|
@@ -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;
|
|
@@ -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);
|
|
@@ -407,39 +480,30 @@ var Executor = /*#__PURE__*/function () {
|
|
|
407
480
|
// payloads (although, can that even happen?)
|
|
408
481
|
|
|
409
482
|
if (hasNonIncrementalResponses) {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
this.
|
|
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
|
+
};
|
|
416
493
|
}
|
|
417
494
|
|
|
418
|
-
this.
|
|
495
|
+
var payloadFollowups = this._processResponses(nonIncrementalResponses);
|
|
419
496
|
|
|
420
|
-
|
|
421
|
-
if (this._incrementalPayloadsPending && !this._retainDisposable) {
|
|
422
|
-
this._retainDisposable = this._store.retain(this._operation);
|
|
423
|
-
}
|
|
424
|
-
}
|
|
497
|
+
this._processPayloadFollowups(payloadFollowups);
|
|
425
498
|
}
|
|
426
499
|
|
|
427
500
|
if (incrementalResponses.length > 0) {
|
|
428
501
|
var _payloadFollowups = this._processIncrementalResponses(incrementalResponses);
|
|
429
502
|
|
|
430
|
-
if (!RelayFeatureFlags.ENABLE_BATCHED_STORE_UPDATES) {
|
|
431
|
-
// For the incremental case, we're only handling follow-up responses
|
|
432
|
-
// for already initiated operation (and we're not passing it to
|
|
433
|
-
// the run(...) call)
|
|
434
|
-
var _updatedOwners = this._publishQueue.run();
|
|
435
|
-
|
|
436
|
-
this._updateOperationTracker(_updatedOwners);
|
|
437
|
-
}
|
|
438
|
-
|
|
439
503
|
this._processPayloadFollowups(_payloadFollowups);
|
|
440
504
|
}
|
|
441
505
|
|
|
442
|
-
if (this._isSubscriptionOperation
|
|
506
|
+
if (this._isSubscriptionOperation) {
|
|
443
507
|
// We attach the id to allow the `requestSubscription` to read from the store using
|
|
444
508
|
// the current id in its `onNext` callback
|
|
445
509
|
if (responsesWithData[0].extensions == null) {
|
|
@@ -450,31 +514,29 @@ var Executor = /*#__PURE__*/function () {
|
|
|
450
514
|
} else {
|
|
451
515
|
responsesWithData[0].extensions.__relay_subscription_root_id = this._operation.fragment.dataID;
|
|
452
516
|
}
|
|
453
|
-
}
|
|
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
|
|
454
521
|
|
|
455
|
-
if (RelayFeatureFlags.ENABLE_BATCHED_STORE_UPDATES) {
|
|
456
|
-
// OK: run once after each new payload
|
|
457
|
-
// If we have non-incremental responses, we passing `this._operation` to
|
|
458
|
-
// the publish queue here, which will later be passed to the store (via
|
|
459
|
-
// notify) to indicate that this operation caused the store to update
|
|
460
|
-
var _updatedOwners2 = this._publishQueue.run(hasNonIncrementalResponses ? this._operation : undefined);
|
|
461
522
|
|
|
462
|
-
|
|
463
|
-
if (this._incrementalPayloadsPending && !this._retainDisposable) {
|
|
464
|
-
this._retainDisposable = this._store.retain(this._operation);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
523
|
+
var updatedOwners = this._runPublishQueue(hasNonIncrementalResponses ? this._operation : undefined);
|
|
467
524
|
|
|
468
|
-
|
|
525
|
+
if (hasNonIncrementalResponses) {
|
|
526
|
+
if (this._incrementalPayloadsPending) {
|
|
527
|
+
this._retainData();
|
|
528
|
+
}
|
|
469
529
|
}
|
|
470
530
|
|
|
531
|
+
this._updateOperationTracker(updatedOwners);
|
|
532
|
+
|
|
471
533
|
this._sink.next(response);
|
|
472
534
|
};
|
|
473
535
|
|
|
474
536
|
_proto._processOptimisticResponse = function _processOptimisticResponse(response, updater, treatMissingFieldsAsNull) {
|
|
475
537
|
var _this6 = this;
|
|
476
538
|
|
|
477
|
-
!(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;
|
|
478
540
|
|
|
479
541
|
if (response == null && updater == null) {
|
|
480
542
|
return;
|
|
@@ -484,9 +546,10 @@ var Executor = /*#__PURE__*/function () {
|
|
|
484
546
|
|
|
485
547
|
if (response) {
|
|
486
548
|
var payload = normalizeResponse(response, this._operation.root, ROOT_TYPE, {
|
|
549
|
+
actorIdentifier: this._actorIdentifier,
|
|
487
550
|
getDataID: this._getDataID,
|
|
488
551
|
path: [],
|
|
489
|
-
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer,
|
|
552
|
+
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer != null ? this._deserializeReactFlightPayloadWithLogging : null,
|
|
490
553
|
reactFlightServerErrorHandler: this._reactFlightServerErrorHandler,
|
|
491
554
|
shouldProcessClientComponents: this._shouldProcessClientComponents,
|
|
492
555
|
treatMissingFieldsAsNull: treatMissingFieldsAsNull
|
|
@@ -506,7 +569,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
506
569
|
errors: null,
|
|
507
570
|
fieldPayloads: null,
|
|
508
571
|
incrementalPlaceholders: null,
|
|
509
|
-
|
|
572
|
+
followupPayloads: null,
|
|
510
573
|
source: RelayRecordSource.create(),
|
|
511
574
|
isFinal: false
|
|
512
575
|
},
|
|
@@ -516,33 +579,47 @@ var Executor = /*#__PURE__*/function () {
|
|
|
516
579
|
|
|
517
580
|
this._optimisticUpdates = optimisticUpdates;
|
|
518
581
|
optimisticUpdates.forEach(function (update) {
|
|
519
|
-
return _this6.
|
|
582
|
+
return _this6._getPublishQueueAndSaveActor().applyUpdate(update);
|
|
520
583
|
}); // OK: only called on construction and when receiving an optimistic payload from network,
|
|
521
584
|
// which doesn't fall-through to the regular next() handling
|
|
522
585
|
|
|
523
|
-
this.
|
|
586
|
+
this._runPublishQueue();
|
|
524
587
|
};
|
|
525
588
|
|
|
526
589
|
_proto._processOptimisticFollowups = function _processOptimisticFollowups(payload, optimisticUpdates) {
|
|
527
|
-
if (payload.
|
|
528
|
-
var
|
|
529
|
-
var operationLoader = this._operationLoader;
|
|
530
|
-
!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;
|
|
531
592
|
|
|
532
|
-
var _iterator = (0, _createForOfIteratorHelper2["default"])(
|
|
593
|
+
var _iterator = (0, _createForOfIteratorHelper2["default"])(followupPayloads),
|
|
533
594
|
_step;
|
|
534
595
|
|
|
535
596
|
try {
|
|
536
597
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
537
|
-
var
|
|
538
|
-
|
|
598
|
+
var followupPayload = _step.value;
|
|
599
|
+
|
|
600
|
+
switch (followupPayload.kind) {
|
|
601
|
+
case 'ModuleImportPayload':
|
|
602
|
+
var operationLoader = this._expectOperationLoader();
|
|
539
603
|
|
|
540
|
-
|
|
541
|
-
this._processAsyncOptimisticModuleImport(operationLoader, moduleImportPayload);
|
|
542
|
-
} else {
|
|
543
|
-
var moduleImportOptimisticUpdates = this._processOptimisticModuleImport(operation, moduleImportPayload);
|
|
604
|
+
var operation = operationLoader.get(followupPayload.operationReference);
|
|
544
605
|
|
|
545
|
-
|
|
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;
|
|
615
|
+
|
|
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;
|
|
546
623
|
}
|
|
547
624
|
}
|
|
548
625
|
} catch (err) {
|
|
@@ -551,16 +628,29 @@ var Executor = /*#__PURE__*/function () {
|
|
|
551
628
|
_iterator.f();
|
|
552
629
|
}
|
|
553
630
|
}
|
|
554
|
-
}
|
|
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;
|
|
555
639
|
|
|
556
|
-
|
|
557
|
-
|
|
640
|
+
if (normalizationNode.kind === 'SplitOperation' && followupPayload.kind === 'ModuleImportPayload') {
|
|
641
|
+
variables = getLocalVariables(followupPayload.variables, normalizationNode.argumentDefinitions, followupPayload.args);
|
|
642
|
+
} else {
|
|
643
|
+
variables = followupPayload.variables;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
var selector = createNormalizationSelector(normalizationNode, followupPayload.dataID, variables);
|
|
558
647
|
return normalizeResponse({
|
|
559
|
-
data:
|
|
560
|
-
}, selector,
|
|
648
|
+
data: followupPayload.data
|
|
649
|
+
}, selector, followupPayload.typeName, {
|
|
650
|
+
actorIdentifier: this._actorIdentifier,
|
|
561
651
|
getDataID: this._getDataID,
|
|
562
|
-
path:
|
|
563
|
-
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer,
|
|
652
|
+
path: followupPayload.path,
|
|
653
|
+
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer != null ? this._deserializeReactFlightPayloadWithLogging : null,
|
|
564
654
|
reactFlightServerErrorHandler: this._reactFlightServerErrorHandler,
|
|
565
655
|
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
566
656
|
shouldProcessClientComponents: this._shouldProcessClientComponents
|
|
@@ -571,7 +661,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
571
661
|
var operation = getOperation(normalizationRootNode);
|
|
572
662
|
var optimisticUpdates = [];
|
|
573
663
|
|
|
574
|
-
var modulePayload = this.
|
|
664
|
+
var modulePayload = this._normalizeFollowupPayload(moduleImportPayload, operation);
|
|
575
665
|
|
|
576
666
|
validateOptimisticResponsePayload(modulePayload);
|
|
577
667
|
optimisticUpdates.push({
|
|
@@ -585,10 +675,10 @@ var Executor = /*#__PURE__*/function () {
|
|
|
585
675
|
return optimisticUpdates;
|
|
586
676
|
};
|
|
587
677
|
|
|
588
|
-
_proto._processAsyncOptimisticModuleImport = function _processAsyncOptimisticModuleImport(
|
|
678
|
+
_proto._processAsyncOptimisticModuleImport = function _processAsyncOptimisticModuleImport(moduleImportPayload) {
|
|
589
679
|
var _this7 = this;
|
|
590
680
|
|
|
591
|
-
|
|
681
|
+
this._expectOperationLoader().load(moduleImportPayload.operationReference).then(function (operation) {
|
|
592
682
|
if (operation == null || _this7._state !== 'started') {
|
|
593
683
|
return;
|
|
594
684
|
}
|
|
@@ -596,7 +686,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
596
686
|
var moduleImportOptimisticUpdates = _this7._processOptimisticModuleImport(operation, moduleImportPayload);
|
|
597
687
|
|
|
598
688
|
moduleImportOptimisticUpdates.forEach(function (update) {
|
|
599
|
-
return _this7.
|
|
689
|
+
return _this7._getPublishQueueAndSaveActor().applyUpdate(update);
|
|
600
690
|
});
|
|
601
691
|
|
|
602
692
|
if (_this7._optimisticUpdates == null) {
|
|
@@ -607,7 +697,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
607
697
|
(_this$_optimisticUpda = _this7._optimisticUpdates).push.apply(_this$_optimisticUpda, (0, _toConsumableArray2["default"])(moduleImportOptimisticUpdates)); // OK: always have to run() after an module import resolves async
|
|
608
698
|
|
|
609
699
|
|
|
610
|
-
_this7.
|
|
700
|
+
_this7._runPublishQueue();
|
|
611
701
|
}
|
|
612
702
|
});
|
|
613
703
|
};
|
|
@@ -617,7 +707,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
617
707
|
|
|
618
708
|
if (this._optimisticUpdates !== null) {
|
|
619
709
|
this._optimisticUpdates.forEach(function (update) {
|
|
620
|
-
|
|
710
|
+
_this8._getPublishQueueAndSaveActor().revertUpdate(update);
|
|
621
711
|
});
|
|
622
712
|
|
|
623
713
|
this._optimisticUpdates = null;
|
|
@@ -631,15 +721,16 @@ var Executor = /*#__PURE__*/function () {
|
|
|
631
721
|
|
|
632
722
|
return responses.map(function (payloadPart) {
|
|
633
723
|
var relayPayload = normalizeResponse(payloadPart, _this8._operation.root, ROOT_TYPE, {
|
|
724
|
+
actorIdentifier: _this8._actorIdentifier,
|
|
634
725
|
getDataID: _this8._getDataID,
|
|
635
726
|
path: [],
|
|
636
|
-
reactFlightPayloadDeserializer: _this8._reactFlightPayloadDeserializer,
|
|
727
|
+
reactFlightPayloadDeserializer: _this8._reactFlightPayloadDeserializer != null ? _this8._deserializeReactFlightPayloadWithLogging : null,
|
|
637
728
|
reactFlightServerErrorHandler: _this8._reactFlightServerErrorHandler,
|
|
638
729
|
treatMissingFieldsAsNull: _this8._treatMissingFieldsAsNull,
|
|
639
730
|
shouldProcessClientComponents: _this8._shouldProcessClientComponents
|
|
640
731
|
});
|
|
641
732
|
|
|
642
|
-
_this8.
|
|
733
|
+
_this8._getPublishQueueAndSaveActor().commitPayload(_this8._operation, relayPayload, _this8._updater);
|
|
643
734
|
|
|
644
735
|
return relayPayload;
|
|
645
736
|
});
|
|
@@ -659,7 +750,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
659
750
|
|
|
660
751
|
payloads.forEach(function (payload) {
|
|
661
752
|
var incrementalPlaceholders = payload.incrementalPlaceholders,
|
|
662
|
-
|
|
753
|
+
followupPayloads = payload.followupPayloads,
|
|
663
754
|
isFinal = payload.isFinal;
|
|
664
755
|
_this9._state = isFinal ? 'loading_final' : 'loading_incremental';
|
|
665
756
|
|
|
@@ -669,18 +760,30 @@ var Executor = /*#__PURE__*/function () {
|
|
|
669
760
|
_this9._incrementalPayloadsPending = false;
|
|
670
761
|
}
|
|
671
762
|
|
|
672
|
-
if (
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
_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;
|
|
677
773
|
});
|
|
678
774
|
}
|
|
679
775
|
|
|
680
776
|
if (incrementalPlaceholders && incrementalPlaceholders.length !== 0) {
|
|
681
777
|
_this9._incrementalPayloadsPending = _this9._state !== 'loading_final';
|
|
682
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
|
+
|
|
683
784
|
_this9._processIncrementalPlaceholder(payload, incrementalPlaceholder);
|
|
785
|
+
|
|
786
|
+
_this9._actorIdentifier = prevActorIdentifier;
|
|
684
787
|
});
|
|
685
788
|
|
|
686
789
|
if (_this9._isClientPayload || _this9._state === 'loading_final') {
|
|
@@ -702,12 +805,6 @@ var Executor = /*#__PURE__*/function () {
|
|
|
702
805
|
});
|
|
703
806
|
|
|
704
807
|
if (relayPayloads.length > 0) {
|
|
705
|
-
if (!RelayFeatureFlags.ENABLE_BATCHED_STORE_UPDATES) {
|
|
706
|
-
var updatedOwners = _this9._publishQueue.run();
|
|
707
|
-
|
|
708
|
-
_this9._updateOperationTracker(updatedOwners);
|
|
709
|
-
}
|
|
710
|
-
|
|
711
808
|
_this9._processPayloadFollowups(relayPayloads);
|
|
712
809
|
}
|
|
713
810
|
}
|
|
@@ -723,15 +820,6 @@ var Executor = /*#__PURE__*/function () {
|
|
|
723
820
|
if (this._pendingModulePayloadsCount === 0 && this._incrementalPayloadsPending === false) {
|
|
724
821
|
this._completeOperationTracker();
|
|
725
822
|
}
|
|
726
|
-
|
|
727
|
-
if (RelayFeatureFlags.ENABLE_UNIQUE_SUBSCRIPTION_ROOT) {
|
|
728
|
-
var nextID = generateUniqueClientID();
|
|
729
|
-
this._operation = {
|
|
730
|
-
request: this._operation.request,
|
|
731
|
-
fragment: createReaderSelector(this._operation.fragment.node, nextID, this._operation.fragment.variables, this._operation.fragment.owner),
|
|
732
|
-
root: createNormalizationSelector(this._operation.root.node, nextID, this._operation.root.variables)
|
|
733
|
-
};
|
|
734
|
-
}
|
|
735
823
|
}
|
|
736
824
|
/**
|
|
737
825
|
* Processes a ModuleImportPayload, asynchronously resolving the normalization
|
|
@@ -742,75 +830,140 @@ var Executor = /*#__PURE__*/function () {
|
|
|
742
830
|
*/
|
|
743
831
|
;
|
|
744
832
|
|
|
745
|
-
_proto.
|
|
833
|
+
_proto._processFollowupPayload = function _processFollowupPayload(followupPayload) {
|
|
746
834
|
var _this10 = this;
|
|
747
835
|
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
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
|
+
}
|
|
784
941
|
});
|
|
785
942
|
}
|
|
786
|
-
}).subscribe({
|
|
787
|
-
complete: function complete() {
|
|
788
|
-
_this10._complete(_id3);
|
|
789
943
|
|
|
790
|
-
|
|
791
|
-
},
|
|
792
|
-
error: function error(_error4) {
|
|
793
|
-
_this10._error(_error4);
|
|
944
|
+
break;
|
|
794
945
|
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
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;
|
|
801
954
|
}
|
|
802
955
|
};
|
|
803
956
|
|
|
804
|
-
_proto.
|
|
805
|
-
|
|
957
|
+
_proto._processFollowupPayloadWithNormalizationNode = function _processFollowupPayloadWithNormalizationNode(followupPayload, normalizationNode) {
|
|
958
|
+
this._handleFollowupPayload(followupPayload, normalizationNode);
|
|
806
959
|
|
|
807
|
-
this.
|
|
960
|
+
this._maybeCompleteSubscriptionOperationTracking();
|
|
961
|
+
};
|
|
808
962
|
|
|
809
|
-
|
|
810
|
-
|
|
963
|
+
_proto._handleFollowupPayload = function _handleFollowupPayload(followupPayload, normalizationNode) {
|
|
964
|
+
var relayPayload = this._normalizeFollowupPayload(followupPayload, normalizationNode);
|
|
811
965
|
|
|
812
|
-
|
|
813
|
-
}
|
|
966
|
+
this._getPublishQueueAndSaveActor().commitPayload(this._operation, relayPayload);
|
|
814
967
|
|
|
815
968
|
this._processPayloadFollowups([relayPayload]);
|
|
816
969
|
}
|
|
@@ -860,7 +1013,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
860
1013
|
parentID = placeholder.selector.dataID;
|
|
861
1014
|
} else {
|
|
862
1015
|
placeholder;
|
|
863
|
-
!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;
|
|
864
1017
|
}
|
|
865
1018
|
|
|
866
1019
|
var parentRecord = relayPayload.source.get(parentID);
|
|
@@ -874,7 +1027,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
874
1027
|
}); // If an incremental payload exists for some id that record should also
|
|
875
1028
|
// exist.
|
|
876
1029
|
|
|
877
|
-
!(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;
|
|
878
1031
|
var nextParentRecord;
|
|
879
1032
|
var nextParentPayloads;
|
|
880
1033
|
|
|
@@ -909,12 +1062,6 @@ var Executor = /*#__PURE__*/function () {
|
|
|
909
1062
|
if (pendingResponses != null) {
|
|
910
1063
|
var payloadFollowups = this._processIncrementalResponses(pendingResponses);
|
|
911
1064
|
|
|
912
|
-
if (!RelayFeatureFlags.ENABLE_BATCHED_STORE_UPDATES) {
|
|
913
|
-
var updatedOwners = this._publishQueue.run();
|
|
914
|
-
|
|
915
|
-
this._updateOperationTracker(updatedOwners);
|
|
916
|
-
}
|
|
917
|
-
|
|
918
1065
|
this._processPayloadFollowups(payloadFollowups);
|
|
919
1066
|
}
|
|
920
1067
|
}
|
|
@@ -959,7 +1106,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
959
1106
|
}
|
|
960
1107
|
|
|
961
1108
|
var placeholder = resultForPath.placeholder;
|
|
962
|
-
!(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;
|
|
963
1110
|
relayPayloads.push(_this11._processDeferResponse(label, path, placeholder, response));
|
|
964
1111
|
} else {
|
|
965
1112
|
// @stream payload path values end in the field name and item index,
|
|
@@ -984,7 +1131,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
984
1131
|
}
|
|
985
1132
|
|
|
986
1133
|
var _placeholder = _resultForPath.placeholder;
|
|
987
|
-
!(_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;
|
|
988
1135
|
relayPayloads.push(_this11._processStreamResponse(label, path, _placeholder, response));
|
|
989
1136
|
}
|
|
990
1137
|
});
|
|
@@ -992,23 +1139,28 @@ var Executor = /*#__PURE__*/function () {
|
|
|
992
1139
|
};
|
|
993
1140
|
|
|
994
1141
|
_proto._processDeferResponse = function _processDeferResponse(label, path, placeholder, response) {
|
|
1142
|
+
var _placeholder$actorIde;
|
|
1143
|
+
|
|
995
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;
|
|
996
1147
|
var relayPayload = normalizeResponse(response, placeholder.selector, placeholder.typeName, {
|
|
1148
|
+
actorIdentifier: this._actorIdentifier,
|
|
997
1149
|
getDataID: this._getDataID,
|
|
998
1150
|
path: placeholder.path,
|
|
999
|
-
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer,
|
|
1151
|
+
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer != null ? this._deserializeReactFlightPayloadWithLogging : null,
|
|
1000
1152
|
reactFlightServerErrorHandler: this._reactFlightServerErrorHandler,
|
|
1001
1153
|
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
1002
1154
|
shouldProcessClientComponents: this._shouldProcessClientComponents
|
|
1003
1155
|
});
|
|
1004
1156
|
|
|
1005
|
-
this.
|
|
1157
|
+
this._getPublishQueueAndSaveActor().commitPayload(this._operation, relayPayload); // Load the version of the parent record from which this incremental data
|
|
1006
1158
|
// was derived
|
|
1007
1159
|
|
|
1008
1160
|
|
|
1009
1161
|
var parentEntry = this._source.get(parentID);
|
|
1010
1162
|
|
|
1011
|
-
!(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;
|
|
1012
1164
|
var fieldPayloads = parentEntry.fieldPayloads;
|
|
1013
1165
|
|
|
1014
1166
|
if (fieldPayloads.length !== 0) {
|
|
@@ -1018,14 +1170,15 @@ var Executor = /*#__PURE__*/function () {
|
|
|
1018
1170
|
errors: null,
|
|
1019
1171
|
fieldPayloads: fieldPayloads,
|
|
1020
1172
|
incrementalPlaceholders: null,
|
|
1021
|
-
|
|
1173
|
+
followupPayloads: null,
|
|
1022
1174
|
source: RelayRecordSource.create(),
|
|
1023
1175
|
isFinal: ((_response$extensions2 = response.extensions) === null || _response$extensions2 === void 0 ? void 0 : _response$extensions2.is_final) === true
|
|
1024
1176
|
};
|
|
1025
1177
|
|
|
1026
|
-
this.
|
|
1178
|
+
this._getPublishQueueAndSaveActor().commitPayload(this._operation, handleFieldsRelayPayload);
|
|
1027
1179
|
}
|
|
1028
1180
|
|
|
1181
|
+
this._actorIdentifier = prevActorIdentifier;
|
|
1029
1182
|
return relayPayload;
|
|
1030
1183
|
}
|
|
1031
1184
|
/**
|
|
@@ -1036,10 +1189,13 @@ var Executor = /*#__PURE__*/function () {
|
|
|
1036
1189
|
_proto._processStreamResponse = function _processStreamResponse(label, path, placeholder, response) {
|
|
1037
1190
|
var parentID = placeholder.parentID,
|
|
1038
1191
|
node = placeholder.node,
|
|
1039
|
-
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
|
|
1040
1196
|
|
|
1041
1197
|
var field = node.selections[0];
|
|
1042
|
-
!(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;
|
|
1043
1199
|
|
|
1044
1200
|
var _this$_normalizeStrea = this._normalizeStreamItem(response, parentID, field, variables, path, placeholder.path),
|
|
1045
1201
|
fieldPayloads = _this$_normalizeStrea.fieldPayloads,
|
|
@@ -1052,7 +1208,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
1052
1208
|
// modified.
|
|
1053
1209
|
|
|
1054
1210
|
|
|
1055
|
-
this.
|
|
1211
|
+
this._getPublishQueueAndSaveActor().commitPayload(this._operation, relayPayload, function (store) {
|
|
1056
1212
|
var currentParentRecord = store.get(parentID);
|
|
1057
1213
|
|
|
1058
1214
|
if (currentParentRecord == null) {
|
|
@@ -1089,14 +1245,15 @@ var Executor = /*#__PURE__*/function () {
|
|
|
1089
1245
|
errors: null,
|
|
1090
1246
|
fieldPayloads: fieldPayloads,
|
|
1091
1247
|
incrementalPlaceholders: null,
|
|
1092
|
-
|
|
1248
|
+
followupPayloads: null,
|
|
1093
1249
|
source: RelayRecordSource.create(),
|
|
1094
1250
|
isFinal: false
|
|
1095
1251
|
};
|
|
1096
1252
|
|
|
1097
|
-
this.
|
|
1253
|
+
this._getPublishQueueAndSaveActor().commitPayload(this._operation, handleFieldsRelayPayload);
|
|
1098
1254
|
}
|
|
1099
1255
|
|
|
1256
|
+
this._actorIdentifier = prevActorIdentifier;
|
|
1100
1257
|
return relayPayload;
|
|
1101
1258
|
};
|
|
1102
1259
|
|
|
@@ -1104,34 +1261,34 @@ var Executor = /*#__PURE__*/function () {
|
|
|
1104
1261
|
var _field$alias, _field$concreteType, _this$_getDataID;
|
|
1105
1262
|
|
|
1106
1263
|
var data = response.data;
|
|
1107
|
-
!(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;
|
|
1108
1265
|
var responseKey = (_field$alias = field.alias) !== null && _field$alias !== void 0 ? _field$alias : field.name;
|
|
1109
1266
|
var storageKey = getStorageKey(field, variables); // Load the version of the parent record from which this incremental data
|
|
1110
1267
|
// was derived
|
|
1111
1268
|
|
|
1112
1269
|
var parentEntry = this._source.get(parentID);
|
|
1113
1270
|
|
|
1114
|
-
!(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;
|
|
1115
1272
|
var parentRecord = parentEntry.record,
|
|
1116
1273
|
fieldPayloads = parentEntry.fieldPayloads; // Load the field value (items) that were created by *this* query executor
|
|
1117
1274
|
// in order to check if there has been any concurrent modifications by some
|
|
1118
1275
|
// other operation.
|
|
1119
1276
|
|
|
1120
1277
|
var prevIDs = RelayModernRecord.getLinkedRecordIDs(parentRecord, storageKey);
|
|
1121
|
-
!(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
|
|
1122
1279
|
|
|
1123
1280
|
var finalPathEntry = path[path.length - 1];
|
|
1124
1281
|
var itemIndex = parseInt(finalPathEntry, 10);
|
|
1125
|
-
!(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;
|
|
1126
1283
|
var typeName = (_field$concreteType = field.concreteType) !== null && _field$concreteType !== void 0 ? _field$concreteType : data[TYPENAME_KEY];
|
|
1127
|
-
!(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
|
|
1128
1285
|
// be assigned had the item not been streamed
|
|
1129
1286
|
|
|
1130
1287
|
var itemID = // https://github.com/prettier/prettier/issues/6403
|
|
1131
1288
|
// prettier-ignore
|
|
1132
1289
|
((_this$_getDataID = this._getDataID(data, typeName)) !== null && _this$_getDataID !== void 0 ? _this$_getDataID : prevIDs && prevIDs[itemIndex]) || // Reuse previously generated client IDs
|
|
1133
1290
|
generateClientID(parentID, storageKey, itemIndex);
|
|
1134
|
-
!(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
|
|
1135
1292
|
|
|
1136
1293
|
var selector = createNormalizationSelector(field, itemID, variables); // Update the cached version of the parent record to reflect the new item:
|
|
1137
1294
|
// this is used when subsequent stream payloads arrive to see if there
|
|
@@ -1148,9 +1305,10 @@ var Executor = /*#__PURE__*/function () {
|
|
|
1148
1305
|
});
|
|
1149
1306
|
|
|
1150
1307
|
var relayPayload = normalizeResponse(response, selector, typeName, {
|
|
1308
|
+
actorIdentifier: this._actorIdentifier,
|
|
1151
1309
|
getDataID: this._getDataID,
|
|
1152
1310
|
path: [].concat((0, _toConsumableArray2["default"])(normalizationPath), [responseKey, String(itemIndex)]),
|
|
1153
|
-
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer,
|
|
1311
|
+
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer != null ? this._deserializeReactFlightPayloadWithLogging : null,
|
|
1154
1312
|
reactFlightServerErrorHandler: this._reactFlightServerErrorHandler,
|
|
1155
1313
|
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
1156
1314
|
shouldProcessClientComponents: this._shouldProcessClientComponents
|
|
@@ -1165,6 +1323,40 @@ var Executor = /*#__PURE__*/function () {
|
|
|
1165
1323
|
};
|
|
1166
1324
|
};
|
|
1167
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
|
+
|
|
1168
1360
|
_proto._updateOperationTracker = function _updateOperationTracker(updatedOwners) {
|
|
1169
1361
|
if (updatedOwners != null && updatedOwners.length > 0) {
|
|
1170
1362
|
this._operationTracker.update(this._operation.request, new Set(updatedOwners));
|
|
@@ -1175,6 +1367,88 @@ var Executor = /*#__PURE__*/function () {
|
|
|
1175
1367
|
this._operationTracker.complete(this._operation.request);
|
|
1176
1368
|
};
|
|
1177
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;
|
|
1381
|
+
}
|
|
1382
|
+
};
|
|
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
|
+
|
|
1178
1452
|
return Executor;
|
|
1179
1453
|
}();
|
|
1180
1454
|
|