react-relay 14.0.0 → 15.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. package/ReactRelayContainerUtils.js.flow +1 -2
  2. package/ReactRelayContext.js +1 -1
  3. package/ReactRelayContext.js.flow +1 -2
  4. package/ReactRelayFragmentContainer.js.flow +6 -4
  5. package/ReactRelayFragmentMockRenderer.js.flow +1 -2
  6. package/ReactRelayLocalQueryRenderer.js.flow +5 -5
  7. package/ReactRelayPaginationContainer.js.flow +21 -14
  8. package/ReactRelayQueryFetcher.js.flow +28 -16
  9. package/ReactRelayQueryRenderer.js.flow +42 -13
  10. package/ReactRelayQueryRendererContext.js.flow +2 -3
  11. package/ReactRelayRefetchContainer.js.flow +9 -9
  12. package/ReactRelayTestMocker.js.flow +3 -3
  13. package/ReactRelayTypes.js.flow +7 -8
  14. package/RelayContext.js.flow +1 -2
  15. package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +4 -5
  16. package/__flowtests__/ReactRelayPaginationContainer-flowtest.js.flow +4 -5
  17. package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +4 -5
  18. package/__flowtests__/RelayModern-flowtest.js.flow +3 -4
  19. package/__flowtests__/RelayModernFlowtest_badref.graphql.js.flow +3 -4
  20. package/__flowtests__/RelayModernFlowtest_notref.graphql.js.flow +3 -4
  21. package/__flowtests__/RelayModernFlowtest_user.graphql.js.flow +3 -4
  22. package/__flowtests__/RelayModernFlowtest_users.graphql.js.flow +3 -4
  23. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer.graphql.js.flow +3 -1
  24. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer2.graphql.js.flow +3 -1
  25. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtestQuery.graphql.js.flow +4 -2
  26. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtest_viewer.graphql.js.flow +3 -1
  27. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtestQuery.graphql.js.flow +4 -2
  28. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtest_viewer.graphql.js.flow +3 -1
  29. package/__flowtests__/__generated__/RelayModernFlowtest_badref.graphql.js.flow +4 -2
  30. package/__flowtests__/__generated__/RelayModernFlowtest_notref.graphql.js.flow +4 -2
  31. package/__flowtests__/__generated__/RelayModernFlowtest_user.graphql.js.flow +3 -1
  32. package/__flowtests__/__generated__/RelayModernFlowtest_users.graphql.js.flow +3 -1
  33. package/assertFragmentMap.js.flow +1 -2
  34. package/buildReactRelayContainer.js.flow +7 -7
  35. package/getRootVariablesForFragments.js.flow +1 -3
  36. package/hooks.js +1 -1
  37. package/hooks.js.flow +4 -2
  38. package/index.js +1 -1
  39. package/index.js.flow +6 -2
  40. package/isRelayEnvironment.js.flow +1 -2
  41. package/jest-react/enqueueTask.js.flow +1 -1
  42. package/jest-react/index.js.flow +1 -1
  43. package/jest-react/internalAct.js.flow +1 -1
  44. package/legacy.js +1 -1
  45. package/legacy.js.flow +1 -2
  46. package/lib/ReactRelayContainerUtils.js +2 -3
  47. package/lib/ReactRelayContext.js +3 -4
  48. package/lib/ReactRelayFragmentContainer.js +47 -73
  49. package/lib/ReactRelayFragmentMockRenderer.js +2 -4
  50. package/lib/ReactRelayLocalQueryRenderer.js +18 -31
  51. package/lib/ReactRelayPaginationContainer.js +74 -164
  52. package/lib/ReactRelayQueryFetcher.js +49 -76
  53. package/lib/ReactRelayQueryRenderer.js +63 -84
  54. package/lib/ReactRelayQueryRendererContext.js +2 -2
  55. package/lib/ReactRelayRefetchContainer.js +58 -108
  56. package/lib/ReactRelayTestMocker.js +33 -68
  57. package/lib/ReactRelayTypes.js +2 -1
  58. package/lib/RelayContext.js +4 -7
  59. package/lib/assertFragmentMap.js +3 -5
  60. package/lib/buildReactRelayContainer.js +11 -27
  61. package/lib/getRootVariablesForFragments.js +6 -10
  62. package/lib/hooks.js +5 -18
  63. package/lib/index.js +7 -24
  64. package/lib/isRelayEnvironment.js +5 -4
  65. package/lib/jest-react/enqueueTask.js +5 -9
  66. package/lib/jest-react/index.js +0 -1
  67. package/lib/jest-react/internalAct.js +9 -20
  68. package/lib/legacy.js +2 -8
  69. package/lib/multi-actor/ActorChange.js +2 -5
  70. package/lib/multi-actor/index.js +2 -1
  71. package/lib/multi-actor/useRelayActorEnvironment.js +4 -8
  72. package/lib/relay-hooks/EntryPointContainer.react.js +9 -15
  73. package/lib/relay-hooks/EntryPointTypes.flow.js +5 -3
  74. package/lib/relay-hooks/FragmentResource.js +109 -203
  75. package/lib/relay-hooks/HooksImplementation.js +3 -6
  76. package/lib/relay-hooks/InternalLogger.js +2 -3
  77. package/lib/relay-hooks/LRUCache.js +2 -20
  78. package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +33 -54
  79. package/lib/relay-hooks/MatchContainer.js +15 -24
  80. package/lib/relay-hooks/ProfilerContext.js +3 -3
  81. package/lib/relay-hooks/QueryResource.js +31 -101
  82. package/lib/relay-hooks/RelayEnvironmentProvider.js +5 -9
  83. package/lib/relay-hooks/SuspenseResource.js +9 -33
  84. package/lib/relay-hooks/loadEntryPoint.js +19 -31
  85. package/lib/relay-hooks/loadQuery.js +42 -78
  86. package/lib/relay-hooks/preloadQuery_DEPRECATED.js +11 -37
  87. package/lib/relay-hooks/prepareEntryPoint_DEPRECATED.js +9 -15
  88. package/lib/relay-hooks/react-cache/RelayReactCache.js +7 -12
  89. package/lib/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js +27 -81
  90. package/lib/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js +206 -0
  91. package/lib/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js +195 -215
  92. package/lib/relay-hooks/react-cache/useFragment_REACT_CACHE.js +5 -15
  93. package/lib/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js +17 -24
  94. package/lib/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js +149 -0
  95. package/lib/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js +24 -39
  96. package/lib/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js +325 -0
  97. package/lib/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js +37 -0
  98. package/lib/relay-hooks/useBlockingPaginationFragment.js +73 -93
  99. package/lib/relay-hooks/useClientQuery.js +30 -0
  100. package/lib/relay-hooks/useEntryPointLoader.js +18 -38
  101. package/lib/relay-hooks/useFetchTrackingRef.js +10 -12
  102. package/lib/relay-hooks/useFragment.js +8 -19
  103. package/lib/relay-hooks/useFragmentNode.js +20 -32
  104. package/lib/relay-hooks/useIsMountedRef.js +4 -6
  105. package/lib/relay-hooks/useIsOperationNodeActive.js +8 -20
  106. package/lib/relay-hooks/useIsParentQueryActive.js +3 -6
  107. package/lib/relay-hooks/useLazyLoadQuery.js +7 -24
  108. package/lib/relay-hooks/useLazyLoadQueryNode.js +23 -34
  109. package/lib/relay-hooks/useLoadMoreFunction.js +46 -78
  110. package/lib/relay-hooks/useMemoOperationDescriptor.js +6 -15
  111. package/lib/relay-hooks/useMemoVariables.js +15 -34
  112. package/lib/relay-hooks/useMutation.js +9 -27
  113. package/lib/relay-hooks/usePaginationFragment.js +73 -76
  114. package/lib/relay-hooks/usePreloadedQuery.js +13 -44
  115. package/lib/relay-hooks/useQueryLoader.js +24 -49
  116. package/lib/relay-hooks/useRefetchableFragment.js +19 -17
  117. package/lib/relay-hooks/useRefetchableFragmentNode.js +65 -109
  118. package/lib/relay-hooks/useRelayEnvironment.js +4 -8
  119. package/lib/relay-hooks/useStaticFragmentNodeWarning.js +4 -8
  120. package/lib/relay-hooks/useSubscribeToInvalidationState.js +8 -9
  121. package/lib/relay-hooks/useSubscription.js +5 -10
  122. package/lib/relay-hooks/useUnsafeRef_DEPRECATED.js +29 -0
  123. package/multi-actor/ActorChange.js.flow +1 -1
  124. package/multi-actor/index.js.flow +1 -1
  125. package/multi-actor/useRelayActorEnvironment.js.flow +2 -4
  126. package/package.json +2 -2
  127. package/react-relay-hooks.js +2 -2
  128. package/react-relay-hooks.min.js +2 -2
  129. package/react-relay-legacy.js +2 -2
  130. package/react-relay-legacy.min.js +2 -2
  131. package/react-relay.js +2 -2
  132. package/react-relay.min.js +2 -2
  133. package/relay-hooks/EntryPointContainer.react.js.flow +3 -5
  134. package/relay-hooks/EntryPointTypes.flow.js.flow +37 -37
  135. package/relay-hooks/FragmentResource.js.flow +43 -19
  136. package/relay-hooks/HooksImplementation.js.flow +7 -9
  137. package/relay-hooks/InternalLogger.js.flow +1 -3
  138. package/relay-hooks/LRUCache.js.flow +1 -3
  139. package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +19 -14
  140. package/relay-hooks/MatchContainer.js.flow +6 -8
  141. package/relay-hooks/ProfilerContext.js.flow +1 -3
  142. package/relay-hooks/QueryResource.js.flow +29 -11
  143. package/relay-hooks/RelayEnvironmentProvider.js.flow +4 -6
  144. package/relay-hooks/SuspenseResource.js.flow +1 -3
  145. package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +6 -4
  146. package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +4 -4
  147. package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_user.graphql.js.flow +3 -1
  148. package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_users.graphql.js.flow +3 -1
  149. package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +39 -39
  150. package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +1 -3
  151. package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +37 -38
  152. package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +18 -20
  153. package/relay-hooks/__flowtests__/utils.js.flow +21 -12
  154. package/relay-hooks/loadEntryPoint.js.flow +11 -6
  155. package/relay-hooks/loadQuery.js.flow +11 -7
  156. package/relay-hooks/preloadQuery_DEPRECATED.js.flow +9 -12
  157. package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +13 -10
  158. package/relay-hooks/react-cache/RelayReactCache.js.flow +1 -3
  159. package/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js.flow +26 -20
  160. package/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js.flow +297 -0
  161. package/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js.flow +136 -96
  162. package/relay-hooks/react-cache/useFragment_REACT_CACHE.js.flow +1 -3
  163. package/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js.flow +3 -5
  164. package/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js.flow +190 -0
  165. package/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js.flow +3 -6
  166. package/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js.flow +601 -0
  167. package/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js.flow +65 -0
  168. package/relay-hooks/useBlockingPaginationFragment.js.flow +86 -59
  169. package/relay-hooks/useClientQuery.js.flow +39 -0
  170. package/relay-hooks/useEntryPointLoader.js.flow +16 -14
  171. package/relay-hooks/useFetchTrackingRef.js.flow +7 -8
  172. package/relay-hooks/useFragment.js.flow +2 -4
  173. package/relay-hooks/useFragmentNode.js.flow +7 -8
  174. package/relay-hooks/useIsMountedRef.js.flow +2 -4
  175. package/relay-hooks/useIsOperationNodeActive.js.flow +1 -1
  176. package/relay-hooks/useIsParentQueryActive.js.flow +1 -1
  177. package/relay-hooks/useLazyLoadQuery.js.flow +9 -32
  178. package/relay-hooks/useLazyLoadQueryNode.js.flow +4 -6
  179. package/relay-hooks/useLoadMoreFunction.js.flow +20 -17
  180. package/relay-hooks/useMemoOperationDescriptor.js.flow +3 -5
  181. package/relay-hooks/useMemoVariables.js.flow +13 -31
  182. package/relay-hooks/useMutation.js.flow +6 -8
  183. package/relay-hooks/usePaginationFragment.js.flow +75 -43
  184. package/relay-hooks/usePreloadedQuery.js.flow +49 -43
  185. package/relay-hooks/useQueryLoader.js.flow +89 -28
  186. package/relay-hooks/useRefetchableFragment.js.flow +83 -23
  187. package/relay-hooks/useRefetchableFragmentNode.js.flow +26 -22
  188. package/relay-hooks/useRelayEnvironment.js.flow +2 -4
  189. package/relay-hooks/useStaticFragmentNodeWarning.js.flow +3 -5
  190. package/relay-hooks/useSubscribeToInvalidationState.js.flow +2 -4
  191. package/relay-hooks/useSubscription.js.flow +1 -3
  192. package/relay-hooks/useUnsafeRef_DEPRECATED.js.flow +25 -0
  193. package/lib/readContext.js +0 -28
  194. package/readContext.js.flow +0 -31
