relay-runtime 10.1.3 → 11.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/handlers/connection/ConnectionHandler.js.flow +60 -0
  2. package/handlers/connection/MutationHandlers.js.flow +28 -0
  3. package/index.js +1 -1
  4. package/index.js.flow +9 -3
  5. package/lib/handlers/RelayDefaultHandlerProvider.js +1 -1
  6. package/lib/handlers/connection/ConnectionHandler.js +68 -6
  7. package/lib/handlers/connection/MutationHandlers.js +67 -8
  8. package/lib/index.js +3 -0
  9. package/lib/multi-actor-environment/ActorIdentifier.js +23 -0
  10. package/lib/multi-actor-environment/ActorSpecificEnvironment.js +108 -0
  11. package/lib/multi-actor-environment/MultiActorEnvironment.js +156 -0
  12. package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +11 -0
  13. package/lib/multi-actor-environment/index.js +17 -0
  14. package/lib/mutations/RelayRecordProxy.js +1 -1
  15. package/lib/mutations/RelayRecordSourceMutator.js +1 -1
  16. package/lib/mutations/RelayRecordSourceProxy.js +1 -1
  17. package/lib/mutations/RelayRecordSourceSelectorProxy.js +1 -1
  18. package/lib/mutations/applyOptimisticMutation.js +1 -1
  19. package/lib/mutations/commitMutation.js +1 -1
  20. package/lib/mutations/validateMutation.js +36 -15
  21. package/lib/network/RelayNetwork.js +1 -1
  22. package/lib/network/RelayQueryResponseCache.js +3 -2
  23. package/lib/query/GraphQLTag.js +1 -1
  24. package/lib/query/fetchQuery.js +129 -13
  25. package/lib/query/fetchQueryInternal.js +3 -4
  26. package/lib/query/fetchQuery_DEPRECATED.js +39 -0
  27. package/lib/store/DataChecker.js +26 -14
  28. package/lib/store/{RelayModernQueryExecutor.js → OperationExecutor.js} +117 -47
  29. package/lib/store/RelayConcreteVariables.js +8 -4
  30. package/lib/store/RelayModernEnvironment.js +105 -136
  31. package/lib/store/RelayModernFragmentSpecResolver.js +16 -9
  32. package/lib/store/RelayModernRecord.js +1 -1
  33. package/lib/store/RelayModernSelector.js +1 -1
  34. package/lib/store/RelayModernStore.js +19 -20
  35. package/lib/store/RelayOperationTracker.js +55 -49
  36. package/lib/store/RelayPublishQueue.js +9 -5
  37. package/lib/store/RelayReader.js +68 -14
  38. package/lib/store/RelayReferenceMarker.js +28 -14
  39. package/lib/store/RelayResponseNormalizer.js +109 -15
  40. package/lib/store/RelayStoreReactFlightUtils.js +6 -4
  41. package/lib/store/RelayStoreSubscriptions.js +18 -8
  42. package/lib/store/RelayStoreSubscriptionsUsingMapByID.js +90 -30
  43. package/lib/store/RelayStoreUtils.js +3 -2
  44. package/lib/store/ResolverFragments.js +57 -0
  45. package/lib/store/cloneRelayHandleSourceField.js +1 -1
  46. package/lib/store/cloneRelayScalarHandleSourceField.js +1 -1
  47. package/lib/store/createFragmentSpecResolver.js +2 -2
  48. package/lib/store/createRelayContext.js +1 -1
  49. package/lib/store/defaultGetDataID.js +3 -1
  50. package/lib/store/hasOverlappingIDs.js +11 -3
  51. package/lib/store/readInlineData.js +1 -1
  52. package/lib/subscription/requestSubscription.js +33 -5
  53. package/lib/util/RelayConcreteNode.js +2 -0
  54. package/lib/util/RelayFeatureFlags.js +8 -3
  55. package/lib/util/RelayProfiler.js +17 -187
  56. package/lib/util/RelayReplaySubject.js +1 -1
  57. package/lib/util/deepFreeze.js +1 -0
  58. package/lib/util/getRelayHandleKey.js +1 -1
  59. package/lib/util/getRequestIdentifier.js +1 -1
  60. package/multi-actor-environment/ActorIdentifier.js.flow +27 -0
  61. package/multi-actor-environment/ActorSpecificEnvironment.js.flow +189 -0
  62. package/multi-actor-environment/MultiActorEnvironment.js.flow +233 -0
  63. package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +196 -0
  64. package/multi-actor-environment/index.js.flow +24 -0
  65. package/mutations/RelayRecordSourceProxy.js.flow +3 -2
  66. package/mutations/commitMutation.js.flow +1 -1
  67. package/mutations/validateMutation.js.flow +40 -15
  68. package/network/RelayNetworkTypes.js.flow +31 -11
  69. package/network/RelayQueryResponseCache.js.flow +2 -1
  70. package/package.json +3 -2
  71. package/query/fetchQuery.js.flow +147 -20
  72. package/query/fetchQueryInternal.js.flow +2 -3
  73. package/query/fetchQuery_DEPRECATED.js.flow +47 -0
  74. package/relay-runtime.js +2 -2
  75. package/relay-runtime.min.js +2 -2
  76. package/store/DataChecker.js.flow +23 -15
  77. package/store/{RelayModernQueryExecutor.js.flow → OperationExecutor.js.flow} +128 -40
  78. package/store/RelayConcreteVariables.js.flow +5 -0
  79. package/store/RelayModernEnvironment.js.flow +100 -130
  80. package/store/RelayModernFragmentSpecResolver.js.flow +30 -8
  81. package/store/RelayModernStore.js.flow +28 -24
  82. package/store/RelayOperationTracker.js.flow +69 -56
  83. package/store/RelayPublishQueue.js.flow +7 -4
  84. package/store/RelayReader.js.flow +63 -11
  85. package/store/RelayRecordSource.js.flow +3 -3
  86. package/store/RelayRecordSourceMapImpl.js.flow +6 -2
  87. package/store/RelayReferenceMarker.js.flow +28 -18
  88. package/store/RelayResponseNormalizer.js.flow +134 -23
  89. package/store/RelayStoreReactFlightUtils.js.flow +9 -4
  90. package/store/RelayStoreSubscriptions.js.flow +22 -7
  91. package/store/RelayStoreSubscriptionsUsingMapByID.js.flow +36 -12
  92. package/store/RelayStoreTypes.js.flow +51 -22
  93. package/store/RelayStoreUtils.js.flow +2 -1
  94. package/store/ResolverFragments.js.flow +125 -0
  95. package/store/createFragmentSpecResolver.js.flow +2 -0
  96. package/store/defaultGetDataID.js.flow +3 -1
  97. package/store/hasOverlappingIDs.js.flow +11 -9
  98. package/subscription/requestSubscription.js.flow +25 -2
  99. package/util/NormalizationNode.js.flow +13 -0
  100. package/util/ReaderNode.js.flow +14 -1
  101. package/util/RelayConcreteNode.js.flow +2 -0
  102. package/util/RelayFeatureFlags.js.flow +12 -2
  103. package/util/RelayProfiler.js.flow +22 -194
  104. package/util/RelayRuntimeTypes.js.flow +4 -5
  105. package/util/deepFreeze.js.flow +2 -1
  106. package/util/isEmptyObject.js.flow +1 -1
