relay-runtime 10.0.1 → 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.
Files changed (70) hide show
  1. package/handlers/RelayDefaultHandlerProvider.js.flow +6 -0
  2. package/handlers/connection/MutationHandlers.js.flow +114 -3
  3. package/index.js +1 -1
  4. package/index.js.flow +16 -1
  5. package/lib/handlers/RelayDefaultHandlerProvider.js +9 -0
  6. package/lib/handlers/connection/MutationHandlers.js +138 -12
  7. package/lib/index.js +7 -0
  8. package/lib/mutations/RelayDeclarativeMutationConfig.js +2 -2
  9. package/lib/mutations/commitMutation.js +1 -4
  10. package/lib/mutations/validateMutation.js +27 -7
  11. package/lib/network/RelayQueryResponseCache.js +2 -2
  12. package/lib/query/GraphQLTag.js +2 -1
  13. package/lib/query/fetchQuery.js +2 -3
  14. package/lib/query/fetchQueryInternal.js +2 -3
  15. package/lib/store/DataChecker.js +82 -5
  16. package/lib/store/RelayModernEnvironment.js +18 -6
  17. package/lib/store/RelayModernFragmentSpecResolver.js +10 -1
  18. package/lib/store/RelayModernOperationDescriptor.js +6 -5
  19. package/lib/store/RelayModernQueryExecutor.js +44 -23
  20. package/lib/store/RelayModernStore.js +25 -14
  21. package/lib/store/RelayOperationTracker.js +2 -2
  22. package/lib/store/RelayPublishQueue.js +1 -1
  23. package/lib/store/RelayReader.js +196 -33
  24. package/lib/store/RelayRecordSourceMapImpl.js +2 -2
  25. package/lib/store/RelayReferenceMarker.js +89 -5
  26. package/lib/store/RelayResponseNormalizer.js +119 -19
  27. package/lib/store/RelayStoreReactFlightUtils.js +47 -0
  28. package/lib/store/defaultRequiredFieldLogger.js +18 -0
  29. package/lib/store/normalizeRelayPayload.js +1 -1
  30. package/lib/subscription/requestSubscription.js +2 -3
  31. package/lib/util/NormalizationNode.js +1 -5
  32. package/lib/util/RelayConcreteNode.js +2 -0
  33. package/lib/util/RelayFeatureFlags.js +5 -2
  34. package/lib/util/getFragmentIdentifier.js +12 -3
  35. package/lib/util/getOperation.js +33 -0
  36. package/lib/util/isEmptyObject.js +25 -0
  37. package/lib/util/recycleNodesInto.js +4 -1
  38. package/lib/util/reportMissingRequiredFields.js +48 -0
  39. package/mutations/commitMutation.js.flow +1 -2
  40. package/mutations/validateMutation.js.flow +34 -5
  41. package/network/RelayNetworkTypes.js.flow +22 -0
  42. package/package.json +2 -2
  43. package/query/GraphQLTag.js.flow +3 -1
  44. package/query/fetchQuery.js.flow +2 -2
  45. package/query/fetchQueryInternal.js.flow +0 -5
  46. package/relay-runtime.js +2 -2
  47. package/relay-runtime.min.js +2 -2
  48. package/store/DataChecker.js.flow +68 -2
  49. package/store/RelayModernEnvironment.js.flow +29 -9
  50. package/store/RelayModernFragmentSpecResolver.js.flow +13 -1
  51. package/store/RelayModernOperationDescriptor.js.flow +5 -1
  52. package/store/RelayModernQueryExecutor.js.flow +47 -23
  53. package/store/RelayModernStore.js.flow +31 -15
  54. package/store/RelayPublishQueue.js.flow +1 -1
  55. package/store/RelayReader.js.flow +180 -15
  56. package/store/RelayReferenceMarker.js.flow +72 -5
  57. package/store/RelayResponseNormalizer.js.flow +130 -19
  58. package/store/RelayStoreReactFlightUtils.js.flow +64 -0
  59. package/store/RelayStoreTypes.js.flow +90 -31
  60. package/store/defaultRequiredFieldLogger.js.flow +23 -0
  61. package/subscription/requestSubscription.js.flow +5 -2
  62. package/util/NormalizationNode.js.flow +17 -2
  63. package/util/ReaderNode.js.flow +20 -1
  64. package/util/RelayConcreteNode.js.flow +6 -0
  65. package/util/RelayFeatureFlags.js.flow +8 -1
  66. package/util/getFragmentIdentifier.js.flow +33 -9
  67. package/util/getOperation.js.flow +40 -0
  68. package/util/isEmptyObject.js.flow +25 -0
  69. package/util/recycleNodesInto.js.flow +11 -0
  70. package/util/reportMissingRequiredFields.js.flow +51 -0