@@ -6,60 +6,45 @@
6
6
  *
7
7
  *
8
8
  * @format
9
+ * @oncall relay
9
10
  */
10
- // flowlint ambiguous-object-type:error
11
- 'use strict';
12
11
 
13
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
12
+ 'use strict';
14
13
 
14
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
15
15
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
16
-
17
16
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
18
-
19
17
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
20
-
21
18
  var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
22
-
23
19
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
24
-
25
20
  var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
26
-
21
+ var _excluded = ["componentRef"],
22
+ _excluded2 = ["componentRef", "__relayContext", "__rootIsQueryRenderer"],
23
+ _excluded3 = ["componentRef", "__relayContext", "__rootIsQueryRenderer"];
27
24
  var buildReactRelayContainer = require('./buildReactRelayContainer');
28
-
29
25
  var getRootVariablesForFragments = require('./getRootVariablesForFragments');
30
-
31
26
  var _require = require('./ReactRelayContainerUtils'),
32
- getComponentName = _require.getComponentName,
33
- getContainerName = _require.getContainerName;
34
-
27
+ getComponentName = _require.getComponentName,
28
+ getContainerName = _require.getContainerName;
35
29
  var ReactRelayContext = require('./ReactRelayContext');
36
-
37
30
  var ReactRelayQueryFetcher = require('./ReactRelayQueryFetcher');
