relay-runtime 0.0.0-main-1decb243 → 0.0.0-main-556d696f
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/experimental.js +1 -1
- package/index.js +1 -1
- package/lib/experimental.js +3 -3
- package/lib/handlers/RelayDefaultHandlerProvider.js +12 -12
- package/lib/handlers/connection/ConnectionHandler.js +17 -17
- package/lib/handlers/connection/ConnectionInterface.js +10 -10
- package/lib/handlers/connection/MutationHandlers.js +16 -16
- package/lib/index.js +61 -61
- package/lib/multi-actor-environment/ActorIdentifier.js +5 -5
- package/lib/multi-actor-environment/ActorSpecificEnvironment.js +8 -8
- package/lib/multi-actor-environment/ActorUtils.js +4 -4
- package/lib/multi-actor-environment/MultiActorEnvironment.js +12 -12
- package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +1 -1
- package/lib/multi-actor-environment/index.js +3 -3
- package/lib/mutations/RelayDeclarativeMutationConfig.js +26 -26
- package/lib/mutations/RelayRecordProxy.js +9 -9
- package/lib/mutations/RelayRecordSourceMutator.js +7 -7
- package/lib/mutations/RelayRecordSourceProxy.js +12 -12
- package/lib/mutations/RelayRecordSourceSelectorProxy.js +9 -9
- package/lib/mutations/applyOptimisticMutation.js +9 -9
- package/lib/mutations/commitLocalUpdate.js +1 -1
- package/lib/mutations/commitMutation.js +15 -15
- package/lib/mutations/createUpdatableProxy.js +13 -13
- package/lib/mutations/readUpdatableFragment.js +6 -6
- package/lib/mutations/readUpdatableQuery.js +3 -3
- package/lib/mutations/validateMutation.js +9 -7
- package/lib/network/ConvertToExecuteFunction.js +2 -2
- package/lib/network/RelayNetwork.js +8 -8
- package/lib/network/RelayNetworkTypes.js +1 -1
- package/lib/network/RelayObservable.js +23 -22
- package/lib/network/RelayQueryResponseCache.js +5 -5
- package/lib/network/wrapNetworkWithLogObserver.js +8 -8
- package/lib/query/GraphQLTag.js +16 -16
- package/lib/query/PreloadableQueryRegistry.js +1 -1
- package/lib/query/fetchQuery.js +13 -13
- package/lib/query/fetchQueryInternal.js +8 -8
- package/lib/query/fetchQuery_DEPRECATED.js +5 -5
- package/lib/store/ClientID.js +7 -7
- package/lib/store/DataChecker.js +29 -25
- package/lib/store/OperationExecutor.js +87 -87
- package/lib/store/RelayConcreteVariables.js +6 -6
- package/lib/store/RelayExperimentalGraphResponseHandler.js +12 -12
- package/lib/store/RelayExperimentalGraphResponseTransform.js +16 -16
- package/lib/store/RelayModernEnvironment.js +21 -21
- package/lib/store/RelayModernFragmentSpecResolver.js +16 -16
- package/lib/store/RelayModernOperationDescriptor.js +6 -6
- package/lib/store/RelayModernRecord.js +23 -23
- package/lib/store/RelayModernSelector.js +23 -23
- package/lib/store/RelayModernStore.js +35 -35
- package/lib/store/RelayOperationTracker.js +3 -3
- package/lib/store/RelayOptimisticRecordSource.js +8 -8
- package/lib/store/RelayPublishQueue.js +22 -22
- package/lib/store/RelayReader.js +48 -50
- package/lib/store/RelayRecordSource.js +3 -3
- package/lib/store/RelayRecordState.js +4 -4
- package/lib/store/RelayReferenceMarker.js +18 -14
- package/lib/store/RelayResponseNormalizer.js +40 -36
- package/lib/store/RelayStoreSubscriptions.js +8 -8
- package/lib/store/RelayStoreTypes.js +1 -1
- package/lib/store/RelayStoreUtils.js +40 -35
- package/lib/store/ResolverCache.js +16 -16
- package/lib/store/ResolverFragments.js +6 -6
- package/lib/store/StoreInspector.js +16 -16
- package/lib/store/TypeID.js +3 -3
- package/lib/store/ViewerPattern.js +5 -5
- package/lib/store/cloneRelayHandleSourceField.js +6 -6
- package/lib/store/cloneRelayScalarHandleSourceField.js +6 -6
- package/lib/store/createFragmentSpecResolver.js +3 -3
- package/lib/store/createRelayContext.js +4 -4
- package/lib/store/defaultGetDataID.js +2 -2
- package/lib/store/defaultRequiredFieldLogger.js +3 -3
- package/lib/store/experimental-live-resolvers/LiveResolverCache.js +33 -33
- package/lib/store/experimental-live-resolvers/LiveResolverStore.js +36 -36
- package/lib/store/experimental-live-resolvers/LiveResolverSuspenseSentinel.js +1 -1
- package/lib/store/experimental-live-resolvers/getOutputTypeRecordIDs.js +5 -5
- package/lib/store/experimental-live-resolvers/isLiveStateValue.js +2 -2
- package/lib/store/experimental-live-resolvers/resolverDataInjector.js +6 -6
- package/lib/store/experimental-live-resolvers/weakObjectWrapper.js +6 -6
- package/lib/store/hasOverlappingIDs.js +1 -1
- package/lib/store/hasSignificantOverlappingIDs.js +3 -3
- package/lib/store/isRelayModernEnvironment.js +2 -2
- package/lib/store/normalizeResponse.js +1 -1
- package/lib/store/readInlineData.js +6 -6
- package/lib/subscription/requestSubscription.js +9 -9
- 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 +36 -36
- package/lib/util/RelayDefaultHandleKey.js +2 -2
- package/lib/util/RelayError.js +3 -3
- package/lib/util/RelayFeatureFlags.js +1 -1
- package/lib/util/RelayProfiler.js +1 -1
- package/lib/util/RelayReplaySubject.js +10 -10
- package/lib/util/RelayRuntimeTypes.js +1 -1
- package/lib/util/StringInterner.js +3 -3
- package/lib/util/createPayloadFor3DField.js +2 -2
- package/lib/util/deepFreeze.js +3 -3
- package/lib/util/generateID.js +1 -1
- package/lib/util/getFragmentIdentifier.js +12 -12
- package/lib/util/getOperation.js +2 -2
- package/lib/util/getPaginationMetadata.js +6 -6
- package/lib/util/getPaginationVariables.js +9 -9
- package/lib/util/getPendingOperationsForFragment.js +5 -5
- package/lib/util/getRefetchMetadata.js +7 -7
- package/lib/util/getRelayHandleKey.js +4 -4
- package/lib/util/getRequestIdentifier.js +4 -4
- package/lib/util/getValueAtPath.js +5 -5
- package/lib/util/handlePotentialSnapshotErrors.js +6 -6
- package/lib/util/isEmptyObject.js +1 -1
- package/lib/util/isPromise.js +2 -2
- package/lib/util/isScalarAndEqual.js +2 -2
- package/lib/util/recycleNodesInto.js +6 -20
- package/lib/util/registerEnvironmentWithDevTools.js +2 -2
- package/lib/util/resolveImmediate.js +1 -1
- package/lib/util/stableCopy.js +2 -2
- package/lib/util/withDuration.js +2 -2
- package/lib/util/withProvidedVariables.js +3 -3
- package/mutations/validateMutation.js.flow +2 -0
- package/network/RelayObservable.js.flow +3 -2
- package/package.json +1 -1
- package/relay-runtime-experimental.js +2 -2
- package/relay-runtime-experimental.min.js +2 -2
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/DataChecker.js.flow +9 -1
- package/store/RelayModernSelector.js.flow +6 -3
- package/store/RelayReader.js.flow +7 -7
- package/store/RelayReferenceMarker.js.flow +6 -1
- package/store/RelayResponseNormalizer.js.flow +6 -1
- package/store/RelayStoreTypes.js.flow +7 -1
- package/store/RelayStoreUtils.js.flow +22 -7
- package/store/experimental-live-resolvers/resolverDataInjector.js.flow +1 -0
- package/store/experimental-live-resolvers/weakObjectWrapper.js.flow +1 -0
- package/util/NormalizationNode.js.flow +15 -2
- package/util/ReaderNode.js.flow +1 -1
- package/util/createPayloadFor3DField.js.flow +1 -0
- package/util/recycleNodesInto.js.flow +8 -30
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
5
5
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
6
|
-
var RelayObservable = require(
|
|
7
|
-
var generateID = require(
|
|
8
|
-
var getOperation = require(
|
|
9
|
-
var RelayError = require(
|
|
10
|
-
var RelayFeatureFlags = require(
|
|
11
|
-
var stableCopy = require(
|
|
12
|
-
var withDuration = require(
|
|
13
|
-
var _require = require(
|
|
6
|
+
var RelayObservable = require('../network/RelayObservable');
|
|
7
|
+
var generateID = require('../util/generateID');
|
|
8
|
+
var getOperation = require('../util/getOperation');
|
|
9
|
+
var RelayError = require('../util/RelayError');
|
|
10
|
+
var RelayFeatureFlags = require('../util/RelayFeatureFlags');
|
|
11
|
+
var stableCopy = require('../util/stableCopy');
|
|
12
|
+
var withDuration = require('../util/withDuration');
|
|
13
|
+
var _require = require('./ClientID'),
|
|
14
14
|
generateClientID = _require.generateClientID,
|
|
15
15
|
generateUniqueClientID = _require.generateUniqueClientID;
|
|
16
|
-
var _require2 = require(
|
|
16
|
+
var _require2 = require('./RelayConcreteVariables'),
|
|
17
17
|
getLocalVariables = _require2.getLocalVariables;
|
|
18
|
-
var RelayModernRecord = require(
|
|
19
|
-
var _require3 = require(
|
|
18
|
+
var RelayModernRecord = require('./RelayModernRecord');
|
|
19
|
+
var _require3 = require('./RelayModernSelector'),
|
|
20
20
|
createNormalizationSelector = _require3.createNormalizationSelector,
|
|
21
21
|
createReaderSelector = _require3.createReaderSelector;
|
|
22
|
-
var RelayRecordSource = require(
|
|
23
|
-
var _require4 = require(
|
|
22
|
+
var RelayRecordSource = require('./RelayRecordSource');
|
|
23
|
+
var _require4 = require('./RelayStoreUtils'),
|
|
24
24
|
ROOT_TYPE = _require4.ROOT_TYPE,
|
|
25
25
|
TYPENAME_KEY = _require4.TYPENAME_KEY,
|
|
26
26
|
getStorageKey = _require4.getStorageKey;
|
|
27
|
-
var invariant = require(
|
|
27
|
+
var invariant = require('invariant');
|
|
28
28
|
var warning = require("fbjs/lib/warning");
|
|
29
29
|
function execute(config) {
|
|
30
30
|
return new Executor(config);
|
|
@@ -69,12 +69,12 @@ var Executor = /*#__PURE__*/function () {
|
|
|
69
69
|
this._scheduler = scheduler;
|
|
70
70
|
this._sink = sink;
|
|
71
71
|
this._source = new Map();
|
|
72
|
-
this._state =
|
|
72
|
+
this._state = 'started';
|
|
73
73
|
this._getStore = getStore;
|
|
74
74
|
this._subscriptions = new Map();
|
|
75
75
|
this._updater = updater;
|
|
76
76
|
this._isClientPayload = isClientPayload === true;
|
|
77
|
-
this._isSubscriptionOperation = this._operation.request.node.params.operationKind ===
|
|
77
|
+
this._isSubscriptionOperation = this._operation.request.node.params.operationKind === 'subscription';
|
|
78
78
|
this._shouldProcessClientComponents = shouldProcessClientComponents;
|
|
79
79
|
this._retainDisposables = new Map();
|
|
80
80
|
this._seenActors = new Set();
|
|
@@ -99,7 +99,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
99
99
|
var _this$_operation$requ;
|
|
100
100
|
_this._start(id, subscription);
|
|
101
101
|
_this._log({
|
|
102
|
-
name:
|
|
102
|
+
name: 'execute.start',
|
|
103
103
|
executeId: _this._executeId,
|
|
104
104
|
params: _this._operation.request.node.params,
|
|
105
105
|
variables: _this._operation.request.variables,
|
|
@@ -116,10 +116,10 @@ var Executor = /*#__PURE__*/function () {
|
|
|
116
116
|
var _proto = Executor.prototype;
|
|
117
117
|
_proto.cancel = function cancel() {
|
|
118
118
|
var _this2 = this;
|
|
119
|
-
if (this._state ===
|
|
119
|
+
if (this._state === 'completed') {
|
|
120
120
|
return;
|
|
121
121
|
}
|
|
122
|
-
this._state =
|
|
122
|
+
this._state = 'completed';
|
|
123
123
|
this._operationExecutions["delete"](this._operation.request.identifier);
|
|
124
124
|
if (this._subscriptions.size !== 0) {
|
|
125
125
|
this._subscriptions.forEach(function (sub) {
|
|
@@ -147,29 +147,29 @@ var Executor = /*#__PURE__*/function () {
|
|
|
147
147
|
_proto._updateActiveState = function _updateActiveState() {
|
|
148
148
|
var activeState;
|
|
149
149
|
switch (this._state) {
|
|
150
|
-
case
|
|
150
|
+
case 'started':
|
|
151
151
|
{
|
|
152
|
-
activeState =
|
|
152
|
+
activeState = 'active';
|
|
153
153
|
break;
|
|
154
154
|
}
|
|
155
|
-
case
|
|
155
|
+
case 'loading_incremental':
|
|
156
156
|
{
|
|
157
|
-
activeState =
|
|
157
|
+
activeState = 'active';
|
|
158
158
|
break;
|
|
159
159
|
}
|
|
160
|
-
case
|
|
160
|
+
case 'completed':
|
|
161
161
|
{
|
|
162
|
-
activeState =
|
|
162
|
+
activeState = 'inactive';
|
|
163
163
|
break;
|
|
164
164
|
}
|
|
165
|
-
case
|
|
165
|
+
case 'loading_final':
|
|
166
166
|
{
|
|
167
|
-
activeState = this._pendingModulePayloadsCount > 0 ?
|
|
167
|
+
activeState = this._pendingModulePayloadsCount > 0 ? 'active' : 'inactive';
|
|
168
168
|
break;
|
|
169
169
|
}
|
|
170
170
|
default:
|
|
171
171
|
this._state;
|
|
172
|
-
!false ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
172
|
+
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: invalid executor state.') : invariant(false) : void 0;
|
|
173
173
|
}
|
|
174
174
|
this._operationExecutions.set(this._operation.request.identifier, activeState);
|
|
175
175
|
};
|
|
@@ -211,7 +211,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
211
211
|
this.cancel();
|
|
212
212
|
this._sink.complete();
|
|
213
213
|
this._log({
|
|
214
|
-
name:
|
|
214
|
+
name: 'execute.complete',
|
|
215
215
|
executeId: this._executeId
|
|
216
216
|
});
|
|
217
217
|
}
|
|
@@ -220,7 +220,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
220
220
|
this.cancel();
|
|
221
221
|
this._sink.error(error);
|
|
222
222
|
this._log({
|
|
223
|
-
name:
|
|
223
|
+
name: 'execute.error',
|
|
224
224
|
executeId: this._executeId,
|
|
225
225
|
error: error
|
|
226
226
|
});
|
|
@@ -238,7 +238,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
238
238
|
}),
|
|
239
239
|
duration = _withDuration[0];
|
|
240
240
|
_this4._log({
|
|
241
|
-
name:
|
|
241
|
+
name: 'execute.next',
|
|
242
242
|
executeId: _this4._executeId,
|
|
243
243
|
response: response,
|
|
244
244
|
duration: duration
|
|
@@ -249,15 +249,15 @@ var Executor = /*#__PURE__*/function () {
|
|
|
249
249
|
var _this5 = this;
|
|
250
250
|
var results = [];
|
|
251
251
|
responses.forEach(function (response) {
|
|
252
|
-
if (response.data === null && response.extensions != null && !response.hasOwnProperty(
|
|
252
|
+
if (response.data === null && response.extensions != null && !response.hasOwnProperty('errors')) {
|
|
253
253
|
return;
|
|
254
254
|
} else if (response.data == null) {
|
|
255
|
-
var errors = response.hasOwnProperty(
|
|
255
|
+
var errors = response.hasOwnProperty('errors') && response.errors != null ? response.errors : null;
|
|
256
256
|
var messages = errors ? errors.map(function (_ref3) {
|
|
257
257
|
var message = _ref3.message;
|
|
258
258
|
return message;
|
|
259
|
-
}).join(
|
|
260
|
-
var error = RelayError.create(
|
|
259
|
+
}).join('\n') : '(No errors)';
|
|
260
|
+
var error = RelayError.create('RelayNetwork', 'No data returned for operation `' + _this5._operation.request.node.params.name + '`, got error(s):\n' + messages + '\n\nSee the error `source` property for more information.');
|
|
261
261
|
error.source = {
|
|
262
262
|
errors: errors,
|
|
263
263
|
operation: _this5._operation.request.node,
|
|
@@ -279,14 +279,14 @@ var Executor = /*#__PURE__*/function () {
|
|
|
279
279
|
var _responsePart$extensi;
|
|
280
280
|
return ((_responsePart$extensi = responsePart.extensions) === null || _responsePart$extensi === void 0 ? void 0 : _responsePart$extensi.isOptimistic) === true;
|
|
281
281
|
})) {
|
|
282
|
-
!false ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
282
|
+
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Optimistic responses cannot be batched.') : invariant(false) : void 0;
|
|
283
283
|
}
|
|
284
284
|
return false;
|
|
285
285
|
}
|
|
286
286
|
var response = responses[0];
|
|
287
287
|
var isOptimistic = ((_response$extensions = response.extensions) === null || _response$extensions === void 0 ? void 0 : _response$extensions.isOptimistic) === true;
|
|
288
|
-
if (isOptimistic && this._state !==
|
|
289
|
-
!false ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
288
|
+
if (isOptimistic && this._state !== 'started') {
|
|
289
|
+
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: optimistic payload received after server payload.') : invariant(false) : void 0;
|
|
290
290
|
}
|
|
291
291
|
if (isOptimistic) {
|
|
292
292
|
this._processOptimisticResponse(response, null, this._treatMissingFieldsAsNull);
|
|
@@ -296,7 +296,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
296
296
|
return false;
|
|
297
297
|
};
|
|
298
298
|
_proto._handleNext = function _handleNext(response) {
|
|
299
|
-
if (this._state ===
|
|
299
|
+
if (this._state === 'completed') {
|
|
300
300
|
return;
|
|
301
301
|
}
|
|
302
302
|
this._seenActors.clear();
|
|
@@ -308,7 +308,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
308
308
|
return ((_x$extensions = x.extensions) === null || _x$extensions === void 0 ? void 0 : _x$extensions.is_final) === true;
|
|
309
309
|
});
|
|
310
310
|
if (isFinal) {
|
|
311
|
-
this._state =
|
|
311
|
+
this._state = 'loading_final';
|
|
312
312
|
this._updateActiveState();
|
|
313
313
|
this._incrementalPayloadsPending = false;
|
|
314
314
|
}
|
|
@@ -359,7 +359,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
359
359
|
};
|
|
360
360
|
_proto._processOptimisticResponse = function _processOptimisticResponse(response, updater, treatMissingFieldsAsNull) {
|
|
361
361
|
var _this6 = this;
|
|
362
|
-
!(this._optimisticUpdates === null) ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
362
|
+
!(this._optimisticUpdates === null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: environment.execute: only support one optimistic response per ' + 'execute.') : invariant(false) : void 0;
|
|
363
363
|
if (response == null && updater == null) {
|
|
364
364
|
return;
|
|
365
365
|
}
|
|
@@ -411,7 +411,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
411
411
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
412
412
|
var followupPayload = _step.value;
|
|
413
413
|
switch (followupPayload.kind) {
|
|
414
|
-
case
|
|
414
|
+
case 'ModuleImportPayload':
|
|
415
415
|
var operationLoader = this._expectOperationLoader();
|
|
416
416
|
var operation = operationLoader.get(followupPayload.operationReference);
|
|
417
417
|
if (operation == null) {
|
|
@@ -421,12 +421,12 @@ var Executor = /*#__PURE__*/function () {
|
|
|
421
421
|
optimisticUpdates.push.apply(optimisticUpdates, (0, _toConsumableArray2["default"])(moduleImportOptimisticUpdates));
|
|
422
422
|
}
|
|
423
423
|
break;
|
|
424
|
-
case
|
|
425
|
-
process.env.NODE_ENV !== "production" ? warning(false,
|
|
424
|
+
case 'ActorPayload':
|
|
425
|
+
process.env.NODE_ENV !== "production" ? warning(false, 'OperationExecutor: Unexpected optimistic ActorPayload. These updates are not supported.') : void 0;
|
|
426
426
|
break;
|
|
427
427
|
default:
|
|
428
428
|
followupPayload;
|
|
429
|
-
!false ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
429
|
+
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Unexpected followup kind `%s`. when processing optimistic updates.', followupPayload.kind) : invariant(false) : void 0;
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
432
|
} catch (err) {
|
|
@@ -438,7 +438,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
438
438
|
};
|
|
439
439
|
_proto._normalizeFollowupPayload = function _normalizeFollowupPayload(followupPayload, normalizationNode) {
|
|
440
440
|
var variables;
|
|
441
|
-
if (normalizationNode.kind ===
|
|
441
|
+
if (normalizationNode.kind === 'SplitOperation' && followupPayload.kind === 'ModuleImportPayload') {
|
|
442
442
|
variables = getLocalVariables(followupPayload.variables, normalizationNode.argumentDefinitions, followupPayload.args);
|
|
443
443
|
} else {
|
|
444
444
|
variables = followupPayload.variables;
|
|
@@ -470,7 +470,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
470
470
|
_proto._processAsyncOptimisticModuleImport = function _processAsyncOptimisticModuleImport(moduleImportPayload) {
|
|
471
471
|
var _this7 = this;
|
|
472
472
|
this._expectOperationLoader().load(moduleImportPayload.operationReference).then(function (operation) {
|
|
473
|
-
if (operation == null || _this7._state !==
|
|
473
|
+
if (operation == null || _this7._state !== 'started') {
|
|
474
474
|
return;
|
|
475
475
|
}
|
|
476
476
|
var moduleImportOptimisticUpdates = _this7._processOptimisticModuleImport(operation, moduleImportPayload);
|
|
@@ -478,7 +478,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
478
478
|
return _this7._getPublishQueueAndSaveActor().applyUpdate(update);
|
|
479
479
|
});
|
|
480
480
|
if (_this7._optimisticUpdates == null) {
|
|
481
|
-
process.env.NODE_ENV !== "production" ? warning(false,
|
|
481
|
+
process.env.NODE_ENV !== "production" ? warning(false, 'OperationExecutor: Unexpected ModuleImport optimistic ' + 'update in operation %s.' + _this7._operation.request.node.params.name) : void 0;
|
|
482
482
|
} else {
|
|
483
483
|
var _this$_optimisticUpda;
|
|
484
484
|
(_this$_optimisticUpda = _this7._optimisticUpdates).push.apply(_this$_optimisticUpda, (0, _toConsumableArray2["default"])(moduleImportOptimisticUpdates));
|
|
@@ -511,14 +511,14 @@ var Executor = /*#__PURE__*/function () {
|
|
|
511
511
|
};
|
|
512
512
|
_proto._processPayloadFollowups = function _processPayloadFollowups(payloads) {
|
|
513
513
|
var _this9 = this;
|
|
514
|
-
if (this._state ===
|
|
514
|
+
if (this._state === 'completed') {
|
|
515
515
|
return;
|
|
516
516
|
}
|
|
517
517
|
payloads.forEach(function (payload) {
|
|
518
518
|
var incrementalPlaceholders = payload.incrementalPlaceholders,
|
|
519
519
|
followupPayloads = payload.followupPayloads,
|
|
520
520
|
isFinal = payload.isFinal;
|
|
521
|
-
_this9._state = isFinal ?
|
|
521
|
+
_this9._state = isFinal ? 'loading_final' : 'loading_incremental';
|
|
522
522
|
_this9._updateActiveState();
|
|
523
523
|
if (isFinal) {
|
|
524
524
|
_this9._incrementalPayloadsPending = false;
|
|
@@ -533,7 +533,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
533
533
|
});
|
|
534
534
|
}
|
|
535
535
|
if (incrementalPlaceholders && incrementalPlaceholders.length !== 0) {
|
|
536
|
-
_this9._incrementalPayloadsPending = _this9._state !==
|
|
536
|
+
_this9._incrementalPayloadsPending = _this9._state !== 'loading_final';
|
|
537
537
|
incrementalPlaceholders.forEach(function (incrementalPlaceholder) {
|
|
538
538
|
var _incrementalPlacehold;
|
|
539
539
|
var prevActorIdentifier = _this9._actorIdentifier;
|
|
@@ -541,11 +541,11 @@ var Executor = /*#__PURE__*/function () {
|
|
|
541
541
|
_this9._processIncrementalPlaceholder(payload, incrementalPlaceholder);
|
|
542
542
|
_this9._actorIdentifier = prevActorIdentifier;
|
|
543
543
|
});
|
|
544
|
-
if (_this9._isClientPayload || _this9._state ===
|
|
545
|
-
process.env.NODE_ENV !== "production" ? warning(_this9._isClientPayload,
|
|
544
|
+
if (_this9._isClientPayload || _this9._state === 'loading_final') {
|
|
545
|
+
process.env.NODE_ENV !== "production" ? warning(_this9._isClientPayload, 'RelayModernEnvironment: Operation `%s` contains @defer/@stream ' + 'directives but was executed in non-streaming mode. See ' + 'https://fburl.com/relay-incremental-delivery-non-streaming-warning.', _this9._operation.request.node.params.name) : void 0;
|
|
546
546
|
var relayPayloads = [];
|
|
547
547
|
incrementalPlaceholders.forEach(function (placeholder) {
|
|
548
|
-
if (placeholder.kind ===
|
|
548
|
+
if (placeholder.kind === 'defer') {
|
|
549
549
|
relayPayloads.push(_this9._processDeferResponse(placeholder.label, placeholder.path, placeholder, {
|
|
550
550
|
data: placeholder.data
|
|
551
551
|
}));
|
|
@@ -569,7 +569,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
569
569
|
_proto._processFollowupPayload = function _processFollowupPayload(followupPayload) {
|
|
570
570
|
var _this10 = this;
|
|
571
571
|
switch (followupPayload.kind) {
|
|
572
|
-
case
|
|
572
|
+
case 'ModuleImportPayload':
|
|
573
573
|
var operationLoader = this._expectOperationLoader();
|
|
574
574
|
var node = operationLoader.get(followupPayload.operationReference);
|
|
575
575
|
if (node != null) {
|
|
@@ -605,7 +605,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
605
605
|
}),
|
|
606
606
|
duration = _withDuration2[0];
|
|
607
607
|
_this10._log({
|
|
608
|
-
name:
|
|
608
|
+
name: 'execute.async.module',
|
|
609
609
|
executeId: _this10._executeId,
|
|
610
610
|
operationName: operation.name,
|
|
611
611
|
duration: duration
|
|
@@ -650,12 +650,12 @@ var Executor = /*#__PURE__*/function () {
|
|
|
650
650
|
});
|
|
651
651
|
}
|
|
652
652
|
break;
|
|
653
|
-
case
|
|
653
|
+
case 'ActorPayload':
|
|
654
654
|
this._processFollowupPayloadWithNormalizationNode(followupPayload, followupPayload.node);
|
|
655
655
|
break;
|
|
656
656
|
default:
|
|
657
657
|
followupPayload;
|
|
658
|
-
!false ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
658
|
+
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Unexpected followup kind `%s`.', followupPayload.kind) : invariant(false) : void 0;
|
|
659
659
|
}
|
|
660
660
|
};
|
|
661
661
|
_proto._processFollowupPayloadWithNormalizationNode = function _processFollowupPayloadWithNormalizationNode(followupPayload, normalizationNode) {
|
|
@@ -671,33 +671,33 @@ var Executor = /*#__PURE__*/function () {
|
|
|
671
671
|
var _relayPayload$fieldPa;
|
|
672
672
|
var label = placeholder.label,
|
|
673
673
|
path = placeholder.path;
|
|
674
|
-
var pathKey = path.map(String).join(
|
|
674
|
+
var pathKey = path.map(String).join('.');
|
|
675
675
|
var resultForLabel = this._incrementalResults.get(label);
|
|
676
676
|
if (resultForLabel == null) {
|
|
677
677
|
resultForLabel = new Map();
|
|
678
678
|
this._incrementalResults.set(label, resultForLabel);
|
|
679
679
|
}
|
|
680
680
|
var resultForPath = resultForLabel.get(pathKey);
|
|
681
|
-
var pendingResponses = resultForPath != null && resultForPath.kind ===
|
|
681
|
+
var pendingResponses = resultForPath != null && resultForPath.kind === 'response' ? resultForPath.responses : null;
|
|
682
682
|
resultForLabel.set(pathKey, {
|
|
683
|
-
kind:
|
|
683
|
+
kind: 'placeholder',
|
|
684
684
|
placeholder: placeholder
|
|
685
685
|
});
|
|
686
686
|
var parentID;
|
|
687
|
-
if (placeholder.kind ===
|
|
687
|
+
if (placeholder.kind === 'stream') {
|
|
688
688
|
parentID = placeholder.parentID;
|
|
689
|
-
} else if (placeholder.kind ===
|
|
689
|
+
} else if (placeholder.kind === 'defer') {
|
|
690
690
|
parentID = placeholder.selector.dataID;
|
|
691
691
|
} else {
|
|
692
692
|
placeholder;
|
|
693
|
-
!false ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
693
|
+
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Unsupported incremental placeholder kind `%s`.', placeholder.kind) : invariant(false) : void 0;
|
|
694
694
|
}
|
|
695
695
|
var parentRecord = relayPayload.source.get(parentID);
|
|
696
696
|
var parentPayloads = ((_relayPayload$fieldPa = relayPayload.fieldPayloads) !== null && _relayPayload$fieldPa !== void 0 ? _relayPayload$fieldPa : []).filter(function (fieldPayload) {
|
|
697
697
|
var fieldID = generateClientID(fieldPayload.dataID, fieldPayload.fieldKey);
|
|
698
698
|
return fieldPayload.dataID === parentID || fieldID === parentID;
|
|
699
699
|
});
|
|
700
|
-
!(parentRecord != null) ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
700
|
+
!(parentRecord != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Expected record `%s` to exist.', parentID) : invariant(false) : void 0;
|
|
701
701
|
var nextParentRecord;
|
|
702
702
|
var nextParentPayloads;
|
|
703
703
|
var previousParentEntry = this._source.get(parentID);
|
|
@@ -736,39 +736,39 @@ var Executor = /*#__PURE__*/function () {
|
|
|
736
736
|
resultForLabel = new Map();
|
|
737
737
|
_this11._incrementalResults.set(label, resultForLabel);
|
|
738
738
|
}
|
|
739
|
-
if (label.indexOf(
|
|
740
|
-
var pathKey = path.map(String).join(
|
|
739
|
+
if (label.indexOf('$defer$') !== -1) {
|
|
740
|
+
var pathKey = path.map(String).join('.');
|
|
741
741
|
var resultForPath = resultForLabel.get(pathKey);
|
|
742
742
|
if (resultForPath == null) {
|
|
743
743
|
resultForPath = {
|
|
744
|
-
kind:
|
|
744
|
+
kind: 'response',
|
|
745
745
|
responses: [incrementalResponse]
|
|
746
746
|
};
|
|
747
747
|
resultForLabel.set(pathKey, resultForPath);
|
|
748
748
|
return;
|
|
749
|
-
} else if (resultForPath.kind ===
|
|
749
|
+
} else if (resultForPath.kind === 'response') {
|
|
750
750
|
resultForPath.responses.push(incrementalResponse);
|
|
751
751
|
return;
|
|
752
752
|
}
|
|
753
753
|
var placeholder = resultForPath.placeholder;
|
|
754
|
-
!(placeholder.kind ===
|
|
754
|
+
!(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;
|
|
755
755
|
relayPayloads.push(_this11._processDeferResponse(label, path, placeholder, response));
|
|
756
756
|
} else {
|
|
757
|
-
var _pathKey = path.slice(0, -2).map(String).join(
|
|
757
|
+
var _pathKey = path.slice(0, -2).map(String).join('.');
|
|
758
758
|
var _resultForPath = resultForLabel.get(_pathKey);
|
|
759
759
|
if (_resultForPath == null) {
|
|
760
760
|
_resultForPath = {
|
|
761
|
-
kind:
|
|
761
|
+
kind: 'response',
|
|
762
762
|
responses: [incrementalResponse]
|
|
763
763
|
};
|
|
764
764
|
resultForLabel.set(_pathKey, _resultForPath);
|
|
765
765
|
return;
|
|
766
|
-
} else if (_resultForPath.kind ===
|
|
766
|
+
} else if (_resultForPath.kind === 'response') {
|
|
767
767
|
_resultForPath.responses.push(incrementalResponse);
|
|
768
768
|
return;
|
|
769
769
|
}
|
|
770
770
|
var _placeholder = _resultForPath.placeholder;
|
|
771
|
-
!(_placeholder.kind ===
|
|
771
|
+
!(_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;
|
|
772
772
|
relayPayloads.push(_this11._processStreamResponse(label, path, _placeholder, response));
|
|
773
773
|
}
|
|
774
774
|
});
|
|
@@ -788,7 +788,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
788
788
|
});
|
|
789
789
|
this._getPublishQueueAndSaveActor().commitPayload(this._operation, relayPayload);
|
|
790
790
|
var parentEntry = this._source.get(parentID);
|
|
791
|
-
!(parentEntry != null) ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
791
|
+
!(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;
|
|
792
792
|
var fieldPayloads = parentEntry.fieldPayloads;
|
|
793
793
|
if (fieldPayloads.length !== 0) {
|
|
794
794
|
var _response$extensions2;
|
|
@@ -813,7 +813,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
813
813
|
var prevActorIdentifier = this._actorIdentifier;
|
|
814
814
|
this._actorIdentifier = actorIdentifier !== null && actorIdentifier !== void 0 ? actorIdentifier : this._actorIdentifier;
|
|
815
815
|
var field = node.selections[0];
|
|
816
|
-
!(field != null && field.kind ===
|
|
816
|
+
!(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;
|
|
817
817
|
var _this$_normalizeStrea = this._normalizeStreamItem(response, parentID, field, variables, path, placeholder.path),
|
|
818
818
|
fieldPayloads = _this$_normalizeStrea.fieldPayloads,
|
|
819
819
|
itemID = _this$_normalizeStrea.itemID,
|
|
@@ -856,22 +856,22 @@ var Executor = /*#__PURE__*/function () {
|
|
|
856
856
|
_proto._normalizeStreamItem = function _normalizeStreamItem(response, parentID, field, variables, path, normalizationPath) {
|
|
857
857
|
var _field$alias, _field$concreteType, _ref, _this$_getDataID;
|
|
858
858
|
var data = response.data;
|
|
859
|
-
!(typeof data ===
|
|
859
|
+
!(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;
|
|
860
860
|
var responseKey = (_field$alias = field.alias) !== null && _field$alias !== void 0 ? _field$alias : field.name;
|
|
861
861
|
var storageKey = getStorageKey(field, variables);
|
|
862
862
|
var parentEntry = this._source.get(parentID);
|
|
863
|
-
!(parentEntry != null) ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
863
|
+
!(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;
|
|
864
864
|
var parentRecord = parentEntry.record,
|
|
865
865
|
fieldPayloads = parentEntry.fieldPayloads;
|
|
866
866
|
var prevIDs = RelayModernRecord.getLinkedRecordIDs(parentRecord, storageKey);
|
|
867
|
-
!(prevIDs != null) ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
867
|
+
!(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;
|
|
868
868
|
var finalPathEntry = path[path.length - 1];
|
|
869
869
|
var itemIndex = parseInt(finalPathEntry, 10);
|
|
870
|
-
!(itemIndex === finalPathEntry && itemIndex >= 0) ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
870
|
+
!(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;
|
|
871
871
|
var typeName = (_field$concreteType = field.concreteType) !== null && _field$concreteType !== void 0 ? _field$concreteType : data[TYPENAME_KEY];
|
|
872
|
-
!(typeof typeName ===
|
|
872
|
+
!(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;
|
|
873
873
|
var itemID = (_ref = (_this$_getDataID = this._getDataID(data, typeName)) !== null && _this$_getDataID !== void 0 ? _this$_getDataID : prevIDs === null || prevIDs === void 0 ? void 0 : prevIDs[itemIndex]) !== null && _ref !== void 0 ? _ref : generateClientID(parentID, storageKey, itemIndex);
|
|
874
|
-
!(typeof itemID ===
|
|
874
|
+
!(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;
|
|
875
875
|
var selector = createNormalizationSelector(field, itemID, variables);
|
|
876
876
|
var nextParentRecord = RelayModernRecord.clone(parentRecord);
|
|
877
877
|
var nextIDs = (0, _toConsumableArray2["default"])(prevIDs);
|
|
@@ -993,7 +993,7 @@ var Executor = /*#__PURE__*/function () {
|
|
|
993
993
|
};
|
|
994
994
|
_proto._expectOperationLoader = function _expectOperationLoader() {
|
|
995
995
|
var operationLoader = this._operationLoader;
|
|
996
|
-
!operationLoader ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
996
|
+
!operationLoader ? process.env.NODE_ENV !== "production" ? invariant(false, 'OperationExecutor: Expected an operationLoader to be ' + 'configured when using `@match`.') : invariant(false) : void 0;
|
|
997
997
|
return operationLoader;
|
|
998
998
|
};
|
|
999
999
|
return Executor;
|
|
@@ -1006,7 +1006,7 @@ function partitionGraphQLResponses(responses) {
|
|
|
1006
1006
|
var label = response.label,
|
|
1007
1007
|
path = response.path;
|
|
1008
1008
|
if (label == null || path == null) {
|
|
1009
|
-
!false ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
1009
|
+
!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;
|
|
1010
1010
|
}
|
|
1011
1011
|
incrementalResponses.push({
|
|
1012
1012
|
label: label,
|
|
@@ -1021,12 +1021,12 @@ function partitionGraphQLResponses(responses) {
|
|
|
1021
1021
|
}
|
|
1022
1022
|
function stableStringify(value) {
|
|
1023
1023
|
var _JSON$stringify;
|
|
1024
|
-
return (_JSON$stringify = JSON.stringify(stableCopy(value))) !== null && _JSON$stringify !== void 0 ? _JSON$stringify :
|
|
1024
|
+
return (_JSON$stringify = JSON.stringify(stableCopy(value))) !== null && _JSON$stringify !== void 0 ? _JSON$stringify : '';
|
|
1025
1025
|
}
|
|
1026
1026
|
function validateOptimisticResponsePayload(payload) {
|
|
1027
1027
|
var incrementalPlaceholders = payload.incrementalPlaceholders;
|
|
1028
1028
|
if (incrementalPlaceholders != null && incrementalPlaceholders.length !== 0) {
|
|
1029
|
-
!false ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
1029
|
+
!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;
|
|
1030
1030
|
}
|
|
1031
1031
|
}
|
|
1032
1032
|
module.exports = {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
5
|
-
var _require = require(
|
|
5
|
+
var _require = require('./RelayStoreUtils'),
|
|
6
6
|
getArgumentValues = _require.getArgumentValues;
|
|
7
|
-
var invariant = require(
|
|
7
|
+
var invariant = require('invariant');
|
|
8
8
|
function getFragmentVariables(fragment, rootVariables, argumentVariables) {
|
|
9
9
|
if (fragment.argumentDefinitions == null) {
|
|
10
10
|
return argumentVariables;
|
|
@@ -16,10 +16,10 @@ function getFragmentVariables(fragment, rootVariables, argumentVariables) {
|
|
|
16
16
|
}
|
|
17
17
|
variables = variables || (0, _objectSpread2["default"])({}, argumentVariables);
|
|
18
18
|
switch (definition.kind) {
|
|
19
|
-
case
|
|
19
|
+
case 'LocalArgument':
|
|
20
20
|
variables[definition.name] = definition.defaultValue;
|
|
21
21
|
break;
|
|
22
|
-
case
|
|
22
|
+
case 'RootArgument':
|
|
23
23
|
if (!rootVariables.hasOwnProperty(definition.name)) {
|
|
24
24
|
variables[definition.name] = undefined;
|
|
25
25
|
break;
|
|
@@ -28,7 +28,7 @@ function getFragmentVariables(fragment, rootVariables, argumentVariables) {
|
|
|
28
28
|
break;
|
|
29
29
|
default:
|
|
30
30
|
definition;
|
|
31
|
-
!false ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
31
|
+
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayConcreteVariables: Unexpected node kind `%s` in fragment `%s`.', definition.kind, fragment.name) : invariant(false) : void 0;
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
return variables || argumentVariables;
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.handleGraphModeResponse = handleGraphModeResponse;
|
|
8
8
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
9
|
-
var RelayModernRecord = require(
|
|
10
|
-
var invariant = require(
|
|
9
|
+
var RelayModernRecord = require('./RelayModernRecord');
|
|
10
|
+
var invariant = require('invariant');
|
|
11
11
|
function handleGraphModeResponse(recordSource, response) {
|
|
12
12
|
var handler = new GraphModeHandler(recordSource);
|
|
13
13
|
return handler.populateRecordSource(response);
|
|
@@ -25,10 +25,10 @@ var GraphModeHandler = /*#__PURE__*/function () {
|
|
|
25
25
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
26
26
|
var chunk = _step.value;
|
|
27
27
|
switch (chunk.$kind) {
|
|
28
|
-
case
|
|
28
|
+
case 'Record':
|
|
29
29
|
this._handleRecordChunk(chunk);
|
|
30
30
|
break;
|
|
31
|
-
case
|
|
31
|
+
case 'Extend':
|
|
32
32
|
{
|
|
33
33
|
var cacheKey = this._lookupCacheKey(chunk.$streamID);
|
|
34
34
|
var record = this._recordSource.get(cacheKey);
|
|
@@ -36,7 +36,7 @@ var GraphModeHandler = /*#__PURE__*/function () {
|
|
|
36
36
|
this._populateRecord(record, chunk);
|
|
37
37
|
break;
|
|
38
38
|
}
|
|
39
|
-
case
|
|
39
|
+
case 'Complete':
|
|
40
40
|
this._streamIdToCacheKey.clear();
|
|
41
41
|
break;
|
|
42
42
|
default:
|
|
@@ -67,26 +67,26 @@ var GraphModeHandler = /*#__PURE__*/function () {
|
|
|
67
67
|
key = _Object$entries$_i[0],
|
|
68
68
|
value = _Object$entries$_i[1];
|
|
69
69
|
switch (key) {
|
|
70
|
-
case
|
|
71
|
-
case
|
|
72
|
-
case
|
|
70
|
+
case '$streamID':
|
|
71
|
+
case '$kind':
|
|
72
|
+
case '__typename':
|
|
73
73
|
break;
|
|
74
74
|
default:
|
|
75
|
-
if (typeof value !==
|
|
75
|
+
if (typeof value !== 'object' || value == null || Array.isArray(value)) {
|
|
76
76
|
RelayModernRecord.setValue(parentRecord, key, value);
|
|
77
77
|
} else {
|
|
78
|
-
if (value.hasOwnProperty(
|
|
78
|
+
if (value.hasOwnProperty('__id')) {
|
|
79
79
|
var streamID = value.__id;
|
|
80
80
|
var id = this._lookupCacheKey(streamID);
|
|
81
81
|
RelayModernRecord.setLinkedRecordID(parentRecord, key, id);
|
|
82
|
-
} else if (value.hasOwnProperty(
|
|
82
|
+
} else if (value.hasOwnProperty('__ids')) {
|
|
83
83
|
var streamIDs = value.__ids;
|
|
84
84
|
var ids = streamIDs.map(function (sID) {
|
|
85
85
|
return sID == null ? null : _this._lookupCacheKey(sID);
|
|
86
86
|
});
|
|
87
87
|
RelayModernRecord.setLinkedRecordIDs(parentRecord, key, ids);
|
|
88
88
|
} else {
|
|
89
|
-
!false ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
89
|
+
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected object to have either __id or __ids.') : invariant(false) : void 0;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
}
|