@@ -15,12 +15,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
15
15
 
16
16
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
17
17
 
18
+ var OperationExecutor = require('./OperationExecutor');
19
+
18
20
  var RelayDefaultHandlerProvider = require('../handlers/RelayDefaultHandlerProvider');
19
21
 
20
22
  var RelayFeatureFlags = require('../util/RelayFeatureFlags');
21
23
 
22
- var RelayModernQueryExecutor = require('./RelayModernQueryExecutor');
23
-
24
24
  var RelayObservable = require('../network/RelayObservable');
25
25
 
26
26
  var RelayOperationTracker = require('../store/RelayOperationTracker');
@@ -35,19 +35,19 @@ var defaultRequiredFieldLogger = require('./defaultRequiredFieldLogger');
35
35
 
36
36
  var generateID = require('../util/generateID');
37
37
 
38
- var invariant = require("fbjs/lib/invariant");
38
+ var invariant = require('invariant');
39
39
 
40
40
  var RelayModernEnvironment = /*#__PURE__*/function () {
41
41
  function RelayModernEnvironment(config) {
42
42
  var _this = this;
43
43
 
44
- var _config$log, _config$requiredField, _config$UNSTABLE_defa, _config$UNSTABLE_DO_N, _config$scheduler, _config$isServer, _config$operationTrac;
44
+ var _config$log, _config$requiredField, _config$UNSTABLE_defa, _config$getDataID, _config$handlerProvid, _config$scheduler, _config$isServer, _config$operationTrac;
45
45
 
46
46
  this.configName = config.configName;
47
- var handlerProvider = config.handlerProvider ? config.handlerProvider : RelayDefaultHandlerProvider;
48
47
  this._treatMissingFieldsAsNull = config.treatMissingFieldsAsNull === true;
49
48
  var operationLoader = config.operationLoader;
50
49
  var reactFlightPayloadDeserializer = config.reactFlightPayloadDeserializer;
50
+ var reactFlightServerErrorHandler = config.reactFlightServerErrorHandler;
51
51
 
52
52
  if (process.env.NODE_ENV !== "production") {
53
53
  if (operationLoader != null) {
@@ -65,8 +65,8 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
65
65
  this._operationLoader = operationLoader;
66
66
  this._operationExecutions = new Map();
67
67
  this._network = this.__wrapNetworkWithLogObserver(config.network);
68
- this._getDataID = (_config$UNSTABLE_DO_N = config.UNSTABLE_DO_NOT_USE_getDataID) !== null && _config$UNSTABLE_DO_N !== void 0 ? _config$UNSTABLE_DO_N : defaultGetDataID;
69
- this._publishQueue = new RelayPublishQueue(config.store, handlerProvider, this._getDataID);
68
+ this._getDataID = (_config$getDataID = config.getDataID) !== null && _config$getDataID !== void 0 ? _config$getDataID : defaultGetDataID;
69
+ this._publishQueue = new RelayPublishQueue(config.store, (_config$handlerProvid = config.handlerProvider) !== null && _config$handlerProvid !== void 0 ? _config$handlerProvid : RelayDefaultHandlerProvider, this._getDataID);
70
70
  this._scheduler = (_config$scheduler = config.scheduler) !== null && _config$scheduler !== void 0 ? _config$scheduler : null;
71
71
  this._store = config.store;
72
72
  this.options = config.options;
@@ -98,6 +98,8 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
98
98
  this._missingFieldHandlers = config.missingFieldHandlers;
99
99
  this._operationTracker = (_config$operationTrac = config.operationTracker) !== null && _config$operationTrac !== void 0 ? _config$operationTrac : new RelayOperationTracker();
100
100
  this._reactFlightPayloadDeserializer = reactFlightPayloadDeserializer;
101
+ this._reactFlightServerErrorHandler = reactFlightServerErrorHandler;
102
+ this._shouldProcessClientComponents = config.shouldProcessClientComponents;
101
103
  }
102
104
 
103
105
  var _proto = RelayModernEnvironment.prototype;
@@ -169,30 +171,16 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
169
171
  };
170
172
 
171
173
  _proto.applyMutation = function applyMutation(optimisticConfig) {
172
- var _this5 = this;
173
-
174
- var subscription = RelayObservable.create(function (sink) {
175
- var source = RelayObservable.create(function (_sink) {});
176
- var executor = RelayModernQueryExecutor.execute({
177
- operation: optimisticConfig.operation,
178
- operationExecutions: _this5._operationExecutions,
179
- operationLoader: _this5._operationLoader,
180
- optimisticConfig: optimisticConfig,
181
- publishQueue: _this5._publishQueue,
182
- reactFlightPayloadDeserializer: _this5._reactFlightPayloadDeserializer,
183
- scheduler: _this5._scheduler,
184
- sink: sink,
185
- source: source,
186
- store: _this5._store,
187
- updater: null,
188
- operationTracker: _this5._operationTracker,
189
- getDataID: _this5._getDataID,
190
- treatMissingFieldsAsNull: _this5._treatMissingFieldsAsNull
191
- });
192
- return function () {
193
- return executor.cancel();
194
- };
174
+ var subscription = this._execute({
175
+ createSource: function createSource() {
176
+ return RelayObservable.create(function (_sink) {});
177
+ },
178
+ isClientPayload: false,
179
+ operation: optimisticConfig.operation,
180
+ optimisticConfig: optimisticConfig,
181
+ updater: null
195
182
  }).subscribe({});
183
+
196
184
  return {
197
185
  dispose: function dispose() {
198
186
  return subscription.unsubscribe();
@@ -209,41 +197,26 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
209
197
  };
210
198
 
211
199
  _proto.commitPayload = function commitPayload(operation, payload) {
212
- var _this6 = this;
213
-
214
- RelayObservable.create(function (sink) {
215
- var executor = RelayModernQueryExecutor.execute({
216
- operation: operation,
217
- operationExecutions: _this6._operationExecutions,
218
- operationLoader: _this6._operationLoader,
219
- optimisticConfig: null,
220
- publishQueue: _this6._publishQueue,
221
- reactFlightPayloadDeserializer: _this6._reactFlightPayloadDeserializer,
222
- scheduler: _this6._scheduler,
223
- sink: sink,
224
- source: RelayObservable.from({
200
+ this._execute({
201
+ createSource: function createSource() {
202
+ return RelayObservable.from({
225
203
  data: payload
226
- }),
227
- store: _this6._store,
228
- updater: null,
229
- operationTracker: _this6._operationTracker,
230
- getDataID: _this6._getDataID,
231
- isClientPayload: true,
232
- treatMissingFieldsAsNull: _this6._treatMissingFieldsAsNull
233
- });
234
- return function () {
235
- return executor.cancel();
236
- };
204
+ });
205
+ },
206
+ isClientPayload: true,
207
+ operation: operation,
208
+ optimisticConfig: null,
209
+ updater: null
237
210
  }).subscribe({});
238
211
  };
239
212
 
240
213
  _proto.commitUpdate = function commitUpdate(updater) {
241
- var _this7 = this;
214
+ var _this5 = this;
242
215
 
243
216
  this._scheduleUpdates(function () {
244
- _this7._publishQueue.commitUpdate(updater);
217
+ _this5._publishQueue.commitUpdate(updater);
245
218
 
246
- _this7._publishQueue.run();
219
+ _this5._publishQueue.run();
247
220
  });
248
221
  };
249
222
 
@@ -264,7 +237,7 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
264
237
  };
265
238
 
266
239
  _proto._checkSelectorAndHandleMissingFields = function _checkSelectorAndHandleMissingFields(operation, handlers) {
267
- var _this8 = this;
240
+ var _this6 = this;
268
241
 
269
242
  var target = RelayRecordSource.create();
270
243
 
@@ -275,9 +248,9 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
275
248
 
276
249
  if (target.size() > 0) {
277
250
  this._scheduleUpdates(function () {
278
- _this8._publishQueue.commitSource(target);
251
+ _this6._publishQueue.commitSource(target);
279
252
 
280
- _this8._publishQueue.run();
253
+ _this6._publishQueue.run();
281
254
  });
282
255
  }
283
256
 
@@ -304,32 +277,18 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
304
277
  ;
305
278
 
306
279
  _proto.execute = function execute(_ref) {
307
- var _this9 = this;
280
+ var _this7 = this;
308
281
 
309
282
  var operation = _ref.operation,
310
283
  updater = _ref.updater;
311
- return RelayObservable.create(function (sink) {
312
- var source = _this9._network.execute(operation.request.node.params, operation.request.variables, operation.request.cacheConfig || {}, null);
313
-
314
- var executor = RelayModernQueryExecutor.execute({
315
- operation: operation,
316
- operationExecutions: _this9._operationExecutions,
317
- operationLoader: _this9._operationLoader,
318
- optimisticConfig: null,
319
- publishQueue: _this9._publishQueue,
320
- reactFlightPayloadDeserializer: _this9._reactFlightPayloadDeserializer,
321
- scheduler: _this9._scheduler,
322
- sink: sink,
323
- source: source,
324
- store: _this9._store,
325
- updater: updater,
326
- operationTracker: _this9._operationTracker,
327
- getDataID: _this9._getDataID,
328
- treatMissingFieldsAsNull: _this9._treatMissingFieldsAsNull
329
- });
330
- return function () {
331
- return executor.cancel();
332
- };
284
+ return this._execute({
285
+ createSource: function createSource() {
286
+ return _this7._network.execute(operation.request.node.params, operation.request.variables, operation.request.cacheConfig || {}, null);
287
+ },
288
+ isClientPayload: false,
289
+ operation: operation,
290
+ optimisticConfig: null,
291
+ updater: updater
333
292
  });
334
293
  }
335
294
  /**
@@ -345,47 +304,33 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
345
304
  ;
346
305
 
347
306
  _proto.executeMutation = function executeMutation(_ref2) {
348
- var _this10 = this;
307
+ var _this8 = this;
349
308
 
350
309
  var operation = _ref2.operation,
351
310
  optimisticResponse = _ref2.optimisticResponse,
352
311
  optimisticUpdater = _ref2.optimisticUpdater,
353
312
  updater = _ref2.updater,
354
313
  uploadables = _ref2.uploadables;
355
- return RelayObservable.create(function (sink) {
356
- var optimisticConfig;
357
-
358
- if (optimisticResponse || optimisticUpdater) {
359
- optimisticConfig = {
360
- operation: operation,
361
- response: optimisticResponse,
362
- updater: optimisticUpdater
363
- };
364
- }
314
+ var optimisticConfig;
365
315
 
366
- var source = _this10._network.execute(operation.request.node.params, operation.request.variables, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, operation.request.cacheConfig), {}, {
367
- force: true
368
- }), uploadables);
369
-
370
- var executor = RelayModernQueryExecutor.execute({
316
+ if (optimisticResponse || optimisticUpdater) {
317
+ optimisticConfig = {
371
318
  operation: operation,
372
- operationExecutions: _this10._operationExecutions,
373
- operationLoader: _this10._operationLoader,
374
- optimisticConfig: optimisticConfig,
375
- publishQueue: _this10._publishQueue,
376
- reactFlightPayloadDeserializer: _this10._reactFlightPayloadDeserializer,
377
- scheduler: _this10._scheduler,
378
- sink: sink,
379
- source: source,
380
- store: _this10._store,
381
- updater: updater,
382
- operationTracker: _this10._operationTracker,
383
- getDataID: _this10._getDataID,
384
- treatMissingFieldsAsNull: _this10._treatMissingFieldsAsNull
385
- });
386
- return function () {
387
- return executor.cancel();
319
+ response: optimisticResponse,
320
+ updater: optimisticUpdater
388
321
  };
322
+ }
323
+
324
+ return this._execute({
325
+ createSource: function createSource() {
326
+ return _this8._network.execute(operation.request.node.params, operation.request.variables, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, operation.request.cacheConfig), {}, {
327
+ force: true
328
+ }), uploadables);
329
+ },
330
+ isClientPayload: false,
331
+ operation: operation,
332
+ optimisticConfig: optimisticConfig,
333
+ updater: updater
389
334
  });
390
335
  }
391
336
  /**
@@ -400,36 +345,59 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
400
345
  ;
401
346
 
402
347
  _proto.executeWithSource = function executeWithSource(_ref3) {
403
- var _this11 = this;
404
-
405
348
  var operation = _ref3.operation,
406
349
  source = _ref3.source;
350
+ return this._execute({
351
+ createSource: function createSource() {
352
+ return source;
353
+ },
354
+ isClientPayload: false,
355
+ operation: operation,
356
+ optimisticConfig: null,
357
+ updater: null
358
+ });
359
+ };
360
+
361
+ _proto.toJSON = function toJSON() {
362
+ var _this$configName;
363
+
364
+ return "RelayModernEnvironment(".concat((_this$configName = this.configName) !== null && _this$configName !== void 0 ? _this$configName : '', ")");
365
+ };
366
+
367
+ _proto._execute = function _execute(_ref4) {
368
+ var _this9 = this;
369
+
370
+ var createSource = _ref4.createSource,
371
+ isClientPayload = _ref4.isClientPayload,
372
+ operation = _ref4.operation,
373
+ optimisticConfig = _ref4.optimisticConfig,
374
+ updater = _ref4.updater;
407
375
  return RelayObservable.create(function (sink) {
408
- var executor = RelayModernQueryExecutor.execute({
376
+ var executor = OperationExecutor.execute({
377
+ getDataID: _this9._getDataID,
378
+ isClientPayload: isClientPayload,
409
379
  operation: operation,
410
- operationExecutions: _this11._operationExecutions,
411
- operationLoader: _this11._operationLoader,
412
- operationTracker: _this11._operationTracker,
413
- optimisticConfig: null,
414
- publishQueue: _this11._publishQueue,
415
- reactFlightPayloadDeserializer: _this11._reactFlightPayloadDeserializer,
416
- scheduler: _this11._scheduler,
380
+ operationExecutions: _this9._operationExecutions,
381
+ operationLoader: _this9._operationLoader,
382
+ operationTracker: _this9._operationTracker,
383
+ optimisticConfig: optimisticConfig,
384
+ publishQueue: _this9._publishQueue,
385
+ reactFlightPayloadDeserializer: _this9._reactFlightPayloadDeserializer,
386
+ reactFlightServerErrorHandler: _this9._reactFlightServerErrorHandler,
387
+ scheduler: _this9._scheduler,
388
+ shouldProcessClientComponents: _this9._shouldProcessClientComponents,
417
389
  sink: sink,
418
- source: source,
419
- store: _this11._store,
420
- getDataID: _this11._getDataID,
421
- treatMissingFieldsAsNull: _this11._treatMissingFieldsAsNull
390
+ // NOTE: Some product tests expect `Network.execute` to be called only
391
+ // when the Observable is executed.
392
+ source: createSource(),
393
+ store: _this9._store,
394
+ treatMissingFieldsAsNull: _this9._treatMissingFieldsAsNull,
395
+ updater: updater
422
396
  });
423
397
  return function () {
424
398
  return executor.cancel();
425
399
  };
426
400
  });
427
- };
428
-
429
- _proto.toJSON = function toJSON() {
430
- var _this$configName;
431
-
432
- return "RelayModernEnvironment(".concat((_this$configName = this.configName) !== null && _this$configName !== void 0 ? _this$configName : '', ")");
433
401
  }
434
402
  /**
435
403
  * Wraps the network with logging to ensure that network requests are
@@ -450,7 +418,8 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
450
418
  name: 'network.start',
451
419
  transactionID: transactionID,
452
420
  params: params,
453
- variables: variables
421
+ variables: variables,
422
+ cacheConfig: cacheConfig
454
423
  });
455
424
  },
456
425
  next: function next(response) {
@@ -20,7 +20,7 @@ var RelayFeatureFlags = require('../util/RelayFeatureFlags');
20
20
 
21
21
  var areEqual = require("fbjs/lib/areEqual");
22
22
 
23
- var invariant = require("fbjs/lib/invariant");
23
+ var invariant = require('invariant');
24
24
 
25
25
  var isScalarAndEqual = require('../util/isScalarAndEqual');
26
26
 
@@ -59,7 +59,7 @@ var _require3 = require('./RelayModernSelector'),
59
59
  * recomputed the first time `resolve()` is called.
60
60
  */
61
61
  var RelayModernFragmentSpecResolver = /*#__PURE__*/function () {
62
- function RelayModernFragmentSpecResolver(context, fragments, props, callback) {
62
+ function RelayModernFragmentSpecResolver(context, fragments, props, callback, rootIsQueryRenderer) {
63
63
  var _this = this;
64
64
 
65
65
  (0, _defineProperty2["default"])(this, "_onChange", function () {
@@ -76,6 +76,7 @@ var RelayModernFragmentSpecResolver = /*#__PURE__*/function () {
76
76
  this._props = {};
77
77
  this._resolvers = {};
78
78
  this._stale = false;
79
+ this._rootIsQueryRenderer = rootIsQueryRenderer;
79
80
  this.setProps(props);
80
81
  }
81
82
 
@@ -149,14 +150,14 @@ var RelayModernFragmentSpecResolver = /*#__PURE__*/function () {
149
150
  resolver = null;
150
151
  } else if (ownedSelector.kind === 'PluralReaderSelector') {
151
152
  if (resolver == null) {
152
- resolver = new SelectorListResolver(this._context.environment, ownedSelector, this._onChange);
153
+ resolver = new SelectorListResolver(this._context.environment, this._rootIsQueryRenderer, ownedSelector, this._onChange);
153
154
  } else {
154
155
  !(resolver instanceof SelectorListResolver) ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayModernFragmentSpecResolver: Expected prop `%s` to always be an array.', _key3) : invariant(false) : void 0;
155
156
  resolver.setSelector(ownedSelector);
156
157
  }
157
158
  } else {
158
159
  if (resolver == null) {
159
- resolver = new SelectorResolver(this._context.environment, ownedSelector, this._onChange);
160
+ resolver = new SelectorResolver(this._context.environment, this._rootIsQueryRenderer, ownedSelector, this._onChange);
160
161
  } else {
161
162
  !(resolver instanceof SelectorResolver) ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayModernFragmentSpecResolver: Expected prop `%s` to always be an object.', _key3) : invariant(false) : void 0;
162
163
  resolver.setSelector(ownedSelector);
@@ -193,7 +194,7 @@ var RelayModernFragmentSpecResolver = /*#__PURE__*/function () {
193
194
 
194
195
 
195
196
  var SelectorResolver = /*#__PURE__*/function () {
196
- function SelectorResolver(environment, selector, callback) {
197
+ function SelectorResolver(environment, rootIsQueryRenderer, selector, callback) {
197
198
  var _this2 = this;
198
199
 
199
200
  (0, _defineProperty2["default"])(this, "_onChange", function (snapshot) {
@@ -211,6 +212,7 @@ var SelectorResolver = /*#__PURE__*/function () {
211
212
  this._isMissingData = _snapshot.isMissingData;
212
213
  this._missingRequiredFields = _snapshot.missingRequiredFields;
213
214
  this._environment = environment;
215
+ this._rootIsQueryRenderer = rootIsQueryRenderer;
214
216
  this._selector = selector;
215
217
  this._subscription = environment.subscribe(_snapshot, this._onChange);
216
218
  }
@@ -253,8 +255,12 @@ var SelectorResolver = /*#__PURE__*/function () {
253
255
  var promise = (_getPromiseForActiveR = getPromiseForActiveRequest(this._environment, this._selector.owner)) !== null && _getPromiseForActiveR !== void 0 ? _getPromiseForActiveR : this._environment.getOperationTracker().getPromiseForPendingOperationsAffectingOwner(this._selector.owner);
254
256
 
255
257
  if (promise != null) {
256
- process.env.NODE_ENV !== "production" ? warning(false, 'Relay: Relay Container for fragment `%s` suspended. When using ' + 'features such as @defer or @module, use `useFragment` instead ' + 'of a Relay Container.', this._selector.node.name) : void 0;
257
- throw promise;
258
+ if (this._rootIsQueryRenderer) {
259
+ process.env.NODE_ENV !== "production" ? warning(false, 'Relay: Relay Container for fragment `%s` has missing data and ' + 'would suspend. When using features such as @defer or @module, ' + 'use `useFragment` instead of a Relay Container.', this._selector.node.name) : void 0;
260
+ } else {
261
+ process.env.NODE_ENV !== "production" ? warning(false, 'Relay: Relay Container for fragment `%s` suspended. When using ' + 'features such as @defer or @module, use `useFragment` instead ' + 'of a Relay Container.', this._selector.node.name) : void 0;
262
+ throw promise;
263
+ }
258
264
  }
259
265
  }
260
266
 
@@ -313,7 +319,7 @@ var SelectorResolver = /*#__PURE__*/function () {
313
319
 
314
320
 
315
321
  var SelectorListResolver = /*#__PURE__*/function () {
316
- function SelectorListResolver(environment, selector, callback) {
322
+ function SelectorListResolver(environment, rootIsQueryRenderer, selector, callback) {
317
323
  var _this3 = this;
318
324
 
319
325
  (0, _defineProperty2["default"])(this, "_onChange", function (data) {
@@ -326,6 +332,7 @@ var SelectorListResolver = /*#__PURE__*/function () {
326
332
  this._environment = environment;
327
333
  this._resolvers = [];
328
334
  this._stale = true;
335
+ this._rootIsQueryRenderer = rootIsQueryRenderer;
329
336
  this.setSelector(selector);
330
337
  }
331
338
 
@@ -377,7 +384,7 @@ var SelectorListResolver = /*#__PURE__*/function () {
377
384
  if (ii < this._resolvers.length) {
378
385
  this._resolvers[ii].setSelector(selectors[ii]);
379
386
  } else {
380
- this._resolvers[ii] = new SelectorResolver(this._environment, selectors[ii], this._onChange);
387
+ this._resolvers[ii] = new SelectorResolver(this._environment, this._rootIsQueryRenderer, selectors[ii], this._onChange);
381
388
  }
382
389
  }
383
390
 
@@ -18,7 +18,7 @@ var areEqual = require("fbjs/lib/areEqual");
18
18
 
19
19
  var deepFreeze = require('../util/deepFreeze');
20
20
 
21
- var invariant = require("fbjs/lib/invariant");
21
+ var invariant = require('invariant');
22
22
 
23
23
  var warning = require("fbjs/lib/warning");
24
24
 
@@ -12,7 +12,7 @@
12
12
 
13
13
  var areEqual = require("fbjs/lib/areEqual");
14
14
 
15
- var invariant = require("fbjs/lib/invariant");
15
+ var invariant = require('invariant');
16
16
 
17
17
  var warning = require("fbjs/lib/warning");
18
18
 
@@ -24,8 +24,6 @@ var RelayModernRecord = require('./RelayModernRecord');
24
24
 
25
25
  var RelayOptimisticRecordSource = require('./RelayOptimisticRecordSource');
26
26
 
27
- var RelayProfiler = require('../util/RelayProfiler');
28
-
29
27
  var RelayReader = require('./RelayReader');
30
28
 
31
29
  var RelayReferenceMarker = require('./RelayReferenceMarker');
@@ -42,7 +40,7 @@ var deepFreeze = require('../util/deepFreeze');
42
40
 
43
41
  var defaultGetDataID = require('./defaultGetDataID');
44
42
 
45
- var invariant = require("fbjs/lib/invariant");
43
+ var invariant = require('invariant');
46
44
 
47
45
  var resolveImmediate = require('../util/resolveImmediate');
48
46
 
@@ -50,7 +48,7 @@ var _require = require('./RelayStoreUtils'),
50
48
  ROOT_ID = _require.ROOT_ID,
51
49
  ROOT_TYPE = _require.ROOT_TYPE;
52
50
 
53
- var DEFAULT_RELEASE_BUFFER_SIZE = 0;
51
+ var DEFAULT_RELEASE_BUFFER_SIZE = 10;
54
52
  /**
55
53
  * @public
56
54
  *
@@ -68,7 +66,7 @@ var RelayModernStore = /*#__PURE__*/function () {
68
66
  function RelayModernStore(source, options) {
69
67
  var _this = this;
70
68
 
71
- var _options$gcReleaseBuf, _options$gcScheduler, _options$UNSTABLE_DO_, _options$log, _options$operationLoa;
69
+ var _options$gcReleaseBuf, _options$gcScheduler, _options$getDataID, _options$log, _options$operationLoa;
72
70
 
73
71
  (0, _defineProperty2["default"])(this, "_gcStep", function () {
74
72
  if (_this._gcRun) {
@@ -98,7 +96,7 @@ var RelayModernStore = /*#__PURE__*/function () {
98
96
  this._gcReleaseBufferSize = (_options$gcReleaseBuf = options === null || options === void 0 ? void 0 : options.gcReleaseBufferSize) !== null && _options$gcReleaseBuf !== void 0 ? _options$gcReleaseBuf : DEFAULT_RELEASE_BUFFER_SIZE;
99
97
  this._gcRun = null;
100
98
  this._gcScheduler = (_options$gcScheduler = options === null || options === void 0 ? void 0 : options.gcScheduler) !== null && _options$gcScheduler !== void 0 ? _options$gcScheduler : resolveImmediate;
101
- this._getDataID = (_options$UNSTABLE_DO_ = options === null || options === void 0 ? void 0 : options.UNSTABLE_DO_NOT_USE_getDataID) !== null && _options$UNSTABLE_DO_ !== void 0 ? _options$UNSTABLE_DO_ : defaultGetDataID;
99
+ this._getDataID = (_options$getDataID = options === null || options === void 0 ? void 0 : options.getDataID) !== null && _options$getDataID !== void 0 ? _options$getDataID : defaultGetDataID;
102
100
  this._globalInvalidationEpoch = null;
103
101
  this._invalidationSubscriptions = new Set();
104
102
  this._invalidatedRecordIDs = new Set();
@@ -110,8 +108,9 @@ var RelayModernStore = /*#__PURE__*/function () {
110
108
  this._releaseBuffer = [];
111
109
  this._roots = new Map();
112
110
  this._shouldScheduleGC = false;
113
- this._storeSubscriptions = RelayFeatureFlags.ENABLE_STORE_SUBSCRIPTIONS_REFACTOR === true ? new RelayStoreSubscriptionsUsingMapByID() : new RelayStoreSubscriptions();
114
- this._updatedRecordIDs = {};
111
+ this._storeSubscriptions = RelayFeatureFlags.ENABLE_STORE_SUBSCRIPTIONS_REFACTOR === true ? new RelayStoreSubscriptionsUsingMapByID(options === null || options === void 0 ? void 0 : options.log) : new RelayStoreSubscriptions(options === null || options === void 0 ? void 0 : options.log);
112
+ this._updatedRecordIDs = new Set();
113
+ this._shouldProcessClientComponents = options === null || options === void 0 ? void 0 : options.shouldProcessClientComponents;
115
114
  initializeRecordSource(this._recordSource);
116
115
  }
117
116
 
@@ -150,7 +149,7 @@ var RelayModernStore = /*#__PURE__*/function () {
150
149
 
151
150
  var target = (_options$target = options === null || options === void 0 ? void 0 : options.target) !== null && _options$target !== void 0 ? _options$target : source;
152
151
  var handlers = (_options$handlers = options === null || options === void 0 ? void 0 : options.handlers) !== null && _options$handlers !== void 0 ? _options$handlers : [];
153
- var operationAvailability = DataChecker.check(source, target, selector, handlers, this._operationLoader, this._getDataID);
152
+ var operationAvailability = DataChecker.check(source, target, selector, handlers, this._operationLoader, this._getDataID, this._shouldProcessClientComponents);
154
153
  return getAvailabilityStatus(operationAvailability, operationLastWrittenAt, rootEntry === null || rootEntry === void 0 ? void 0 : rootEntry.fetchTime, this._queryCacheExpirationTime);
155
154
  };
156
155
 
@@ -252,7 +251,8 @@ var RelayModernStore = /*#__PURE__*/function () {
252
251
 
253
252
  if (log != null) {
254
253
  log({
255
- name: 'store.notify.start'
254
+ name: 'store.notify.start',
255
+ sourceOperation: sourceOperation
256
256
  });
257
257
  } // Increment the current write when notifying after executing
258
258
  // a set of changes to the store.
@@ -267,7 +267,7 @@ var RelayModernStore = /*#__PURE__*/function () {
267
267
  var source = this.getSource();
268
268
  var updatedOwners = [];
269
269
 
270
- this._storeSubscriptions.updateSubscriptions(source, this._updatedRecordIDs, updatedOwners);
270
+ this._storeSubscriptions.updateSubscriptions(source, this._updatedRecordIDs, updatedOwners, sourceOperation);
271
271
 
272
272
  this._invalidationSubscriptions.forEach(function (subscription) {
273
273
  _this3._updateInvalidationSubscription(subscription, invalidateStore === true);
@@ -276,12 +276,13 @@ var RelayModernStore = /*#__PURE__*/function () {
276
276
  if (log != null) {
277
277
  log({
278
278
  name: 'store.notify.complete',
279
+ sourceOperation: sourceOperation,
279
280
  updatedRecordIDs: this._updatedRecordIDs,
280
281
  invalidatedRecordIDs: this._invalidatedRecordIDs
281
282
  });
282
283
  }
283
284
 
284
- this._updatedRecordIDs = {};
285
+ this._updatedRecordIDs.clear();
285
286
 
286
287
  this._invalidatedRecordIDs.clear(); // If a source operation was provided (indicating the operation
287
288
  // that produced this update to the store), record the current epoch
@@ -547,7 +548,7 @@ var RelayModernStore = /*#__PURE__*/function () {
547
548
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
548
549
  var operation = _step2.value.operation;
549
550
  var selector = operation.root;
550
- RelayReferenceMarker.mark(this._recordSource, selector, references, this._operationLoader); // Yield for other work after each operation
551
+ RelayReferenceMarker.mark(this._recordSource, selector, references, this._operationLoader, this._shouldProcessClientComponents); // Yield for other work after each operation
551
552
 
552
553
  yield; // If the store was updated, restart
553
554
 
@@ -645,7 +646,8 @@ function updateTargetFromSource(target, source, currentWriteEpoch, idsMarkedForI
645
646
  }
646
647
 
647
648
  RelayModernRecord.setValue(nextRecord, RelayStoreUtils.INVALIDATED_AT_KEY, currentWriteEpoch);
648
- invalidatedRecordIDs.add(dataID);
649
+ invalidatedRecordIDs.add(dataID); // $FlowFixMe[incompatible-call]
650
+
649
651
  target.set(dataID, nextRecord);
650
652
  });
651
653
  } // Update the target based on the changes present in source
@@ -677,18 +679,18 @@ function updateTargetFromSource(target, source, currentWriteEpoch, idsMarkedForI
677
679
  RelayModernRecord.freeze(nextRecord);
678
680
  }
679
681
 
680
- updatedRecordIDs[dataID] = true;
682
+ updatedRecordIDs.add(dataID);
681
683
  target.set(dataID, nextRecord);
682
684
  }
683
685
  } else if (sourceRecord === null) {
684
686
  target["delete"](dataID);
685
687
 
686
688
  if (targetRecord !== null) {
687
- updatedRecordIDs[dataID] = true;
689
+ updatedRecordIDs.add(dataID);
688
690
  }
689
691
  } else if (sourceRecord) {
690
692
  target.set(dataID, sourceRecord);
691
- updatedRecordIDs[dataID] = true;
693
+ updatedRecordIDs.add(dataID);
692
694
  } // don't add explicit undefined
693
695
 
694
696
  }
@@ -743,7 +745,4 @@ function getAvailabilityStatus(operationAvailability, operationLastWrittenAt, op
743
745
  };
744
746
  }
745
747
 
746
- RelayProfiler.instrumentMethods(RelayModernStore.prototype, {
747
- lookup: 'RelayModernStore.prototype.lookup'
748
- });
749
748
  module.exports = RelayModernStore;