38
-
39
31
  var _require2 = require('./RelayContext'),
40
- assertRelayContext = _require2.assertRelayContext;
41
-
32
+ assertRelayContext = _require2.assertRelayContext;
42
33
  var areEqual = require("fbjs/lib/areEqual");
43
-
44
34
  var invariant = require('invariant');
45
-
46
35
  var React = require('react');
47
-
48
36
  var _require3 = require('relay-runtime'),
49
- ConnectionInterface = _require3.ConnectionInterface,
50
- Observable = _require3.Observable,
51
- RelayFeatureFlags = _require3.RelayFeatureFlags,
52
- createFragmentSpecResolver = _require3.createFragmentSpecResolver,
53
- createOperationDescriptor = _require3.createOperationDescriptor,
54
- getDataIDsFromObject = _require3.getDataIDsFromObject,
55
- getRequest = _require3.getRequest,
56
- getVariablesFromObject = _require3.getVariablesFromObject,
57
- isScalarAndEqual = _require3.isScalarAndEqual;
58
-
37
+ ConnectionInterface = _require3.ConnectionInterface,
38
+ Observable = _require3.Observable,
39
+ RelayFeatureFlags = _require3.RelayFeatureFlags,
40
+ createFragmentSpecResolver = _require3.createFragmentSpecResolver,
41
+ createOperationDescriptor = _require3.createOperationDescriptor,
42
+ getDataIDsFromObject = _require3.getDataIDsFromObject,
43
+ getRequest = _require3.getRequest,
44
+ getVariablesFromObject = _require3.getVariablesFromObject,
45
+ isScalarAndEqual = _require3.isScalarAndEqual;
59
46
  var warning = require("fbjs/lib/warning");
60
-
61
47
  var FORWARD = 'forward';
62
-
63
48
  /**
64
49
  * Extends the functionality of RelayFragmentContainer by providing a mechanism
65
50
  * to load more data from a connection.
@@ -191,24 +176,21 @@ var FORWARD = 'forward';
191
176
  * typically reference one of the container's fragment (as in the example)
192
177
  * to ensure that all the necessary fields for sub-components are fetched.
193
178
  */
179
+
194
180
  function createGetConnectionFromProps(metadata) {
195
181
  var path = metadata.path;
196
182
  !path ? process.env.NODE_ENV !== "production" ? invariant(false, 'ReactRelayPaginationContainer: Unable to synthesize a ' + 'getConnectionFromProps function.') : invariant(false) : void 0;
197
183
  return function (props) {
198
184
  var data = props[metadata.fragmentName];
199
-
200
185
  for (var i = 0; i < path.length; i++) {
201
186
  if (!data || typeof data !== 'object') {
202
187
  return null;
203
188
  }
204
-
205
189
  data = data[path[i]];
206
190
  }
207
-
208
191
  return data;
209
192
  };
210
193
  }
