relay-runtime 9.0.0 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/handlers/RelayDefaultHandlerProvider.js.flow +47 -0
- package/handlers/connection/ConnectionHandler.js.flow +549 -0
- package/handlers/connection/ConnectionInterface.js.flow +92 -0
- package/handlers/connection/MutationHandlers.js.flow +199 -0
- package/index.js +1 -1
- package/index.js.flow +335 -0
- package/lib/handlers/RelayDefaultHandlerProvider.js +20 -0
- package/lib/handlers/connection/ConnectionHandler.js +1 -3
- package/lib/handlers/connection/MutationHandlers.js +212 -0
- package/lib/index.js +14 -2
- package/lib/mutations/RelayDeclarativeMutationConfig.js +22 -45
- package/lib/mutations/RelayRecordProxy.js +1 -3
- package/lib/mutations/RelayRecordSourceMutator.js +1 -3
- package/lib/mutations/RelayRecordSourceProxy.js +1 -3
- package/lib/mutations/RelayRecordSourceSelectorProxy.js +1 -3
- package/lib/mutations/commitMutation.js +2 -3
- package/lib/mutations/validateMutation.js +40 -9
- package/lib/network/RelayObservable.js +9 -9
- package/lib/network/RelayQueryResponseCache.js +8 -6
- package/lib/query/GraphQLTag.js +2 -1
- package/lib/query/PreloadableQueryRegistry.js +70 -0
- package/lib/query/fetchQuery.js +2 -3
- package/lib/query/fetchQueryInternal.js +5 -14
- package/lib/store/DataChecker.js +200 -71
- package/lib/store/RelayConcreteVariables.js +6 -2
- package/lib/store/RelayModernEnvironment.js +124 -65
- package/lib/store/RelayModernFragmentSpecResolver.js +19 -14
- package/lib/store/RelayModernOperationDescriptor.js +6 -5
- package/lib/store/RelayModernQueryExecutor.js +122 -73
- package/lib/store/RelayModernRecord.js +14 -9
- package/lib/store/RelayModernSelector.js +6 -2
- package/lib/store/RelayModernStore.js +281 -131
- package/lib/store/RelayOperationTracker.js +35 -78
- package/lib/store/RelayOptimisticRecordSource.js +7 -5
- package/lib/store/RelayPublishQueue.js +2 -4
- package/lib/store/RelayReader.js +304 -52
- package/lib/store/RelayRecordSource.js +1 -3
- package/lib/store/RelayRecordSourceMapImpl.js +13 -18
- package/lib/store/RelayReferenceMarker.js +125 -14
- package/lib/store/RelayResponseNormalizer.js +261 -66
- package/lib/store/RelayStoreReactFlightUtils.js +47 -0
- package/lib/store/RelayStoreUtils.js +1 -0
- package/lib/store/StoreInspector.js +8 -8
- package/lib/store/TypeID.js +28 -0
- package/lib/store/cloneRelayScalarHandleSourceField.js +44 -0
- package/lib/store/defaultRequiredFieldLogger.js +18 -0
- package/lib/store/normalizeRelayPayload.js +6 -2
- package/lib/store/readInlineData.js +1 -1
- package/lib/subscription/requestSubscription.js +4 -3
- package/lib/util/NormalizationNode.js +1 -5
- package/lib/util/RelayConcreteNode.js +11 -6
- package/lib/util/RelayError.js +39 -9
- package/lib/util/RelayFeatureFlags.js +6 -3
- package/lib/util/RelayReplaySubject.js +3 -3
- package/lib/util/createPayloadFor3DField.js +7 -2
- package/lib/util/getFragmentIdentifier.js +12 -3
- package/lib/util/getOperation.js +33 -0
- package/lib/util/getRequestIdentifier.js +2 -2
- package/lib/util/isEmptyObject.js +25 -0
- package/lib/util/recycleNodesInto.js +6 -7
- package/lib/util/reportMissingRequiredFields.js +48 -0
- package/mutations/RelayDeclarativeMutationConfig.js.flow +380 -0
- package/mutations/RelayRecordProxy.js.flow +165 -0
- package/mutations/RelayRecordSourceMutator.js.flow +238 -0
- package/mutations/RelayRecordSourceProxy.js.flow +164 -0
- package/mutations/RelayRecordSourceSelectorProxy.js.flow +119 -0
- package/mutations/applyOptimisticMutation.js.flow +76 -0
- package/mutations/commitLocalUpdate.js.flow +24 -0
- package/mutations/commitMutation.js.flow +181 -0
- package/mutations/validateMutation.js.flow +242 -0
- package/network/ConvertToExecuteFunction.js.flow +49 -0
- package/network/RelayNetwork.js.flow +84 -0
- package/network/RelayNetworkTypes.js.flow +145 -0
- package/network/RelayObservable.js.flow +634 -0
- package/network/RelayQueryResponseCache.js.flow +111 -0
- package/package.json +2 -2
- package/query/GraphQLTag.js.flow +168 -0
- package/query/PreloadableQueryRegistry.js.flow +65 -0
- package/query/fetchQuery.js.flow +47 -0
- package/query/fetchQueryInternal.js.flow +343 -0
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/ClientID.js.flow +43 -0
- package/store/DataChecker.js.flow +568 -0
- package/store/RelayConcreteVariables.js.flow +96 -0
- package/store/RelayModernEnvironment.js.flow +571 -0
- package/store/RelayModernFragmentSpecResolver.js.flow +438 -0
- package/store/RelayModernOperationDescriptor.js.flow +92 -0
- package/store/RelayModernQueryExecutor.js.flow +1345 -0
- package/store/RelayModernRecord.js.flow +403 -0
- package/store/RelayModernSelector.js.flow +455 -0
- package/store/RelayModernStore.js.flow +858 -0
- package/store/RelayOperationTracker.js.flow +164 -0
- package/store/RelayOptimisticRecordSource.js.flow +119 -0
- package/store/RelayPublishQueue.js.flow +401 -0
- package/store/RelayReader.js.flow +638 -0
- package/store/RelayRecordSource.js.flow +29 -0
- package/store/RelayRecordSourceMapImpl.js.flow +87 -0
- package/store/RelayRecordState.js.flow +37 -0
- package/store/RelayReferenceMarker.js.flow +324 -0
- package/store/RelayResponseNormalizer.js.flow +791 -0
- package/store/RelayStoreReactFlightUtils.js.flow +64 -0
- package/store/RelayStoreTypes.js.flow +958 -0
- package/store/RelayStoreUtils.js.flow +219 -0
- package/store/StoreInspector.js.flow +171 -0
- package/store/TypeID.js.flow +28 -0
- package/store/ViewerPattern.js.flow +26 -0
- package/store/cloneRelayHandleSourceField.js.flow +66 -0
- package/store/cloneRelayScalarHandleSourceField.js.flow +62 -0
- package/store/createFragmentSpecResolver.js.flow +55 -0
- package/store/createRelayContext.js.flow +44 -0
- package/store/defaultGetDataID.js.flow +27 -0
- package/store/defaultRequiredFieldLogger.js.flow +23 -0
- package/store/hasOverlappingIDs.js.flow +34 -0
- package/store/isRelayModernEnvironment.js.flow +27 -0
- package/store/normalizeRelayPayload.js.flow +51 -0
- package/store/readInlineData.js.flow +75 -0
- package/subscription/requestSubscription.js.flow +103 -0
- package/util/JSResourceTypes.flow.js.flow +20 -0
- package/util/NormalizationNode.js.flow +213 -0
- package/util/ReaderNode.js.flow +227 -0
- package/util/RelayConcreteNode.js.flow +99 -0
- package/util/RelayDefaultHandleKey.js.flow +17 -0
- package/util/RelayError.js.flow +62 -0
- package/util/RelayFeatureFlags.js.flow +37 -0
- package/util/RelayProfiler.js.flow +284 -0
- package/util/RelayReplaySubject.js.flow +135 -0
- package/util/RelayRuntimeTypes.js.flow +72 -0
- package/util/createPayloadFor3DField.js.flow +43 -0
- package/util/deepFreeze.js.flow +36 -0
- package/util/generateID.js.flow +21 -0
- package/util/getFragmentIdentifier.js.flow +76 -0
- package/util/getOperation.js.flow +40 -0
- package/util/getRelayHandleKey.js.flow +41 -0
- package/util/getRequestIdentifier.js.flow +42 -0
- package/util/isEmptyObject.js.flow +25 -0
- package/util/isPromise.js.flow +21 -0
- package/util/isScalarAndEqual.js.flow +26 -0
- package/util/recycleNodesInto.js.flow +87 -0
- package/util/reportMissingRequiredFields.js.flow +51 -0
- package/util/resolveImmediate.js.flow +30 -0
- package/util/stableCopy.js.flow +35 -0
|
@@ -13,10 +13,20 @@
|
|
|
13
13
|
|
|
14
14
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
17
|
|
|
18
18
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
19
19
|
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
+
|
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
23
|
+
|
|
24
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
25
|
+
|
|
26
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
27
|
+
|
|
28
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
29
|
+
|
|
20
30
|
var RelayError = require('../util/RelayError');
|
|
21
31
|
|
|
22
32
|
var RelayModernRecord = require('./RelayModernRecord');
|
|
@@ -27,6 +37,8 @@ var RelayRecordSource = require('./RelayRecordSource');
|
|
|
27
37
|
|
|
28
38
|
var RelayResponseNormalizer = require('./RelayResponseNormalizer');
|
|
29
39
|
|
|
40
|
+
var getOperation = require('../util/getOperation');
|
|
41
|
+
|
|
30
42
|
var invariant = require("fbjs/lib/invariant");
|
|
31
43
|
|
|
32
44
|
var stableCopy = require('../util/stableCopy');
|
|
@@ -54,9 +66,7 @@ function execute(config) {
|
|
|
54
66
|
*/
|
|
55
67
|
|
|
56
68
|
|
|
57
|
-
var Executor =
|
|
58
|
-
/*#__PURE__*/
|
|
59
|
-
function () {
|
|
69
|
+
var Executor = /*#__PURE__*/function () {
|
|
60
70
|
function Executor(_ref) {
|
|
61
71
|
var _this = this;
|
|
62
72
|
|
|
@@ -71,9 +81,12 @@ function () {
|
|
|
71
81
|
store = _ref.store,
|
|
72
82
|
updater = _ref.updater,
|
|
73
83
|
operationTracker = _ref.operationTracker,
|
|
84
|
+
treatMissingFieldsAsNull = _ref.treatMissingFieldsAsNull,
|
|
74
85
|
getDataID = _ref.getDataID,
|
|
75
|
-
isClientPayload = _ref.isClientPayload
|
|
86
|
+
isClientPayload = _ref.isClientPayload,
|
|
87
|
+
reactFlightPayloadDeserializer = _ref.reactFlightPayloadDeserializer;
|
|
76
88
|
this._getDataID = getDataID;
|
|
89
|
+
this._treatMissingFieldsAsNull = treatMissingFieldsAsNull;
|
|
77
90
|
this._incrementalPayloadsPending = false;
|
|
78
91
|
this._incrementalResults = new Map();
|
|
79
92
|
this._nextSubscriptionId = 0;
|
|
@@ -93,6 +106,7 @@ function () {
|
|
|
93
106
|
this._subscriptions = new Map();
|
|
94
107
|
this._updater = updater;
|
|
95
108
|
this._isClientPayload = isClientPayload === true;
|
|
109
|
+
this._reactFlightPayloadDeserializer = reactFlightPayloadDeserializer;
|
|
96
110
|
var id = this._nextSubscriptionId++;
|
|
97
111
|
source.subscribe({
|
|
98
112
|
complete: function complete() {
|
|
@@ -116,7 +130,7 @@ function () {
|
|
|
116
130
|
if (optimisticConfig != null) {
|
|
117
131
|
this._processOptimisticResponse(optimisticConfig.response != null ? {
|
|
118
132
|
data: optimisticConfig.response
|
|
119
|
-
} : null, optimisticConfig.updater);
|
|
133
|
+
} : null, optimisticConfig.updater, false);
|
|
120
134
|
}
|
|
121
135
|
} // Cancel any pending execution tasks and mark the executor as completed.
|
|
122
136
|
|
|
@@ -156,6 +170,12 @@ function () {
|
|
|
156
170
|
this._incrementalResults.clear();
|
|
157
171
|
|
|
158
172
|
this._completeOperationTracker();
|
|
173
|
+
|
|
174
|
+
if (this._retainDisposable) {
|
|
175
|
+
this._retainDisposable.dispose();
|
|
176
|
+
|
|
177
|
+
this._retainDisposable = null;
|
|
178
|
+
}
|
|
159
179
|
};
|
|
160
180
|
|
|
161
181
|
_proto._updateActiveState = function _updateActiveState() {
|
|
@@ -266,26 +286,35 @@ function () {
|
|
|
266
286
|
_proto._handleErrorResponse = function _handleErrorResponse(responses) {
|
|
267
287
|
var _this5 = this;
|
|
268
288
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
289
|
+
var results = [];
|
|
290
|
+
responses.forEach(function (response) {
|
|
291
|
+
if (response.data === null && response.extensions != null && !response.hasOwnProperty('errors')) {
|
|
292
|
+
// Skip extensions-only payloads
|
|
293
|
+
return;
|
|
294
|
+
} else if (response.data == null) {
|
|
295
|
+
// Error if any other payload in the batch is missing data, regardless of whether
|
|
296
|
+
// it had `errors` or not.
|
|
297
|
+
var errors = response.hasOwnProperty('errors') && response.errors != null ? response.errors : null;
|
|
298
|
+
var messages = errors ? errors.map(function (_ref2) {
|
|
274
299
|
var message = _ref2.message;
|
|
275
300
|
return message;
|
|
276
301
|
}).join('\n') : '(No errors)';
|
|
277
302
|
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.');
|
|
278
303
|
error.source = {
|
|
279
|
-
errors:
|
|
304
|
+
errors: errors,
|
|
280
305
|
operation: _this5._operation.request.node,
|
|
281
306
|
variables: _this5._operation.request.variables
|
|
282
|
-
};
|
|
307
|
+
}; // In V8, Error objects keep the closure scope chain alive until the
|
|
308
|
+
// err.stack property is accessed.
|
|
309
|
+
|
|
310
|
+
error.stack;
|
|
283
311
|
throw error;
|
|
312
|
+
} else {
|
|
313
|
+
var responseWithData = response;
|
|
314
|
+
results.push(responseWithData);
|
|
284
315
|
}
|
|
285
|
-
|
|
286
|
-
var responseWithData = response;
|
|
287
|
-
return responseWithData;
|
|
288
316
|
});
|
|
317
|
+
return results;
|
|
289
318
|
}
|
|
290
319
|
/**
|
|
291
320
|
* This method return boolean to indicate if the optimistic
|
|
@@ -316,7 +345,7 @@ function () {
|
|
|
316
345
|
}
|
|
317
346
|
|
|
318
347
|
if (isOptimistic) {
|
|
319
|
-
this._processOptimisticResponse(response, null);
|
|
348
|
+
this._processOptimisticResponse(response, null, this._treatMissingFieldsAsNull);
|
|
320
349
|
|
|
321
350
|
this._sink.next(response);
|
|
322
351
|
|
|
@@ -331,7 +360,31 @@ function () {
|
|
|
331
360
|
return;
|
|
332
361
|
}
|
|
333
362
|
|
|
334
|
-
var
|
|
363
|
+
var responses = Array.isArray(response) ? response : [response];
|
|
364
|
+
|
|
365
|
+
var responsesWithData = this._handleErrorResponse(responses);
|
|
366
|
+
|
|
367
|
+
if (responsesWithData.length === 0) {
|
|
368
|
+
// no results with data, nothing to process
|
|
369
|
+
// this can occur with extensions-only payloads
|
|
370
|
+
var isFinal = responses.some(function (x) {
|
|
371
|
+
var _x$extensions;
|
|
372
|
+
|
|
373
|
+
return ((_x$extensions = x.extensions) === null || _x$extensions === void 0 ? void 0 : _x$extensions.is_final) === true;
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
if (isFinal) {
|
|
377
|
+
this._state = 'loading_final';
|
|
378
|
+
|
|
379
|
+
this._updateActiveState();
|
|
380
|
+
|
|
381
|
+
this._incrementalPayloadsPending = false;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
this._sink.next(response);
|
|
385
|
+
|
|
386
|
+
return;
|
|
387
|
+
} // Next, handle optimistic responses
|
|
335
388
|
|
|
336
389
|
|
|
337
390
|
var isOptimistic = this._handleOptimisticResponses(responsesWithData);
|
|
@@ -344,17 +397,17 @@ function () {
|
|
|
344
397
|
nonIncrementalResponses = _partitionGraphQLResp[0],
|
|
345
398
|
incrementalResponses = _partitionGraphQLResp[1]; // In theory this doesn't preserve the ordering of the batch.
|
|
346
399
|
// The idea is that a batch is always:
|
|
347
|
-
// * at
|
|
348
|
-
// * followed zero or more incremental payloads
|
|
400
|
+
// * at most one non-incremental payload
|
|
401
|
+
// * followed by zero or more incremental payloads
|
|
349
402
|
// The non-incremental payload can appear if the server sends a batch
|
|
350
|
-
//
|
|
403
|
+
// with the initial payload followed by some early-to-resolve incremental
|
|
351
404
|
// payloads (although, can that even happen?)
|
|
352
405
|
|
|
353
406
|
|
|
354
407
|
if (nonIncrementalResponses.length > 0) {
|
|
355
|
-
var payloadFollowups = this._processResponses(nonIncrementalResponses); // Please note
|
|
408
|
+
var payloadFollowups = this._processResponses(nonIncrementalResponses); // Please note that we're passing `this._operation` to the publish
|
|
356
409
|
// queue here, which will later passed to the store (via notify)
|
|
357
|
-
// to indicate that this is an operation that
|
|
410
|
+
// to indicate that this is an operation that caused the store to update
|
|
358
411
|
|
|
359
412
|
|
|
360
413
|
var updatedOwners = this._publishQueue.run(this._operation);
|
|
@@ -362,6 +415,10 @@ function () {
|
|
|
362
415
|
this._updateOperationTracker(updatedOwners);
|
|
363
416
|
|
|
364
417
|
this._processPayloadFollowups(payloadFollowups);
|
|
418
|
+
|
|
419
|
+
if (this._incrementalPayloadsPending && !this._retainDisposable) {
|
|
420
|
+
this._retainDisposable = this._store.retain(this._operation);
|
|
421
|
+
}
|
|
365
422
|
}
|
|
366
423
|
|
|
367
424
|
if (incrementalResponses.length > 0) {
|
|
@@ -380,7 +437,7 @@ function () {
|
|
|
380
437
|
this._sink.next(response);
|
|
381
438
|
};
|
|
382
439
|
|
|
383
|
-
_proto._processOptimisticResponse = function _processOptimisticResponse(response, updater) {
|
|
440
|
+
_proto._processOptimisticResponse = function _processOptimisticResponse(response, updater, treatMissingFieldsAsNull) {
|
|
384
441
|
var _this6 = this;
|
|
385
442
|
|
|
386
443
|
!(this._optimisticUpdates === null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'environment.execute: only support one optimistic response per ' + 'execute.') : invariant(false) : void 0;
|
|
@@ -395,7 +452,8 @@ function () {
|
|
|
395
452
|
var payload = normalizeResponse(response, this._operation.root, ROOT_TYPE, {
|
|
396
453
|
getDataID: this._getDataID,
|
|
397
454
|
path: [],
|
|
398
|
-
|
|
455
|
+
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer,
|
|
456
|
+
treatMissingFieldsAsNull: treatMissingFieldsAsNull
|
|
399
457
|
});
|
|
400
458
|
validateOptimisticResponsePayload(payload);
|
|
401
459
|
optimisticUpdates.push({
|
|
@@ -433,36 +491,27 @@ function () {
|
|
|
433
491
|
var moduleImportPayloads = payload.moduleImportPayloads;
|
|
434
492
|
var operationLoader = this._operationLoader;
|
|
435
493
|
!operationLoader ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayModernEnvironment: Expected an operationLoader to be ' + 'configured when using `@match`.') : invariant(false) : void 0;
|
|
436
|
-
|
|
437
|
-
var
|
|
438
|
-
|
|
494
|
+
|
|
495
|
+
var _iterator = _createForOfIteratorHelper(moduleImportPayloads),
|
|
496
|
+
_step;
|
|
439
497
|
|
|
440
498
|
try {
|
|
441
|
-
for (
|
|
499
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
442
500
|
var moduleImportPayload = _step.value;
|
|
443
501
|
var operation = operationLoader.get(moduleImportPayload.operationReference);
|
|
444
502
|
|
|
445
503
|
if (operation == null) {
|
|
446
504
|
this._processAsyncOptimisticModuleImport(operationLoader, moduleImportPayload);
|
|
447
505
|
} else {
|
|
448
|
-
var
|
|
506
|
+
var moduleImportOptimisticUpdates = this._processOptimisticModuleImport(operation, moduleImportPayload);
|
|
449
507
|
|
|
450
|
-
optimisticUpdates.push.apply(optimisticUpdates, (0, _toConsumableArray2["default"])(
|
|
508
|
+
optimisticUpdates.push.apply(optimisticUpdates, (0, _toConsumableArray2["default"])(moduleImportOptimisticUpdates));
|
|
451
509
|
}
|
|
452
510
|
}
|
|
453
511
|
} catch (err) {
|
|
454
|
-
|
|
455
|
-
_iteratorError = err;
|
|
512
|
+
_iterator.e(err);
|
|
456
513
|
} finally {
|
|
457
|
-
|
|
458
|
-
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
|
|
459
|
-
_iterator["return"]();
|
|
460
|
-
}
|
|
461
|
-
} finally {
|
|
462
|
-
if (_didIteratorError) {
|
|
463
|
-
throw _iteratorError;
|
|
464
|
-
}
|
|
465
|
-
}
|
|
514
|
+
_iterator.f();
|
|
466
515
|
}
|
|
467
516
|
}
|
|
468
517
|
};
|
|
@@ -474,11 +523,13 @@ function () {
|
|
|
474
523
|
}, selector, moduleImportPayload.typeName, {
|
|
475
524
|
getDataID: this._getDataID,
|
|
476
525
|
path: moduleImportPayload.path,
|
|
477
|
-
|
|
526
|
+
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer,
|
|
527
|
+
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull
|
|
478
528
|
});
|
|
479
529
|
};
|
|
480
530
|
|
|
481
|
-
_proto._processOptimisticModuleImport = function _processOptimisticModuleImport(
|
|
531
|
+
_proto._processOptimisticModuleImport = function _processOptimisticModuleImport(normalizationRootNode, moduleImportPayload) {
|
|
532
|
+
var operation = getOperation(normalizationRootNode);
|
|
482
533
|
var optimisticUpdates = [];
|
|
483
534
|
|
|
484
535
|
var modulePayload = this._normalizeModuleImport(moduleImportPayload, operation);
|
|
@@ -503,18 +554,18 @@ function () {
|
|
|
503
554
|
return;
|
|
504
555
|
}
|
|
505
556
|
|
|
506
|
-
var
|
|
557
|
+
var moduleImportOptimisticUpdates = _this7._processOptimisticModuleImport(operation, moduleImportPayload);
|
|
507
558
|
|
|
508
|
-
|
|
559
|
+
moduleImportOptimisticUpdates.forEach(function (update) {
|
|
509
560
|
return _this7._publishQueue.applyUpdate(update);
|
|
510
561
|
});
|
|
511
562
|
|
|
512
563
|
if (_this7._optimisticUpdates == null) {
|
|
513
|
-
process.env.NODE_ENV !== "production" ? warning(false, 'RelayModernQueryExecutor: Unexpected ModuleImport
|
|
564
|
+
process.env.NODE_ENV !== "production" ? warning(false, 'RelayModernQueryExecutor: Unexpected ModuleImport optimistic ' + 'update in operation %s.' + _this7._operation.request.node.params.name) : void 0;
|
|
514
565
|
} else {
|
|
515
566
|
var _this$_optimisticUpda;
|
|
516
567
|
|
|
517
|
-
(_this$_optimisticUpda = _this7._optimisticUpdates).push.apply(_this$_optimisticUpda, (0, _toConsumableArray2["default"])(
|
|
568
|
+
(_this$_optimisticUpda = _this7._optimisticUpdates).push.apply(_this$_optimisticUpda, (0, _toConsumableArray2["default"])(moduleImportOptimisticUpdates));
|
|
518
569
|
|
|
519
570
|
_this7._publishQueue.run();
|
|
520
571
|
}
|
|
@@ -542,7 +593,8 @@ function () {
|
|
|
542
593
|
var relayPayload = normalizeResponse(payloadPart, _this8._operation.root, ROOT_TYPE, {
|
|
543
594
|
getDataID: _this8._getDataID,
|
|
544
595
|
path: [],
|
|
545
|
-
|
|
596
|
+
reactFlightPayloadDeserializer: _this8._reactFlightPayloadDeserializer,
|
|
597
|
+
treatMissingFieldsAsNull: _this8._treatMissingFieldsAsNull
|
|
546
598
|
});
|
|
547
599
|
|
|
548
600
|
_this8._publishQueue.commitPayload(_this8._operation, relayPayload, _this8._updater);
|
|
@@ -642,16 +694,15 @@ function () {
|
|
|
642
694
|
_proto._processModuleImportPayload = function _processModuleImportPayload(moduleImportPayload, operationLoader) {
|
|
643
695
|
var _this10 = this;
|
|
644
696
|
|
|
645
|
-
var
|
|
697
|
+
var node = operationLoader.get(moduleImportPayload.operationReference);
|
|
646
698
|
|
|
647
|
-
if (
|
|
648
|
-
// If the operation module is available synchronously, normalize the
|
|
699
|
+
if (node != null) {
|
|
700
|
+
var operation = getOperation(node); // If the operation module is available synchronously, normalize the
|
|
649
701
|
// data synchronously.
|
|
650
|
-
this._schedule(function () {
|
|
651
|
-
_this10._handleModuleImportPayload(moduleImportPayload, syncOperation);
|
|
652
702
|
|
|
653
|
-
|
|
654
|
-
|
|
703
|
+
this._handleModuleImportPayload(moduleImportPayload, operation);
|
|
704
|
+
|
|
705
|
+
this._maybeCompleteSubscriptionOperationTracking();
|
|
655
706
|
} else {
|
|
656
707
|
// Otherwise load the operation module and schedule a task to normalize
|
|
657
708
|
// the data when the module is available.
|
|
@@ -673,7 +724,7 @@ function () {
|
|
|
673
724
|
})).map(function (operation) {
|
|
674
725
|
if (operation != null) {
|
|
675
726
|
_this10._schedule(function () {
|
|
676
|
-
_this10._handleModuleImportPayload(moduleImportPayload, operation);
|
|
727
|
+
_this10._handleModuleImportPayload(moduleImportPayload, getOperation(operation));
|
|
677
728
|
});
|
|
678
729
|
}
|
|
679
730
|
}).subscribe({
|
|
@@ -719,8 +770,6 @@ function () {
|
|
|
719
770
|
;
|
|
720
771
|
|
|
721
772
|
_proto._processIncrementalPlaceholder = function _processIncrementalPlaceholder(relayPayload, placeholder) {
|
|
722
|
-
var _this11 = this;
|
|
723
|
-
|
|
724
773
|
var _relayPayload$fieldPa;
|
|
725
774
|
|
|
726
775
|
// Update the label => path => placeholder map
|
|
@@ -800,15 +849,13 @@ function () {
|
|
|
800
849
|
|
|
801
850
|
|
|
802
851
|
if (pendingResponses != null) {
|
|
803
|
-
this.
|
|
804
|
-
var payloadFollowups = _this11._processIncrementalResponses(pendingResponses);
|
|
852
|
+
var payloadFollowups = this._processIncrementalResponses(pendingResponses);
|
|
805
853
|
|
|
806
|
-
|
|
854
|
+
var updatedOwners = this._publishQueue.run();
|
|
807
855
|
|
|
808
|
-
|
|
856
|
+
this._updateOperationTracker(updatedOwners);
|
|
809
857
|
|
|
810
|
-
|
|
811
|
-
});
|
|
858
|
+
this._processPayloadFollowups(payloadFollowups);
|
|
812
859
|
}
|
|
813
860
|
}
|
|
814
861
|
/**
|
|
@@ -819,7 +866,7 @@ function () {
|
|
|
819
866
|
;
|
|
820
867
|
|
|
821
868
|
_proto._processIncrementalResponses = function _processIncrementalResponses(incrementalResponses) {
|
|
822
|
-
var
|
|
869
|
+
var _this11 = this;
|
|
823
870
|
|
|
824
871
|
var relayPayloads = [];
|
|
825
872
|
incrementalResponses.forEach(function (incrementalResponse) {
|
|
@@ -827,12 +874,12 @@ function () {
|
|
|
827
874
|
path = incrementalResponse.path,
|
|
828
875
|
response = incrementalResponse.response;
|
|
829
876
|
|
|
830
|
-
var resultForLabel =
|
|
877
|
+
var resultForLabel = _this11._incrementalResults.get(label);
|
|
831
878
|
|
|
832
879
|
if (resultForLabel == null) {
|
|
833
880
|
resultForLabel = new Map();
|
|
834
881
|
|
|
835
|
-
|
|
882
|
+
_this11._incrementalResults.set(label, resultForLabel);
|
|
836
883
|
}
|
|
837
884
|
|
|
838
885
|
if (label.indexOf('$defer$') !== -1) {
|
|
@@ -853,7 +900,7 @@ function () {
|
|
|
853
900
|
|
|
854
901
|
var placeholder = resultForPath.placeholder;
|
|
855
902
|
!(placeholder.kind === 'defer') ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayModernEnvironment: Expected data for path `%s` for label `%s` ' + 'to be data for @defer, was `@%s`.', pathKey, label, placeholder.kind) : invariant(false) : void 0;
|
|
856
|
-
relayPayloads.push(
|
|
903
|
+
relayPayloads.push(_this11._processDeferResponse(label, path, placeholder, response));
|
|
857
904
|
} else {
|
|
858
905
|
// @stream payload path values end in the field name and item index,
|
|
859
906
|
// but Relay records paths relative to the parent of the stream node:
|
|
@@ -878,7 +925,7 @@ function () {
|
|
|
878
925
|
|
|
879
926
|
var _placeholder = _resultForPath.placeholder;
|
|
880
927
|
!(_placeholder.kind === 'stream') ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayModernEnvironment: Expected data for path `%s` for label `%s` ' + 'to be data for @stream, was `@%s`.', _pathKey, label, _placeholder.kind) : invariant(false) : void 0;
|
|
881
|
-
relayPayloads.push(
|
|
928
|
+
relayPayloads.push(_this11._processStreamResponse(label, path, _placeholder, response));
|
|
882
929
|
}
|
|
883
930
|
});
|
|
884
931
|
return relayPayloads;
|
|
@@ -889,7 +936,8 @@ function () {
|
|
|
889
936
|
var relayPayload = normalizeResponse(response, placeholder.selector, placeholder.typeName, {
|
|
890
937
|
getDataID: this._getDataID,
|
|
891
938
|
path: placeholder.path,
|
|
892
|
-
|
|
939
|
+
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer,
|
|
940
|
+
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull
|
|
893
941
|
});
|
|
894
942
|
|
|
895
943
|
this._publishQueue.commitPayload(this._operation, relayPayload); // Load the version of the parent record from which this incremental data
|
|
@@ -1040,7 +1088,8 @@ function () {
|
|
|
1040
1088
|
var relayPayload = normalizeResponse(response, selector, typeName, {
|
|
1041
1089
|
getDataID: this._getDataID,
|
|
1042
1090
|
path: [].concat((0, _toConsumableArray2["default"])(normalizationPath), [responseKey, String(itemIndex)]),
|
|
1043
|
-
|
|
1091
|
+
reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer,
|
|
1092
|
+
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull
|
|
1044
1093
|
});
|
|
1045
1094
|
return {
|
|
1046
1095
|
fieldPayloads: fieldPayloads,
|
|
@@ -1100,7 +1149,7 @@ function normalizeResponse(response, selector, typeName, options) {
|
|
|
1100
1149
|
var record = RelayModernRecord.create(selector.dataID, typeName);
|
|
1101
1150
|
source.set(selector.dataID, record);
|
|
1102
1151
|
var relayPayload = RelayResponseNormalizer.normalize(source, selector, data, options);
|
|
1103
|
-
return (
|
|
1152
|
+
return _objectSpread(_objectSpread({}, relayPayload), {}, {
|
|
1104
1153
|
errors: errors,
|
|
1105
1154
|
isFinal: ((_response$extensions3 = response.extensions) === null || _response$extensions3 === void 0 ? void 0 : _response$extensions3.is_final) === true
|
|
1106
1155
|
});
|
|
@@ -12,7 +12,11 @@
|
|
|
12
12
|
|
|
13
13
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
+
|
|
17
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
18
|
+
|
|
19
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
16
20
|
|
|
17
21
|
var areEqual = require("fbjs/lib/areEqual");
|
|
18
22
|
|
|
@@ -30,7 +34,8 @@ var _require2 = require('./RelayStoreUtils'),
|
|
|
30
34
|
REF_KEY = _require2.REF_KEY,
|
|
31
35
|
REFS_KEY = _require2.REFS_KEY,
|
|
32
36
|
TYPENAME_KEY = _require2.TYPENAME_KEY,
|
|
33
|
-
INVALIDATED_AT_KEY = _require2.INVALIDATED_AT_KEY
|
|
37
|
+
INVALIDATED_AT_KEY = _require2.INVALIDATED_AT_KEY,
|
|
38
|
+
ROOT_ID = _require2.ROOT_ID;
|
|
34
39
|
|
|
35
40
|
/**
|
|
36
41
|
* @public
|
|
@@ -82,7 +87,7 @@ var _require2 = require('./RelayStoreUtils'),
|
|
|
82
87
|
* Clone a record.
|
|
83
88
|
*/
|
|
84
89
|
function clone(record) {
|
|
85
|
-
return (
|
|
90
|
+
return _objectSpread({}, record);
|
|
86
91
|
}
|
|
87
92
|
/**
|
|
88
93
|
* @public
|
|
@@ -233,7 +238,7 @@ function update(prevRecord, nextRecord) {
|
|
|
233
238
|
|
|
234
239
|
var prevType = (_getType = getType(prevRecord)) !== null && _getType !== void 0 ? _getType : null;
|
|
235
240
|
var nextType = (_getType2 = getType(nextRecord)) !== null && _getType2 !== void 0 ? _getType2 : null;
|
|
236
|
-
process.env.NODE_ENV !== "production" ? warning(isClientID(nextID) || prevType === nextType, 'RelayModernRecord: Invalid record update, expected both versions of ' + 'record `%s` to have the same `%s` but got conflicting types `%s` ' + 'and `%s`. The GraphQL server likely violated the globally unique ' + 'id requirement by returning the same id for different objects.', prevID, TYPENAME_KEY, prevType, nextType) : void 0;
|
|
241
|
+
process.env.NODE_ENV !== "production" ? warning(isClientID(nextID) && nextID !== ROOT_ID || prevType === nextType, 'RelayModernRecord: Invalid record update, expected both versions of ' + 'record `%s` to have the same `%s` but got conflicting types `%s` ' + 'and `%s`. The GraphQL server likely violated the globally unique ' + 'id requirement by returning the same id for different objects.', prevID, TYPENAME_KEY, prevType, nextType) : void 0;
|
|
237
242
|
}
|
|
238
243
|
|
|
239
244
|
var updated = null;
|
|
@@ -243,7 +248,7 @@ function update(prevRecord, nextRecord) {
|
|
|
243
248
|
var key = keys[ii];
|
|
244
249
|
|
|
245
250
|
if (updated || !areEqual(prevRecord[key], nextRecord[key])) {
|
|
246
|
-
updated = updated !== null ? updated : (
|
|
251
|
+
updated = updated !== null ? updated : _objectSpread({}, prevRecord);
|
|
247
252
|
updated[key] = nextRecord[key];
|
|
248
253
|
}
|
|
249
254
|
}
|
|
@@ -268,7 +273,7 @@ function merge(record1, record2) {
|
|
|
268
273
|
|
|
269
274
|
var prevType = (_getType3 = getType(record1)) !== null && _getType3 !== void 0 ? _getType3 : null;
|
|
270
275
|
var nextType = (_getType4 = getType(record2)) !== null && _getType4 !== void 0 ? _getType4 : null;
|
|
271
|
-
process.env.NODE_ENV !== "production" ? warning(isClientID(nextID) || prevType === nextType, 'RelayModernRecord: Invalid record merge, expected both versions of ' + 'record `%s` to have the same `%s` but got conflicting types `%s` ' + 'and `%s`. The GraphQL server likely violated the globally unique ' + 'id requirement by returning the same id for different objects.', prevID, TYPENAME_KEY, prevType, nextType) : void 0;
|
|
276
|
+
process.env.NODE_ENV !== "production" ? warning(isClientID(nextID) && nextID !== ROOT_ID || prevType === nextType, 'RelayModernRecord: Invalid record merge, expected both versions of ' + 'record `%s` to have the same `%s` but got conflicting types `%s` ' + 'and `%s`. The GraphQL server likely violated the globally unique ' + 'id requirement by returning the same id for different objects.', prevID, TYPENAME_KEY, prevType, nextType) : void 0;
|
|
272
277
|
}
|
|
273
278
|
|
|
274
279
|
return Object.assign({}, record1, record2);
|
|
@@ -298,12 +303,12 @@ function setValue(record, storageKey, value) {
|
|
|
298
303
|
if (storageKey === ID_KEY) {
|
|
299
304
|
process.env.NODE_ENV !== "production" ? warning(prevID === value, 'RelayModernRecord: Invalid field update, expected both versions of ' + 'the record to have the same id, got `%s` and `%s`.', prevID, value) : void 0;
|
|
300
305
|
} else if (storageKey === TYPENAME_KEY) {
|
|
301
|
-
var _getType5
|
|
306
|
+
var _getType5;
|
|
302
307
|
|
|
303
308
|
// note: coalesce null/undefined to null
|
|
304
309
|
var prevType = (_getType5 = getType(record)) !== null && _getType5 !== void 0 ? _getType5 : null;
|
|
305
|
-
var nextType =
|
|
306
|
-
process.env.NODE_ENV !== "production" ? warning(isClientID(getDataID(record)) || prevType === nextType, 'RelayModernRecord: Invalid field update, expected both versions of ' + 'record `%s` to have the same `%s` but got conflicting types `%s` ' + 'and `%s`. The GraphQL server likely violated the globally unique ' + 'id requirement by returning the same id for different objects.', prevID, TYPENAME_KEY, prevType, nextType) : void 0;
|
|
310
|
+
var nextType = value !== null && value !== void 0 ? value : null;
|
|
311
|
+
process.env.NODE_ENV !== "production" ? warning(isClientID(getDataID(record)) && getDataID(record) !== ROOT_ID || prevType === nextType, 'RelayModernRecord: Invalid field update, expected both versions of ' + 'record `%s` to have the same `%s` but got conflicting types `%s` ' + 'and `%s`. The GraphQL server likely violated the globally unique ' + 'id requirement by returning the same id for different objects.', prevID, TYPENAME_KEY, prevType, nextType) : void 0;
|
|
307
312
|
}
|
|
308
313
|
}
|
|
309
314
|
|
|
@@ -22,7 +22,8 @@ var _require = require('./RelayConcreteVariables'),
|
|
|
22
22
|
var _require2 = require('./RelayStoreUtils'),
|
|
23
23
|
FRAGMENT_OWNER_KEY = _require2.FRAGMENT_OWNER_KEY,
|
|
24
24
|
FRAGMENTS_KEY = _require2.FRAGMENTS_KEY,
|
|
25
|
-
ID_KEY = _require2.ID_KEY
|
|
25
|
+
ID_KEY = _require2.ID_KEY,
|
|
26
|
+
IS_WITHIN_UNMATCHED_TYPE_REFINEMENT = _require2.IS_WITHIN_UNMATCHED_TYPE_REFINEMENT;
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* @public
|
|
@@ -58,12 +59,13 @@ function getSingularSelector(fragment, item) {
|
|
|
58
59
|
var dataID = item[ID_KEY];
|
|
59
60
|
var fragments = item[FRAGMENTS_KEY];
|
|
60
61
|
var mixedOwner = item[FRAGMENT_OWNER_KEY];
|
|
62
|
+
var isWithinUnmatchedTypeRefinement = item[IS_WITHIN_UNMATCHED_TYPE_REFINEMENT] === true;
|
|
61
63
|
|
|
62
64
|
if (typeof dataID === 'string' && typeof fragments === 'object' && fragments !== null && typeof fragments[fragment.name] === 'object' && fragments[fragment.name] !== null && typeof mixedOwner === 'object' && mixedOwner !== null) {
|
|
63
65
|
var owner = mixedOwner;
|
|
64
66
|
var argumentVariables = fragments[fragment.name];
|
|
65
67
|
var fragmentVariables = getFragmentVariables(fragment, owner.variables, argumentVariables);
|
|
66
|
-
return createReaderSelector(fragment, dataID, fragmentVariables, owner);
|
|
68
|
+
return createReaderSelector(fragment, dataID, fragmentVariables, owner, isWithinUnmatchedTypeRefinement);
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -292,9 +294,11 @@ function areEqualSelectors(thisSelector, thatSelector) {
|
|
|
292
294
|
}
|
|
293
295
|
|
|
294
296
|
function createReaderSelector(fragment, dataID, variables, request) {
|
|
297
|
+
var isWithinUnmatchedTypeRefinement = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
295
298
|
return {
|
|
296
299
|
kind: 'SingularReaderSelector',
|
|
297
300
|
dataID: dataID,
|
|
301
|
+
isWithinUnmatchedTypeRefinement: isWithinUnmatchedTypeRefinement,
|
|
298
302
|
node: fragment,
|
|
299
303
|
variables: variables,
|
|
300
304
|
owner: request
|