@@ -21,7 +21,7 @@ var warning = require("fbjs/lib/warning");
21
21
  * All calls to this function should be transformed by the plugin.
22
22
  */
23
23
  function graphql(strings) {
24
- !false ? process.env.NODE_ENV !== "production" ? invariant(false, 'graphql: Unexpected invocation at runtime. Either the Babel transform ' + 'was not set up, or it failed to identify this call site. Make sure it ' + 'is being used verbatim as `graphql`.') : invariant(false) : void 0;
24
+ !false ? process.env.NODE_ENV !== "production" ? invariant(false, 'graphql: Unexpected invocation at runtime. Either the Babel transform ' + 'was not set up, or it failed to identify this call site. Make sure it ' + 'is being used verbatim as `graphql`. Note also that there cannot be ' + 'a space between graphql and the backtick that follows.') : invariant(false) : void 0;
25
25
  }
26
26
 
27
27
  function getNode(taggedNode) {
@@ -100,6 +100,7 @@ function getInlineDataFragment(taggedNode) {
100
100
 
101
101
  module.exports = {
102
102
  getFragment: getFragment,
103
+ getNode: getNode,
103
104
  getPaginationFragment: getPaginationFragment,
104
105
  getRefetchableFragment: getRefetchableFragment,
105
106
  getRequest: getRequest,
@@ -28,10 +28,9 @@ function fetchQuery(environment, taggedNode, variables, cacheConfig) {
28
28
  throw new Error('fetchQuery: Expected query operation');
29
29
  }
30
30
 
31
- var operation = createOperationDescriptor(query, variables);
31
+ var operation = createOperationDescriptor(query, variables, cacheConfig);
32
32
  return environment.execute({
33
- operation: operation,
34
- cacheConfig: cacheConfig
33
+ operation: operation
35
34
  }).map(function () {
36
35
  return environment.lookup(operation.fragment).data;
37
36
  }).toPromise();
@@ -82,11 +82,10 @@ var requestCachesByEnvironment = WEAKMAP_SUPPORTED ? new WeakMap() : new Map();
82
82
  * ```
83
83
  */
84
84
 
85
- function fetchQuery(environment, operation, options) {
85
+ function fetchQuery(environment, operation) {
86
86
  return fetchQueryDeduped(environment, operation.request.identifier, function () {
87
87
  return environment.execute({
88
- operation: operation,
89
- cacheConfig: options === null || options === void 0 ? void 0 : options.networkCacheConfig
88
+ operation: operation
90
89
  });
91
90
  });
92
91
  }
@@ -11,9 +11,9 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
  'use strict';
13
13
 
14
- function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { 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 it, 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; } } }; }
14
+ 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; } } }; }
15
15
 
16
- 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(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
+ 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); }
17
17
 
18
18
  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; }
19
19
 
@@ -27,12 +27,16 @@ var RelayRecordSourceMutator = require('../mutations/RelayRecordSourceMutator');
27
27
 
28
28
  var RelayRecordSourceProxy = require('../mutations/RelayRecordSourceProxy');
29
29
 
30
+ var RelayStoreReactFlightUtils = require('./RelayStoreReactFlightUtils');
31
+
30
32
  var RelayStoreUtils = require('./RelayStoreUtils');
31
33
 
32
34
  var cloneRelayHandleSourceField = require('./cloneRelayHandleSourceField');
33
35
 
34
36
  var cloneRelayScalarHandleSourceField = require('./cloneRelayScalarHandleSourceField');
35
37
 
38
+ var getOperation = require('../util/getOperation');
39
+
36
40
  var invariant = require("fbjs/lib/invariant");
37
41
 
38
42
  var _require = require('./ClientID'),
@@ -48,6 +52,7 @@ var _require3 = require('./TypeID'),
48
52
  var CONDITION = RelayConcreteNode.CONDITION,
49
53
  CLIENT_EXTENSION = RelayConcreteNode.CLIENT_EXTENSION,
50
54
  DEFER = RelayConcreteNode.DEFER,
55
+ FLIGHT_FIELD = RelayConcreteNode.FLIGHT_FIELD,
51
56
  FRAGMENT_SPREAD = RelayConcreteNode.FRAGMENT_SPREAD,
52
57
  INLINE_FRAGMENT = RelayConcreteNode.INLINE_FRAGMENT,
53
58
  LINKED_FIELD = RelayConcreteNode.LINKED_FIELD,
@@ -57,7 +62,8 @@ var CONDITION = RelayConcreteNode.CONDITION,
57
62
  SCALAR_HANDLE = RelayConcreteNode.SCALAR_HANDLE,
58
63
  STREAM = RelayConcreteNode.STREAM,
59
64
  TYPE_DISCRIMINATOR = RelayConcreteNode.TYPE_DISCRIMINATOR;
60
- var getModuleOperationKey = RelayStoreUtils.getModuleOperationKey,
65
+ var ROOT_ID = RelayStoreUtils.ROOT_ID,
66
+ getModuleOperationKey = RelayStoreUtils.getModuleOperationKey,
61
67
  getStorageKey = RelayStoreUtils.getStorageKey,
62
68
  getArgumentValues = RelayStoreUtils.getArgumentValues;
63
69
  /**
@@ -358,6 +364,7 @@ var DataChecker = /*#__PURE__*/function () {
358
364
  _this2._traverseSelections(selection.selections, dataID);
359
365
 
360
366
  break;
367
+ // $FlowFixMe[incompatible-type]
361
368
 
362
369
  case FRAGMENT_SPREAD:
363
370
  !false ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayAsyncLoader(): Unexpected ast kind `%s`.', selection.kind) : invariant(false) : void 0; // $FlowExpectedError[unreachable-code] - we need the break; for OSS linter
@@ -394,6 +401,15 @@ var DataChecker = /*#__PURE__*/function () {
394
401
 
395
402
  break;
396
403
 
404
+ case FLIGHT_FIELD:
405
+ if (RelayFeatureFlags.ENABLE_REACT_FLIGHT_COMPONENT_FIELD) {
406
+ _this2._checkFlightField(selection, dataID);
407
+ } else {
408
+ throw new Error('Flight fields are not yet supported.');
409
+ }
410
+
411
+ break;
412
+
397
413
  default:
398
414
  selection;
399
415
  !false ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayAsyncLoader(): Unexpected ast kind `%s`.', selection.kind) : invariant(false) : void 0;
@@ -416,9 +432,11 @@ var DataChecker = /*#__PURE__*/function () {
416
432
  return;
417
433
  }
418
434
 
419
- var operation = operationLoader.get(operationReference);
435
+ var normalizationRootNode = operationLoader.get(operationReference);
436
+
437
+ if (normalizationRootNode != null) {
438
+ var operation = getOperation(normalizationRootNode);
420
439
 
421
- if (operation != null) {
422
440
  this._traverse(operation, dataID);
423
441
  } else {
424
442
  // If the fragment is not available, we assume that the data cannot have been
@@ -487,6 +505,65 @@ var DataChecker = /*#__PURE__*/function () {
487
505
  }
488
506
  };
489
507
 
508
+ _proto._checkFlightField = function _checkFlightField(field, dataID) {
509
+ var storageKey = getStorageKey(field, this._variables);
510
+
511
+ var linkedID = this._mutator.getLinkedRecordID(dataID, storageKey);
512
+
513
+ if (linkedID == null) {
514
+ if (linkedID === undefined) {
515
+ this._handleMissing();
516
+
517
+ return;
518
+ }
519
+
520
+ return;
521
+ }
522
+
523
+ var tree = this._mutator.getValue(linkedID, RelayStoreReactFlightUtils.REACT_FLIGHT_TREE_STORAGE_KEY);
524
+
525
+ var reachableQueries = this._mutator.getValue(linkedID, RelayStoreReactFlightUtils.REACT_FLIGHT_QUERIES_STORAGE_KEY);
526
+
527
+ if (tree == null || !Array.isArray(reachableQueries)) {
528
+ this._handleMissing();
529
+
530
+ return;
531
+ }
532
+
533
+ var operationLoader = this._operationLoader;
534
+ !(operationLoader !== null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'DataChecker: Expected an operationLoader to be configured when using ' + 'React Flight.') : invariant(false) : void 0; // In Flight, the variables that are in scope for reachable queries aren't
535
+ // the same as what's in scope for the outer query.
536
+
537
+ var prevVariables = this._variables; // $FlowFixMe[incompatible-cast]
538
+
539
+ var _iterator4 = _createForOfIteratorHelper(reachableQueries),
540
+ _step4;
541
+
542
+ try {
543
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
544
+ var query = _step4.value;
545
+ this._variables = query.variables;
546
+ var normalizationRootNode = operationLoader.get(query.module);
547
+
548
+ if (normalizationRootNode != null) {
549
+ var operation = getOperation(normalizationRootNode);
550
+
551
+ this._traverseSelections(operation.selections, ROOT_ID);
552
+ } else {
553
+ // If the fragment is not available, we assume that the data cannot have
554
+ // been processed yet and must therefore be missing.
555
+ this._handleMissing();
556
+ }
557
+ }
558
+ } catch (err) {
559
+ _iterator4.e(err);
560
+ } finally {
561
+ _iterator4.f();
562
+ }
563
+
564
+ this._variables = prevVariables;
565
+ };
566
+
490
567
  return DataChecker;
491
568
  }();
492
569
 
@@ -35,6 +35,8 @@ var RelayRecordSource = require('./RelayRecordSource');
35
35
 
36
36
  var defaultGetDataID = require('./defaultGetDataID');
37
37
 
38
+ var defaultRequiredFieldLogger = require('./defaultRequiredFieldLogger');
39
+
38
40
  var generateID = require('../util/generateID');
39
41
 
40
42
  var invariant = require("fbjs/lib/invariant");
@@ -43,20 +45,26 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
43
45
  function RelayModernEnvironment(config) {
44
46
  var _this = this;
45
47
 
46
- var _config$log, _config$UNSTABLE_defa, _config$UNSTABLE_DO_N, _config$scheduler, _config$isServer, _config$operationTrac;
48
+ var _config$log, _config$requiredField, _config$UNSTABLE_defa, _config$UNSTABLE_DO_N, _config$scheduler, _config$isServer, _config$operationTrac;
47
49
 
48
50
  this.configName = config.configName;
49
51
  var handlerProvider = config.handlerProvider ? config.handlerProvider : RelayDefaultHandlerProvider;
50
52
  this._treatMissingFieldsAsNull = config.treatMissingFieldsAsNull === true;
51
53
  var operationLoader = config.operationLoader;
54
+ var reactFlightPayloadDeserializer = config.reactFlightPayloadDeserializer;
52
55
 
53
56
  if (process.env.NODE_ENV !== "production") {
54
57
  if (operationLoader != null) {
55
58
  !(typeof operationLoader === 'object' && typeof operationLoader.get === 'function' && typeof operationLoader.load === 'function') ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayModernEnvironment: Expected `operationLoader` to be an object ' + 'with get() and load() functions, got `%s`.', operationLoader) : invariant(false) : void 0;
56
59
  }
60
+
61
+ if (reactFlightPayloadDeserializer != null) {
62
+ !(typeof reactFlightPayloadDeserializer === 'function') ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayModernEnvironment: Expected `reactFlightPayloadDeserializer` ' + ' to be a function, got `%s`.', reactFlightPayloadDeserializer) : invariant(false) : void 0;
63
+ }
57
64
  }
58
65
 
59
66
  this.__log = (_config$log = config.log) !== null && _config$log !== void 0 ? _config$log : emptyFunction;
67
+ this.requiredFieldLogger = (_config$requiredField = config.requiredFieldLogger) !== null && _config$requiredField !== void 0 ? _config$requiredField : defaultRequiredFieldLogger;
60
68
  this._defaultRenderPolicy = ((_config$UNSTABLE_defa = config.UNSTABLE_defaultRenderPolicy) !== null && _config$UNSTABLE_defa !== void 0 ? _config$UNSTABLE_defa : RelayFeatureFlags.ENABLE_PARTIAL_RENDERING_DEFAULT === true) ? 'partial' : 'full';
61
69
  this._operationLoader = operationLoader;
62
70
  this._operationExecutions = new Map();
@@ -93,6 +101,7 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
93
101
 
94
102
  this._missingFieldHandlers = config.missingFieldHandlers;
95
103
  this._operationTracker = (_config$operationTrac = config.operationTracker) !== null && _config$operationTrac !== void 0 ? _config$operationTrac : new RelayOperationTracker();
104
+ this._reactFlightPayloadDeserializer = reactFlightPayloadDeserializer;
96
105
  }
97
106
 
98
107
  var _proto = RelayModernEnvironment.prototype;
@@ -174,6 +183,7 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
174
183
  operationLoader: _this5._operationLoader,
175
184
  optimisticConfig: optimisticConfig,
176
185
  publishQueue: _this5._publishQueue,
186
+ reactFlightPayloadDeserializer: _this5._reactFlightPayloadDeserializer,
177
187
  scheduler: _this5._scheduler,
178
188
  sink: sink,
179
189
  source: source,
@@ -212,6 +222,7 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
212
222
  operationLoader: _this6._operationLoader,
213
223
  optimisticConfig: null,
214
224
  publishQueue: _this6._publishQueue,
225
+ reactFlightPayloadDeserializer: _this6._reactFlightPayloadDeserializer,
215
226
  scheduler: _this6._scheduler,
216
227
  sink: sink,
217
228
  source: RelayObservable.from({
@@ -300,7 +311,6 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
300
311
  var _this9 = this;
301
312
 
302
313
  var operation = _ref.operation,
303
- cacheConfig = _ref.cacheConfig,
304
314
  updater = _ref.updater;
305
315
 
306
316
  var _this$__createLogObse = this.__createLogObserver(operation.request.node.params, operation.request.variables),
@@ -308,7 +318,7 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
308
318
  logRequestInfo = _this$__createLogObse[1];
309
319
 
310
320
  return RelayObservable.create(function (sink) {
311
- var source = _this9._network.execute(operation.request.node.params, operation.request.variables, cacheConfig || {}, null, logRequestInfo)["do"](logObserver);
321
+ var source = _this9._network.execute(operation.request.node.params, operation.request.variables, operation.request.cacheConfig || {}, null, logRequestInfo)["do"](logObserver);
312
322
 
313
323
  var executor = RelayModernQueryExecutor.execute({
314
324
  operation: operation,
@@ -316,6 +326,7 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
316
326
  operationLoader: _this9._operationLoader,
317
327
  optimisticConfig: null,
318
328
  publishQueue: _this9._publishQueue,
329
+ reactFlightPayloadDeserializer: _this9._reactFlightPayloadDeserializer,
319
330
  scheduler: _this9._scheduler,
320
331
  sink: sink,
321
332
  source: source,
@@ -345,8 +356,7 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
345
356
  _proto.executeMutation = function executeMutation(_ref2) {
346
357
  var _this10 = this;
347
358
 
348
- var cacheConfig = _ref2.cacheConfig,
349
- operation = _ref2.operation,
359
+ var operation = _ref2.operation,
350
360
  optimisticResponse = _ref2.optimisticResponse,
351
361
  optimisticUpdater = _ref2.optimisticUpdater,
352
362
  updater = _ref2.updater,
@@ -367,7 +377,7 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
367
377
  };
368
378
  }
369
379
 
370
- var source = _this10._network.execute(operation.request.node.params, operation.request.variables, _objectSpread({}, cacheConfig, {
380
+ var source = _this10._network.execute(operation.request.node.params, operation.request.variables, _objectSpread(_objectSpread({}, operation.request.cacheConfig), {}, {
371
381
  force: true
372
382
  }), uploadables, logRequestInfo)["do"](logObserver);
373
383
 
@@ -377,6 +387,7 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
377
387
  operationLoader: _this10._operationLoader,
378
388
  optimisticConfig: optimisticConfig,
379
389
  publishQueue: _this10._publishQueue,
390
+ reactFlightPayloadDeserializer: _this10._reactFlightPayloadDeserializer,
380
391
  scheduler: _this10._scheduler,
381
392
  sink: sink,
382
393
  source: source,
@@ -415,6 +426,7 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
415
426
  operationTracker: _this11._operationTracker,
416
427
  optimisticConfig: null,
417
428
  publishQueue: _this11._publishQueue,
429
+ reactFlightPayloadDeserializer: _this11._reactFlightPayloadDeserializer,
418
430
  scheduler: _this11._scheduler,
419
431
  sink: sink,
420
432
  source: source,
@@ -26,6 +26,8 @@ var invariant = require("fbjs/lib/invariant");
26
26
 
27
27
  var isScalarAndEqual = require('../util/isScalarAndEqual');
28
28
 
29
+ var reportMissingRequiredFields = require('../util/reportMissingRequiredFields');
30
+
29
31
  var warning = require("fbjs/lib/warning");
30
32
 
31
33
  var _require = require('../query/fetchQueryInternal'),
@@ -199,6 +201,7 @@ var SelectorResolver = /*#__PURE__*/function () {
199
201
  (0, _defineProperty2["default"])(this, "_onChange", function (snapshot) {
200
202
  _this2._data = snapshot.data;
201
203
  _this2._isMissingData = snapshot.isMissingData;
204
+ _this2._missingRequiredFields = snapshot.missingRequiredFields;
202
205
 
203
206
  _this2._callback();
204
207
  });
@@ -208,6 +211,7 @@ var SelectorResolver = /*#__PURE__*/function () {
208
211
  this._callback = callback;
209
212
  this._data = _snapshot.data;
210
213
  this._isMissingData = _snapshot.isMissingData;
214
+ this._missingRequiredFields = _snapshot.missingRequiredFields;
211
215
  this._environment = environment;
212
216
  this._selector = selector;
213
217
  this._subscription = environment.subscribe(_snapshot, this._onChange);
@@ -256,6 +260,10 @@ var SelectorResolver = /*#__PURE__*/function () {
256
260
  }
257
261
  }
258
262
 
263
+ if (this._missingRequiredFields != null) {
264
+ reportMissingRequiredFields(this._environment, this._missingRequiredFields);
265
+ }
266
+
259
267
  return this._data;
260
268
  };
261
269
 
@@ -270,6 +278,7 @@ var SelectorResolver = /*#__PURE__*/function () {
270
278
 
271
279
  this._data = snapshot.data;
272
280
  this._isMissingData = snapshot.isMissingData;
281
+ this._missingRequiredFields = snapshot.missingRequiredFields;
273
282
  this._selector = selector;
274
283
  this._subscription = this._environment.subscribe(snapshot, this._onChange);
275
284
  };
@@ -287,7 +296,7 @@ var SelectorResolver = /*#__PURE__*/function () {
287
296
  } // NOTE: We manually create the request descriptor here instead of
288
297
  // calling createOperationDescriptor() because we want to set a
289
298
  // descriptor with *unaltered* variables as the fragment owner.
290
- // This is a hack that allows us to preserve exisiting (broken)
299
+ // This is a hack that allows us to preserve existing (broken)
291
300
  // behavior of RelayModern containers while using fragment ownership
292
301
  // to propagate variables instead of Context.
293
302
  // For more details, see the summary of D13999308
@@ -30,11 +30,11 @@ var _require3 = require('./RelayStoreUtils'),
30
30
  * are filtered to exclude variables that do not match defined arguments on the
31
31
  * operation, and default values are populated for null values.
32
32
  */
33
- function createOperationDescriptor(request, variables) {
34
- var dataID = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ROOT_ID;
33
+ function createOperationDescriptor(request, variables, cacheConfig) {
34
+ var dataID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ROOT_ID;
35
35
  var operation = request.operation;
36
36
  var operationVariables = getOperationVariables(operation, variables);
37
- var requestDescriptor = createRequestDescriptor(request, operationVariables);
37
+ var requestDescriptor = createRequestDescriptor(request, operationVariables, cacheConfig);
38
38
  var operationDescriptor = {
39
39
  fragment: createReaderSelector(request.fragment, dataID, operationVariables, requestDescriptor),
40
40
  request: requestDescriptor,
@@ -53,11 +53,12 @@ function createOperationDescriptor(request, variables) {
53
53
  return operationDescriptor;
54
54
  }
55
55
 
56
- function createRequestDescriptor(request, variables) {
56
+ function createRequestDescriptor(request, variables, cacheConfig) {
57
57
  var requestDescriptor = {
58
58
  identifier: getRequestIdentifier(request.params, variables),
59
59
  node: request,
60
- variables: variables
60
+ variables: variables,
61
+ cacheConfig: cacheConfig
61
62
  };
62
63
 
63
64
  if (process.env.NODE_ENV !== "production") {
@@ -21,9 +21,9 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
21
21
 
22
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
23
 
24
- function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { 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 it, 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; } } }; }
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
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(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
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
27
 
28
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
29
 
@@ -37,6 +37,8 @@ var RelayRecordSource = require('./RelayRecordSource');
37
37
 
38
38
  var RelayResponseNormalizer = require('./RelayResponseNormalizer');
39
39
 
40
+ var getOperation = require('../util/getOperation');
41
+
40
42
  var invariant = require("fbjs/lib/invariant");
41
43
 
42
44
  var stableCopy = require('../util/stableCopy');
@@ -81,7 +83,8 @@ var Executor = /*#__PURE__*/function () {
81
83
  operationTracker = _ref.operationTracker,
82
84
  treatMissingFieldsAsNull = _ref.treatMissingFieldsAsNull,
83
85
  getDataID = _ref.getDataID,
84
- isClientPayload = _ref.isClientPayload;
86
+ isClientPayload = _ref.isClientPayload,
87
+ reactFlightPayloadDeserializer = _ref.reactFlightPayloadDeserializer;
85
88
  this._getDataID = getDataID;
86
89
  this._treatMissingFieldsAsNull = treatMissingFieldsAsNull;
87
90
  this._incrementalPayloadsPending = false;
@@ -103,6 +106,7 @@ var Executor = /*#__PURE__*/function () {
103
106
  this._subscriptions = new Map();
104
107
  this._updater = updater;
105
108
  this._isClientPayload = isClientPayload === true;
109
+ this._reactFlightPayloadDeserializer = reactFlightPayloadDeserializer;
106
110
  var id = this._nextSubscriptionId++;
107
111
  source.subscribe({
108
112
  complete: function complete() {
@@ -166,6 +170,12 @@ var Executor = /*#__PURE__*/function () {
166
170
  this._incrementalResults.clear();
167
171
 
168
172
  this._completeOperationTracker();
173
+
174
+ if (this._retainDisposable) {
175
+ this._retainDisposable.dispose();
176
+
177
+ this._retainDisposable = null;
178
+ }
169
179
  };
170
180
 
171
181
  _proto._updateActiveState = function _updateActiveState() {
@@ -387,17 +397,17 @@ var Executor = /*#__PURE__*/function () {
387
397
  nonIncrementalResponses = _partitionGraphQLResp[0],
388
398
  incrementalResponses = _partitionGraphQLResp[1]; // In theory this doesn't preserve the ordering of the batch.
389
399
  // The idea is that a batch is always:
390
- // * at-most one non-incremental payload
391
- // * followed zero or more incremental payloads
400
+ // * at most one non-incremental payload
401
+ // * followed by zero or more incremental payloads
392
402
  // The non-incremental payload can appear if the server sends a batch
393
- // w the initial payload followed by some early-to-resolve incremental
403
+ // with the initial payload followed by some early-to-resolve incremental
394
404
  // payloads (although, can that even happen?)
395
405
 
396
406
 
397
407
  if (nonIncrementalResponses.length > 0) {
398
- var payloadFollowups = this._processResponses(nonIncrementalResponses); // Please note, that we're passing `this._operation` to the publish
408
+ var payloadFollowups = this._processResponses(nonIncrementalResponses); // Please note that we're passing `this._operation` to the publish
399
409
  // queue here, which will later passed to the store (via notify)
400
- // to indicate that this is an operation that cause the store to update
410
+ // to indicate that this is an operation that caused the store to update
401
411
 
402
412
 
403
413
  var updatedOwners = this._publishQueue.run(this._operation);
@@ -405,6 +415,10 @@ var Executor = /*#__PURE__*/function () {
405
415
  this._updateOperationTracker(updatedOwners);
406
416
 
407
417
  this._processPayloadFollowups(payloadFollowups);
418
+
419
+ if (this._incrementalPayloadsPending && !this._retainDisposable) {
420
+ this._retainDisposable = this._store.retain(this._operation);
421
+ }
408
422
  }
409
423
 
410
424
  if (incrementalResponses.length > 0) {
@@ -438,6 +452,7 @@ var Executor = /*#__PURE__*/function () {
438
452
  var payload = normalizeResponse(response, this._operation.root, ROOT_TYPE, {
439
453
  getDataID: this._getDataID,
440
454
  path: [],
455
+ reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer,
441
456
  treatMissingFieldsAsNull: treatMissingFieldsAsNull
442
457
  });
443
458
  validateOptimisticResponsePayload(payload);
@@ -488,9 +503,9 @@ var Executor = /*#__PURE__*/function () {
488
503
  if (operation == null) {
489
504
  this._processAsyncOptimisticModuleImport(operationLoader, moduleImportPayload);
490
505
  } else {
491
- var moduleImportOptimisitcUpdates = this._processOptimisticModuleImport(operation, moduleImportPayload);
506
+ var moduleImportOptimisticUpdates = this._processOptimisticModuleImport(operation, moduleImportPayload);
492
507
 
493
- optimisticUpdates.push.apply(optimisticUpdates, (0, _toConsumableArray2["default"])(moduleImportOptimisitcUpdates));
508
+ optimisticUpdates.push.apply(optimisticUpdates, (0, _toConsumableArray2["default"])(moduleImportOptimisticUpdates));
494
509
  }
495
510
  }
496
511
  } catch (err) {
@@ -508,11 +523,13 @@ var Executor = /*#__PURE__*/function () {
508
523
  }, selector, moduleImportPayload.typeName, {
509
524
  getDataID: this._getDataID,
510
525
  path: moduleImportPayload.path,
526
+ reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer,
511
527
  treatMissingFieldsAsNull: this._treatMissingFieldsAsNull
512
528
  });
513
529
  };
514
530
 
515
- _proto._processOptimisticModuleImport = function _processOptimisticModuleImport(operation, moduleImportPayload) {
531
+ _proto._processOptimisticModuleImport = function _processOptimisticModuleImport(normalizationRootNode, moduleImportPayload) {
532
+ var operation = getOperation(normalizationRootNode);
516
533
  var optimisticUpdates = [];
517
534
 
518
535
  var modulePayload = this._normalizeModuleImport(moduleImportPayload, operation);
@@ -537,18 +554,18 @@ var Executor = /*#__PURE__*/function () {
537
554
  return;
538
555
  }
539
556
 
540
- var moduleImportOptimisitcUpdates = _this7._processOptimisticModuleImport(operation, moduleImportPayload);
557
+ var moduleImportOptimisticUpdates = _this7._processOptimisticModuleImport(operation, moduleImportPayload);
541
558
 
542
- moduleImportOptimisitcUpdates.forEach(function (update) {
559
+ moduleImportOptimisticUpdates.forEach(function (update) {
543
560
  return _this7._publishQueue.applyUpdate(update);
544
561
  });
545
562
 
546
563
  if (_this7._optimisticUpdates == null) {
547
- process.env.NODE_ENV !== "production" ? warning(false, 'RelayModernQueryExecutor: Unexpected ModuleImport optimisitc ' + 'update in operation %s.' + _this7._operation.request.node.params.name) : void 0;
564
+ process.env.NODE_ENV !== "production" ? warning(false, 'RelayModernQueryExecutor: Unexpected ModuleImport optimistic ' + 'update in operation %s.' + _this7._operation.request.node.params.name) : void 0;
548
565
  } else {
549
566
  var _this$_optimisticUpda;
550
567
 
551
- (_this$_optimisticUpda = _this7._optimisticUpdates).push.apply(_this$_optimisticUpda, (0, _toConsumableArray2["default"])(moduleImportOptimisitcUpdates));
568
+ (_this$_optimisticUpda = _this7._optimisticUpdates).push.apply(_this$_optimisticUpda, (0, _toConsumableArray2["default"])(moduleImportOptimisticUpdates));
552
569
 
553
570
  _this7._publishQueue.run();
554
571
  }
@@ -575,8 +592,9 @@ var Executor = /*#__PURE__*/function () {
575
592
  return responses.map(function (payloadPart) {
576
593
  var relayPayload = normalizeResponse(payloadPart, _this8._operation.root, ROOT_TYPE, {
577
594
  getDataID: _this8._getDataID,
578
- treatMissingFieldsAsNull: _this8._treatMissingFieldsAsNull,
579
- path: []
595
+ path: [],
596
+ reactFlightPayloadDeserializer: _this8._reactFlightPayloadDeserializer,
597
+ treatMissingFieldsAsNull: _this8._treatMissingFieldsAsNull
580
598
  });
581
599
 
582
600
  _this8._publishQueue.commitPayload(_this8._operation, relayPayload, _this8._updater);
@@ -676,12 +694,13 @@ var Executor = /*#__PURE__*/function () {
676
694
  _proto._processModuleImportPayload = function _processModuleImportPayload(moduleImportPayload, operationLoader) {
677
695
  var _this10 = this;
678
696
 
679
- var syncOperation = operationLoader.get(moduleImportPayload.operationReference);
697
+ var node = operationLoader.get(moduleImportPayload.operationReference);
680
698
 
681
- if (syncOperation != null) {
682
- // 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
683
701
  // data synchronously.
684
- this._handleModuleImportPayload(moduleImportPayload, syncOperation);
702
+
703
+ this._handleModuleImportPayload(moduleImportPayload, operation);
685
704
 
686
705
  this._maybeCompleteSubscriptionOperationTracking();
687
706
  } else {
@@ -705,7 +724,7 @@ var Executor = /*#__PURE__*/function () {
705
724
  })).map(function (operation) {
706
725
  if (operation != null) {
707
726
  _this10._schedule(function () {
708
- _this10._handleModuleImportPayload(moduleImportPayload, operation);
727
+ _this10._handleModuleImportPayload(moduleImportPayload, getOperation(operation));
709
728
  });
710
729
  }
711
730
  }).subscribe({
@@ -917,6 +936,7 @@ var Executor = /*#__PURE__*/function () {
917
936
  var relayPayload = normalizeResponse(response, placeholder.selector, placeholder.typeName, {
918
937
  getDataID: this._getDataID,
919
938
  path: placeholder.path,
939
+ reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer,
920
940
  treatMissingFieldsAsNull: this._treatMissingFieldsAsNull
921
941
  });
922
942
 
@@ -1068,6 +1088,7 @@ var Executor = /*#__PURE__*/function () {
1068
1088
  var relayPayload = normalizeResponse(response, selector, typeName, {
1069
1089
  getDataID: this._getDataID,
1070
1090
  path: [].concat((0, _toConsumableArray2["default"])(normalizationPath), [responseKey, String(itemIndex)]),
1091
+ reactFlightPayloadDeserializer: this._reactFlightPayloadDeserializer,
1071
1092
  treatMissingFieldsAsNull: this._treatMissingFieldsAsNull
1072
1093
  });
1073
1094
  return {
@@ -1128,7 +1149,7 @@ function normalizeResponse(response, selector, typeName, options) {
1128
1149
  var record = RelayModernRecord.create(selector.dataID, typeName);
1129
1150
  source.set(selector.dataID, record);
1130
1151
  var relayPayload = RelayResponseNormalizer.normalize(source, selector, data, options);
1131
- return _objectSpread({}, relayPayload, {
1152
+ return _objectSpread(_objectSpread({}, relayPayload), {}, {
1132
1153
  errors: errors,
1133
1154
  isFinal: ((_response$extensions3 = response.extensions) === null || _response$extensions3 === void 0 ? void 0 : _response$extensions3.is_final) === true
1134
1155
  });