211
-
212
194
  function createGetFragmentVariables(metadata) {
213
195
  var countVariable = metadata.count;
214
196
  !countVariable ? process.env.NODE_ENV !== "production" ? invariant(false, 'ReactRelayPaginationContainer: Unable to synthesize a ' + 'getFragmentVariables function.') : invariant(false) : void 0;
@@ -216,21 +198,18 @@ function createGetFragmentVariables(metadata) {
216
198
  return (0, _objectSpread3["default"])((0, _objectSpread3["default"])({}, prevVars), {}, (0, _defineProperty2["default"])({}, countVariable, totalCount));
217
199
  };
218
200
  }
219
-
220
201
  function findConnectionMetadata(fragments) {
221
202
  var foundConnectionMetadata = null;
222
203
  var isRelayModern = false;
223
-
224
204
  for (var fragmentName in fragments) {
225
205
  var fragment = fragments[fragmentName];
226
- var connectionMetadata = fragment.metadata && fragment.metadata.connection; // HACK: metadata is always set to `undefined` in classic. In modern, even
206
+ var connectionMetadata = fragment.metadata && fragment.metadata.connection;
207
+ // HACK: metadata is always set to `undefined` in classic. In modern, even
227
208
  // if empty, it is set to null (never undefined). We use that knowlege to
228
209
  // check if we're dealing with classic or modern
229
-
230
210
  if (fragment.metadata !== undefined) {
231
211
  isRelayModern = true;
232
212
  }
233
-
234
213
  if (connectionMetadata) {
235
214
  !(connectionMetadata.length === 1) ? process.env.NODE_ENV !== "production" ? invariant(false, 'ReactRelayPaginationContainer: Only a single @connection is ' + 'supported, `%s` has %s.', fragmentName, connectionMetadata.length) : invariant(false) : void 0;
236
215
  !!foundConnectionMetadata ? process.env.NODE_ENV !== "production" ? invariant(false, 'ReactRelayPaginationContainer: Only a single fragment with ' + '@connection is supported.') : invariant(false) : void 0;
@@ -239,11 +218,9 @@ function findConnectionMetadata(fragments) {
239
218
  });
240
219
  }
241
220
  }
242
-
243
221
  !(!isRelayModern || foundConnectionMetadata !== null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'ReactRelayPaginationContainer: A @connection directive must be present.') : invariant(false) : void 0;
244
222
  return foundConnectionMetadata || {};
245
223
  }
246
-
247
224
  function toObserver(observerOrCallback) {
248
225
  return typeof observerOrCallback === 'function' ? {
249
226
  error: observerOrCallback,
@@ -253,10 +230,8 @@ function toObserver(observerOrCallback) {
253
230
  }
254
231
  } : observerOrCallback || {};
255
232
  }
256
-
257
233
  function createContainerWithFragments(Component, fragments, connectionConfig) {
258
- var _class, _temp;
259
-
234
+ var _class;
260
235
  var componentName = getComponentName(Component);
261
236
  var containerName = getContainerName(Component);
262
237
  var metadata = findConnectionMetadata(fragments);
@@ -264,12 +239,12 @@ function createContainerWithFragments(Component, fragments, connectionConfig) {
264
239
  var direction = connectionConfig.direction || metadata.direction;
265
240
  !direction ? process.env.NODE_ENV !== "production" ? invariant(false, 'ReactRelayPaginationContainer: Unable to infer direction of the ' + 'connection, possibly because both first and last are provided.') : invariant(false) : void 0;
266
241
  var getFragmentVariables = connectionConfig.getFragmentVariables || createGetFragmentVariables(metadata);
267
- return _temp = _class = /*#__PURE__*/function (_React$Component) {
242
+ return _class = /*#__PURE__*/function (_React$Component) {
268
243
  (0, _inheritsLoose2["default"])(_class, _React$Component);
244
+ // $FlowFixMe[missing-local-annot]
269
245
 
270
246
  function _class(props) {
271
247
  var _props$__rootIsQueryR, _this;
272
-
273
248
  _this = _React$Component.call(this, props) || this;
274
249
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_handleFragmentDataUpdate", function () {
275
250
  _this.setState({
@@ -278,7 +253,6 @@ function createContainerWithFragments(Component, fragments, connectionConfig) {
278
253
  });
279
254
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_hasMore", function () {
280
255
  var connectionData = _this._getConnectionData();
281
-
282
256
  return !!(connectionData && connectionData.hasMore && connectionData.cursor);
283
257
  });
284
258
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_isLoading", function () {
@@ -290,18 +264,15 @@ function createContainerWithFragments(Component, fragments, connectionConfig) {
290
264
  dispose: function dispose() {}
291
265
  };
292
266
  }
293
-
294
267
  _this._refetchVariables = refetchVariables;
295
268
  var paginatingVariables = {
296
269
  count: totalCount,
297
270
  cursor: null,
298
271
  totalCount: totalCount
299
272
  };
300
-
301
273
  var fetch = _this._fetchPage(paginatingVariables, toObserver(observerOrCallback), {
302
274
  force: true
303
275
  });
304
-
305
276
  return {
306
277
  dispose: fetch.unsubscribe
307
278
  };
@@ -312,28 +283,21 @@ function createContainerWithFragments(Component, fragments, connectionConfig) {
312
283
  dispose: function dispose() {}
313
284
  };
314
285
  }
315
-
316
286
  var observer = toObserver(observerOrCallback);
317
-
318
287
  var connectionData = _this._getConnectionData();
319
-
320
288
  if (!connectionData) {
321
289
  Observable.create(function (sink) {
322
290
  return sink.complete();
323
291
  }).subscribe(observer);
324
292
  return null;
325
293
  }
326
-
327
294
  var totalCount = connectionData.edgeCount + pageSize;
328
-
329
295
  if (options && options.force) {
330
296
  return _this._refetchConnection(totalCount, observerOrCallback);
331
297
  }
332
-
333
298
  var _ConnectionInterface$ = ConnectionInterface.get(),
334
- END_CURSOR = _ConnectionInterface$.END_CURSOR,
335
- START_CURSOR = _ConnectionInterface$.START_CURSOR;
336
-
299
+ END_CURSOR = _ConnectionInterface$.END_CURSOR,
300
+ START_CURSOR = _ConnectionInterface$.START_CURSOR;
337
301
  var cursor = connectionData.cursor;
338
302
  process.env.NODE_ENV !== "production" ? warning(cursor != null && cursor !== '', 'ReactRelayPaginationContainer: Cannot `loadMore` without valid `%s` (got `%s`)', direction === FORWARD ? END_CURSOR : START_CURSOR, cursor) : void 0;
339
303
  var paginatingVariables = {
@@ -341,9 +305,7 @@ function createContainerWithFragments(Component, fragments, connectionConfig) {
341
305
  cursor: cursor,
342
306
  totalCount: totalCount
343
307
  };
344
-
345
308
  var fetch = _this._fetchPage(paginatingVariables, observer, options);
346
-
347
309
  return {
348
310
  dispose: fetch.unsubscribe
349
311
  };
@@ -353,13 +315,11 @@ function createContainerWithFragments(Component, fragments, connectionConfig) {
353
315
  _this._isARequestInFlight = false;
354
316
  _this._refetchSubscription = null;
355
317
  _this._refetchVariables = null;
356
-
357
318
  if (RelayFeatureFlags.ENABLE_CONTAINERS_SUBSCRIBE_ON_COMMIT === true) {
358
319
  _this._resolver = createFragmentSpecResolver(relayContext, containerName, fragments, props, rootIsQueryRenderer);
359
320
  } else {
360
321
  _this._resolver = createFragmentSpecResolver(relayContext, containerName, fragments, props, rootIsQueryRenderer, _this._handleFragmentDataUpdate);
361
322
  }
362
-
363
323
  _this.state = {
364
324
  data: _this._resolver.resolve(),
365
325
  prevContext: relayContext,
@@ -371,17 +331,13 @@ function createContainerWithFragments(Component, fragments, connectionConfig) {
371
331
  _this._hasFetched = false;
372
332
  return _this;
373
333
  }
374
-
375
334
  var _proto = _class.prototype;
376
-
377
335
  _proto.componentDidMount = function componentDidMount() {
378
336
  this._isUnmounted = false;
379
-
380
337
  if (RelayFeatureFlags.ENABLE_CONTAINERS_SUBSCRIBE_ON_COMMIT === true) {
381
338
  this._subscribeToNewResolverAndRerenderIfStoreHasChanged();
382
339
  }
383
340
  };
384
-
385
341
  _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
386
342
  if (RelayFeatureFlags.ENABLE_CONTAINERS_SUBSCRIBE_ON_COMMIT === true) {
387
343
  if (prevState.resolverGeneration !== this.state.resolverGeneration) {
@@ -391,39 +347,35 @@ function createContainerWithFragments(Component, fragments, connectionConfig) {
391
347
  }
392
348
  }
393
349
  }
350
+
394
351
  /**
395
352
  * When new props are received, read data for the new props and subscribe
396
353
  * for updates. Props may be the same in which case previous data and
397
354
  * subscriptions can be reused.
398
- */
399
- ;
400
-
355
+ */;
401
356
  _proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
402
357
  var _this2 = this;
403
-
404
358
  var _nextProps$__rootIsQu;
405
-
406
359
  var relayContext = assertRelayContext(nextProps.__relayContext);
407
360
  var rootIsQueryRenderer = (_nextProps$__rootIsQu = nextProps.__rootIsQueryRenderer) !== null && _nextProps$__rootIsQu !== void 0 ? _nextProps$__rootIsQu : false;
408
361
  var prevIDs = getDataIDsFromObject(fragments, this.props);
409
362
  var nextIDs = getDataIDsFromObject(fragments, nextProps);
410
363
  var prevRootVariables = getRootVariablesForFragments(fragments, this.props);
411
- var nextRootVariables = getRootVariablesForFragments(fragments, nextProps); // If the environment has changed or props point to new records then
364
+ var nextRootVariables = getRootVariablesForFragments(fragments, nextProps);
365
+
366
+ // If the environment has changed or props point to new records then
412
367
  // previously fetched data and any pending fetches no longer apply:
413
368
  // - Existing references are on the old environment.
414
369
  // - Existing references are based on old variables.
415
370
  // - Pending fetches are for the previous records.
416
-
417
371
  if (relayContext.environment !== this.state.prevContext.environment || !areEqual(prevRootVariables, nextRootVariables) || !areEqual(prevIDs, nextIDs)) {
418
- this._cleanup(); // Child containers rely on context.relay being mutated (for gDSFP).
419
-
420
-
372
+ this._cleanup();
373
+ // Child containers rely on context.relay being mutated (for gDSFP).
421
374
  if (RelayFeatureFlags.ENABLE_CONTAINERS_SUBSCRIBE_ON_COMMIT === true) {
422
375
  this._resolver = createFragmentSpecResolver(relayContext, containerName, fragments, nextProps, rootIsQueryRenderer);
423
376
  } else {
424
377
  this._resolver = createFragmentSpecResolver(relayContext, containerName, fragments, nextProps, rootIsQueryRenderer, this._handleFragmentDataUpdate);
425
378
  }
426
-
427
379
  this.setState(function (prevState) {
428
380
  return {
429
381
  prevContext: relayContext,
@@ -435,49 +387,39 @@ function createContainerWithFragments(Component, fragments, connectionConfig) {
435
387
  } else if (!this._hasFetched) {
436
388
  this._resolver.setProps(nextProps);
437
389
  }
438
-
439
390
  var data = this._resolver.resolve();
440
-
441
391
  if (data !== this.state.data) {
442
392
  this.setState({
443
393
  data: data
444
394
  });
445
395
  }
446
396
  };
447
-
448
397
  _proto.componentWillUnmount = function componentWillUnmount() {
449
398
  this._isUnmounted = true;
450
-
451
399
  this._cleanup();
452
400
  };
453
-
454
401
  _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
455
402
  // Short-circuit if any Relay-related data has changed
456
403
  if (nextState.data !== this.state.data || nextState.relayProp !== this.state.relayProp || nextState.resolverGeneration !== this.state.resolverGeneration) {
457
404
  return true;
458
- } // Otherwise, for convenience short-circuit if all non-Relay props
405
+ }
406
+ // Otherwise, for convenience short-circuit if all non-Relay props
459
407
  // are scalar and equal
460
-
461
-
462
408
  var keys = Object.keys(nextProps);
463
-
464
409
  for (var ii = 0; ii < keys.length; ii++) {
465
- var _key = keys[ii];
466
-
467
- if (_key === '__relayContext') {
410
+ var key = keys[ii];
411
+ if (key === '__relayContext') {
468
412
  if (nextState.prevContext.environment !== this.state.prevContext.environment) {
469
413
  return true;
470
414
  }
471
415
  } else {
472
- if (!fragments.hasOwnProperty(_key) && !isScalarAndEqual(nextProps[_key], this.props[_key])) {
416
+ if (!fragments.hasOwnProperty(key) && !isScalarAndEqual(nextProps[key], this.props[key])) {
473
417
  return true;
474
418
  }
475
419
  }
476
420
  }
477
-
478
421
  return false;
479
422
  };
480
-
481
423
  _proto._buildRelayProp = function _buildRelayProp(relayContext) {
482
424
  return {
483
425
  hasMore: this._hasMore,
@@ -487,115 +429,97 @@ function createContainerWithFragments(Component, fragments, connectionConfig) {
487
429
  environment: relayContext.environment
488
430
  };
489
431
  };
490
-
491
432
  _proto._rerenderIfStoreHasChanged = function _rerenderIfStoreHasChanged() {
492
- var data = this.state.data; // External values could change between render and commit.
433
+ var data = this.state.data;
434
+ // External values could change between render and commit.
493
435
  // Check for this case, even though it requires an extra store read.
494
-
495
436
  var maybeNewData = this._resolver.resolve();
496
-
497
437
  if (data !== maybeNewData) {
498
438
  this.setState({
499
439
  data: maybeNewData
500
440
  });
501
441
  }
502
442
  };
503
-
504
443
  _proto._subscribeToNewResolverAndRerenderIfStoreHasChanged = function _subscribeToNewResolverAndRerenderIfStoreHasChanged() {
505
444
  var data = this.state.data;
445
+ var maybeNewData = this._resolver.resolve();
506
446
 
507
- var maybeNewData = this._resolver.resolve(); // Event listeners are only safe to add during the commit phase,
447
+ // Event listeners are only safe to add during the commit phase,
508
448
  // So they won't leak if render is interrupted or errors.
449
+ this._resolver.setCallback(this.props, this._handleFragmentDataUpdate);
509
450
 
510
-
511
- this._resolver.setCallback(this.props, this._handleFragmentDataUpdate); // External values could change between render and commit.
451
+ // External values could change between render and commit.
512
452
  // Check for this case, even though it requires an extra store read.
513
-
514
-
515
453
  if (data !== maybeNewData) {
516
454
  this.setState({
517
455
  data: maybeNewData
518
456
  });
519
457
  }
520
458
  }
459
+
521
460
  /**
522
461
  * Render new data for the existing props/context.
523
- */
524
- ;
525
-
462
+ */;
526
463
  _proto._getConnectionData = function _getConnectionData() {
527
464
  // Extract connection data and verify there are more edges to fetch
465
+ // eslint-disable-next-line no-unused-vars
528
466
  var _this$props = this.props,
529
- _ = _this$props.componentRef,
530
- restProps = (0, _objectWithoutPropertiesLoose2["default"])(_this$props, ["componentRef"]);
467
+ _ = _this$props.componentRef,
468
+ restProps = (0, _objectWithoutPropertiesLoose2["default"])(_this$props, _excluded);
531
469
  var props = (0, _objectSpread3["default"])((0, _objectSpread3["default"])({}, restProps), this.state.data);
532
470
  var connectionData = getConnectionFromProps(props);
533
-
534
471
  if (connectionData == null) {
535
472
  return null;
536
473
  }
537
-
538
474
  var _ConnectionInterface$2 = ConnectionInterface.get(),
539
- EDGES = _ConnectionInterface$2.EDGES,
540
- PAGE_INFO = _ConnectionInterface$2.PAGE_INFO,
541
- HAS_NEXT_PAGE = _ConnectionInterface$2.HAS_NEXT_PAGE,
542
- HAS_PREV_PAGE = _ConnectionInterface$2.HAS_PREV_PAGE,
543
- END_CURSOR = _ConnectionInterface$2.END_CURSOR,
544
- START_CURSOR = _ConnectionInterface$2.START_CURSOR;
545
-
475
+ EDGES = _ConnectionInterface$2.EDGES,
476
+ PAGE_INFO = _ConnectionInterface$2.PAGE_INFO,
477
+ HAS_NEXT_PAGE = _ConnectionInterface$2.HAS_NEXT_PAGE,
478
+ HAS_PREV_PAGE = _ConnectionInterface$2.HAS_PREV_PAGE,
479
+ END_CURSOR = _ConnectionInterface$2.END_CURSOR,
480
+ START_CURSOR = _ConnectionInterface$2.START_CURSOR;
546
481
  !(typeof connectionData === 'object') ? process.env.NODE_ENV !== "production" ? invariant(false, 'ReactRelayPaginationContainer: Expected `getConnectionFromProps()` in `%s`' + 'to return `null` or a plain object with %s and %s properties, got `%s`.', componentName, EDGES, PAGE_INFO, connectionData) : invariant(false) : void 0;
547
482
  var edges = connectionData[EDGES];
548
483
  var pageInfo = connectionData[PAGE_INFO];
549
-
550
484
  if (edges == null || pageInfo == null) {
551
485
  return null;
552
486
  }
553
-
554
487
  !Array.isArray(edges) ? process.env.NODE_ENV !== "production" ? invariant(false, 'ReactRelayPaginationContainer: Expected `getConnectionFromProps()` in `%s`' + 'to return an object with %s: Array, got `%s`.', componentName, EDGES, edges) : invariant(false) : void 0;
555
488
  !(typeof pageInfo === 'object') ? process.env.NODE_ENV !== "production" ? invariant(false, 'ReactRelayPaginationContainer: Expected `getConnectionFromProps()` in `%s`' + 'to return an object with %s: Object, got `%s`.', componentName, PAGE_INFO, pageInfo) : invariant(false) : void 0;
556
489
  var hasMore = direction === FORWARD ? pageInfo[HAS_NEXT_PAGE] : pageInfo[HAS_PREV_PAGE];
557
490
  var cursor = direction === FORWARD ? pageInfo[END_CURSOR] : pageInfo[START_CURSOR];
558
-
559
491
  if (typeof hasMore !== 'boolean' || edges.length !== 0 && typeof cursor === 'undefined') {
560
492
  process.env.NODE_ENV !== "production" ? warning(false, 'ReactRelayPaginationContainer: Cannot paginate without %s fields in `%s`. ' + 'Be sure to fetch %s (got `%s`) and %s (got `%s`).', PAGE_INFO, componentName, direction === FORWARD ? HAS_NEXT_PAGE : HAS_PREV_PAGE, hasMore, direction === FORWARD ? END_CURSOR : START_CURSOR, cursor) : void 0;
561
493
  return null;
562
494
  }
563
-
564
495
  return {
565
496
  cursor: cursor,
566
497
  edgeCount: edges.length,
567
498
  hasMore: hasMore
568
499
  };
569
500
  };
570
-
571
501
  _proto._getQueryFetcher = function _getQueryFetcher() {
572
502
  if (!this._queryFetcher) {
573
503
  this._queryFetcher = new ReactRelayQueryFetcher();
574
504
  }
575
-
576
505
  return this._queryFetcher;
577
506
  };
578
-
579
507
  _proto._canFetchPage = function _canFetchPage(method) {
580
508
  if (this._isUnmounted) {
581
509
  process.env.NODE_ENV !== "production" ? warning(false, 'ReactRelayPaginationContainer: Unexpected call of `%s` ' + 'on unmounted container `%s`. It looks like some instances ' + 'of your container still trying to fetch data but they already ' + 'unmounted. Please make sure you clear all timers, intervals, async ' + 'calls, etc that may trigger `%s` call.', method, containerName, method) : void 0;
582
510
  return false;
583
511
  }
584
-
585
512
  return true;
586
513
  };
587
-
588
514
  _proto._fetchPage = function _fetchPage(paginatingVariables, observer, options) {
589
515
  var _this3 = this;
590
-
591
516
  var _assertRelayContext = assertRelayContext(this.props.__relayContext),
592
- environment = _assertRelayContext.environment;
593
-
517
+ environment = _assertRelayContext.environment;
594
518
  var _this$props2 = this.props,
595
- _ = _this$props2.componentRef,
596
- __relayContext = _this$props2.__relayContext,
597
- __rootIsQueryRenderer = _this$props2.__rootIsQueryRenderer,
598
- restProps = (0, _objectWithoutPropertiesLoose2["default"])(_this$props2, ["componentRef", "__relayContext", "__rootIsQueryRenderer"]);
519
+ _ = _this$props2.componentRef,
520
+ __relayContext = _this$props2.__relayContext,
521
+ __rootIsQueryRenderer = _this$props2.__rootIsQueryRenderer,
522
+ restProps = (0, _objectWithoutPropertiesLoose2["default"])(_this$props2, _excluded2);
599
523
  var props = (0, _objectSpread3["default"])((0, _objectSpread3["default"])({}, restProps), this.state.data);
600
524
  var fragmentVariables;
601
525
  var rootVariables = getRootVariablesForFragments(fragments, restProps);
@@ -611,27 +535,22 @@ function createContainerWithFragments(Component, fragments, connectionConfig) {
611
535
  var cacheConfig = options ? {
612
536
  force: !!options.force
613
537
  } : undefined;
614
-
615
538
  if (cacheConfig != null && (options === null || options === void 0 ? void 0 : options.metadata) != null) {
616
539
  cacheConfig.metadata = options === null || options === void 0 ? void 0 : options.metadata;
617
540
  }
618
-
619
541
  var request = getRequest(connectionConfig.query);
620
542
  var operation = createOperationDescriptor(request, fetchVariables, cacheConfig);
621
543
  var refetchSubscription = null;
622
-
623
544
  if (this._refetchSubscription) {
624
545
  this._refetchSubscription.unsubscribe();
625
546
  }
626
-
627
547
  this._hasFetched = true;
628
-
629
548
  var onNext = function onNext(payload, complete) {
630
549
  var prevData = _this3._resolver.resolve();
631
-
632
550
  _this3._resolver.setVariables(getFragmentVariables(fragmentVariables, paginatingVariables.totalCount), operation.request.node);
551
+ var nextData = _this3._resolver.resolve();
633
552
 
634
- var nextData = _this3._resolver.resolve(); // Workaround slightly different handling for connection in different
553
+ // Workaround slightly different handling for connection in different
635
554
  // core implementations:
636
555
  // - Classic core requires the count to be explicitly incremented
637
556
  // - Modern core automatically appends new items, updating the count
@@ -640,8 +559,6 @@ function createContainerWithFragments(Component, fragments, connectionConfig) {
640
559
  // `setState` is only required if changing the variables would change the
641
560
  // resolved data.
642
561
  // TODO #14894725: remove PaginationContainer equal check
643
-
644
-
645
562
  if (!areEqual(prevData, nextData)) {
646
563
  _this3.setState({
647
564
  data: nextData,
@@ -653,14 +570,12 @@ function createContainerWithFragments(Component, fragments, connectionConfig) {
653
570
  complete();
654
571
  }
655
572
  };
656
-
657
573
  var cleanup = function cleanup() {
658
574
  if (_this3._refetchSubscription === refetchSubscription) {
659
575
  _this3._refetchSubscription = null;
660
576
  _this3._isARequestInFlight = false;
661
577
  }
662
578
  };
663
-
664
579
  this._isARequestInFlight = true;
665
580
  refetchSubscription = this._getQueryFetcher().execute({
666
581
  environment: environment,
@@ -670,11 +585,11 @@ function createContainerWithFragments(Component, fragments, connectionConfig) {
670
585
  return Observable.create(function (sink) {
671
586
  onNext(payload, function () {
672
587
  sink.next(); // pass void to public observer's `next`
673
-
674
588
  sink.complete();
675
589
  });
676
590
  });
677
- }) // use do instead of finally so that observer's `complete` fires after cleanup
591
+ })
592
+ // use do instead of finally so that observer's `complete` fires after cleanup
678
593
  ["do"]({
679
594
  error: cleanup,
680
595
  complete: cleanup,
@@ -683,31 +598,29 @@ function createContainerWithFragments(Component, fragments, connectionConfig) {
683
598
  this._refetchSubscription = this._isARequestInFlight ? refetchSubscription : null;
684
599
  return refetchSubscription;
685
600
  };
686
-
687
601
  _proto._cleanup = function _cleanup() {
688
602
  this._resolver.dispose();
689
-
690
603
  this._refetchVariables = null;
691
604
  this._hasFetched = false;
692
-
693
605
  if (this._refetchSubscription) {
694
606
  this._refetchSubscription.unsubscribe();
695
-
696
607
  this._refetchSubscription = null;
697
608
  this._isARequestInFlight = false;
698
609
  }
699
-
700
610
  if (this._queryFetcher) {
701
611
  this._queryFetcher.dispose();
702
612
  }
703
- };
613
+ }
704
614
 
615
+ // $FlowFixMe[missing-local-annot]
616
+ ;
705
617
  _proto.render = function render() {
618
+ // eslint-disable-next-line no-unused-vars
706
619
  var _this$props3 = this.props,
707
- componentRef = _this$props3.componentRef,
708
- __relayContext = _this$props3.__relayContext,
709
- __rootIsQueryRenderer = _this$props3.__rootIsQueryRenderer,
710
- props = (0, _objectWithoutPropertiesLoose2["default"])(_this$props3, ["componentRef", "__relayContext", "__rootIsQueryRenderer"]);
620
+ componentRef = _this$props3.componentRef,
621
+ __relayContext = _this$props3.__relayContext,
622
+ __rootIsQueryRenderer = _this$props3.__rootIsQueryRenderer,
623
+ props = (0, _objectWithoutPropertiesLoose2["default"])(_this$props3, _excluded3);
711
624
  return /*#__PURE__*/React.createElement(ReactRelayContext.Provider, {
712
625
  value: this.state.contextForChildren
713
626
  }, /*#__PURE__*/React.createElement(Component, (0, _extends2["default"])({}, props, this.state.data, {
@@ -715,10 +628,10 @@ function createContainerWithFragments(Component, fragments, connectionConfig) {
715
628
  relay: this.state.relayProp
716
629
  })));
717
630
  };
718
-
719
631
  return _class;
720
- }(React.Component), (0, _defineProperty2["default"])(_class, "displayName", containerName), _temp;
632
+ }(React.Component), (0, _defineProperty2["default"])(_class, "displayName", containerName), _class;
721
633
  }
634
+
722
635
  /**
723
636
  * Wrap the basic `createContainer()` function with logic to adapt to the
724
637
  * `context.relay.environment` in which it is rendered. Specifically, the
@@ -726,15 +639,12 @@ function createContainerWithFragments(Component, fragments, connectionConfig) {
726
639
  * `fragmentSpec` is memoized once per environment, rather than once per
727
640
  * instance of the container constructed/rendered.
728
641
  */
729
-
730
-
731
642
  function createContainer(Component, fragmentSpec, connectionConfig) {
732
643
  // $FlowFixMe[incompatible-return]
733
644
  return buildReactRelayContainer(Component, fragmentSpec, function (ComponentClass, fragments) {
734
645
  return createContainerWithFragments(ComponentClass, fragments, connectionConfig);
735
646
  });
736
647
  }
737
-
738
648
  module.exports = {
739
649
  createContainer: createContainer
740
650
  };