react-relay 14.1.0 → 16.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. package/ReactRelayContainerUtils.js.flow +1 -0
  2. package/ReactRelayContext.js +1 -1
  3. package/ReactRelayContext.js.flow +1 -0
  4. package/ReactRelayFragmentContainer.js.flow +6 -2
  5. package/ReactRelayFragmentMockRenderer.js.flow +1 -0
  6. package/ReactRelayLocalQueryRenderer.js.flow +5 -3
  7. package/ReactRelayPaginationContainer.js.flow +21 -12
  8. package/ReactRelayQueryFetcher.js.flow +20 -10
  9. package/ReactRelayQueryRenderer.js.flow +15 -11
  10. package/ReactRelayQueryRendererContext.js.flow +1 -0
  11. package/ReactRelayRefetchContainer.js.flow +9 -5
  12. package/ReactRelayTestMocker.js.flow +3 -1
  13. package/ReactRelayTypes.js.flow +2 -0
  14. package/RelayContext.js.flow +1 -0
  15. package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +2 -1
  16. package/__flowtests__/ReactRelayPaginationContainer-flowtest.js.flow +1 -0
  17. package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +1 -0
  18. package/__flowtests__/RelayModern-flowtest.js.flow +1 -0
  19. package/__flowtests__/RelayModernFlowtest_badref.graphql.js.flow +1 -0
  20. package/__flowtests__/RelayModernFlowtest_notref.graphql.js.flow +1 -0
  21. package/__flowtests__/RelayModernFlowtest_user.graphql.js.flow +1 -0
  22. package/__flowtests__/RelayModernFlowtest_users.graphql.js.flow +1 -0
  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 -0
  34. package/buildReactRelayContainer.js.flow +10 -6
  35. package/getRootVariablesForFragments.js.flow +1 -1
  36. package/hooks.js +1 -1
  37. package/hooks.js.flow +4 -0
  38. package/index.js +1 -1
  39. package/index.js.flow +4 -0
  40. package/isRelayEnvironment.js.flow +1 -0
  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 -0
  46. package/lib/ReactRelayContainerUtils.js +0 -11
  47. package/lib/ReactRelayContext.js +1 -12
  48. package/lib/ReactRelayFragmentContainer.js +23 -122
  49. package/lib/ReactRelayFragmentMockRenderer.js +0 -12
  50. package/lib/ReactRelayLocalQueryRenderer.js +12 -41
  51. package/lib/ReactRelayPaginationContainer.js +45 -341
  52. package/lib/ReactRelayQueryFetcher.js +36 -111
  53. package/lib/ReactRelayQueryRenderer.js +29 -137
  54. package/lib/ReactRelayQueryRendererContext.js +0 -10
  55. package/lib/ReactRelayRefetchContainer.js +33 -166
  56. package/lib/ReactRelayTestMocker.js +18 -128
  57. package/lib/ReactRelayTypes.js +0 -9
  58. package/lib/RelayContext.js +0 -23
  59. package/lib/assertFragmentMap.js +0 -16
  60. package/lib/buildReactRelayContainer.js +7 -41
  61. package/lib/getRootVariablesForFragments.js +2 -19
  62. package/lib/hooks.js +3 -30
  63. package/lib/index.js +3 -39
  64. package/lib/isRelayEnvironment.js +1 -16
  65. package/lib/jest-react/enqueueTask.js +1 -25
  66. package/lib/jest-react/index.js +0 -1
  67. package/lib/jest-react/internalAct.js +2 -51
  68. package/lib/legacy.js +0 -20
  69. package/lib/multi-actor/ActorChange.js +0 -14
  70. package/lib/multi-actor/index.js +0 -10
  71. package/lib/multi-actor/useRelayActorEnvironment.js +2 -16
  72. package/lib/relay-hooks/EntryPointContainer.react.js +7 -23
  73. package/lib/relay-hooks/EntryPointTypes.flow.js +0 -10
  74. package/lib/relay-hooks/FragmentResource.js +130 -280
  75. package/lib/relay-hooks/HooksImplementation.js +0 -14
  76. package/lib/relay-hooks/InternalLogger.js +0 -11
  77. package/lib/relay-hooks/LRUCache.js +0 -39
  78. package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +27 -65
  79. package/lib/relay-hooks/MatchContainer.js +9 -111
  80. package/lib/relay-hooks/NestedRelayEntryPointBuilderUtils.js +9 -0
  81. package/lib/relay-hooks/ProfilerContext.js +0 -14
  82. package/lib/relay-hooks/QueryResource.js +14 -149
  83. package/lib/relay-hooks/RelayEnvironmentProvider.js +3 -17
  84. package/lib/relay-hooks/SuspenseResource.js +2 -59
  85. package/lib/relay-hooks/loadEntryPoint.js +10 -45
  86. package/lib/relay-hooks/loadQuery.js +29 -169
  87. package/lib/relay-hooks/preloadQuery_DEPRECATED.js +8 -58
  88. package/lib/relay-hooks/prepareEntryPoint_DEPRECATED.js +6 -24
  89. package/lib/relay-hooks/react-cache/RelayReactCache.js +4 -20
  90. package/lib/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js +13 -102
  91. package/lib/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js +18 -75
  92. package/lib/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js +79 -222
  93. package/lib/relay-hooks/react-cache/useFragment_REACT_CACHE.js +3 -27
  94. package/lib/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js +11 -33
  95. package/lib/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js +62 -85
  96. package/lib/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js +20 -63
  97. package/lib/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js +53 -179
  98. package/lib/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js +5 -27
  99. package/lib/relay-hooks/useBlockingPaginationFragment.js +58 -121
  100. package/lib/relay-hooks/useClientQuery.js +0 -21
  101. package/lib/relay-hooks/useEntryPointLoader.js +12 -100
  102. package/lib/relay-hooks/useFetchTrackingRef.js +6 -33
  103. package/lib/relay-hooks/useFragment.js +5 -32
  104. package/lib/relay-hooks/useFragmentNode.js +14 -55
  105. package/lib/relay-hooks/useIsMountedRef.js +2 -14
  106. package/lib/relay-hooks/useIsOperationNodeActive.js +6 -29
  107. package/lib/relay-hooks/useIsParentQueryActive.js +1 -15
  108. package/lib/relay-hooks/useLazyLoadQuery.js +2 -23
  109. package/lib/relay-hooks/useLazyLoadQueryNode.js +18 -63
  110. package/lib/relay-hooks/useLoadMoreFunction.js +44 -100
  111. package/lib/relay-hooks/useMemoOperationDescriptor.js +4 -23
  112. package/lib/relay-hooks/useMemoVariables.js +8 -43
  113. package/lib/relay-hooks/useMutation.js +6 -34
  114. package/lib/relay-hooks/usePaginationFragment.js +49 -89
  115. package/lib/relay-hooks/usePreloadedQuery.js +10 -54
  116. package/lib/relay-hooks/useQueryLoader.js +18 -116
  117. package/lib/relay-hooks/useRefetchableFragment.js +4 -30
  118. package/lib/relay-hooks/useRefetchableFragmentNode.js +58 -184
  119. package/lib/relay-hooks/useRelayEnvironment.js +2 -16
  120. package/lib/relay-hooks/useStaticFragmentNodeWarning.js +2 -20
  121. package/lib/relay-hooks/useSubscribeToInvalidationState.js +3 -28
  122. package/lib/relay-hooks/useSubscription.js +3 -22
  123. package/lib/relay-hooks/useUnsafeRef_DEPRECATED.js +12 -0
  124. package/multi-actor/ActorChange.js.flow +1 -1
  125. package/multi-actor/index.js.flow +1 -1
  126. package/multi-actor/useRelayActorEnvironment.js.flow +2 -2
  127. package/package.json +2 -2
  128. package/react-relay-hooks.js +2 -2
  129. package/react-relay-hooks.min.js +2 -2
  130. package/react-relay-legacy.js +2 -2
  131. package/react-relay-legacy.min.js +2 -2
  132. package/react-relay.js +2 -2
  133. package/react-relay.min.js +2 -2
  134. package/relay-hooks/EntryPointContainer.react.js.flow +6 -1
  135. package/relay-hooks/EntryPointTypes.flow.js.flow +23 -20
  136. package/relay-hooks/FragmentResource.js.flow +148 -34
  137. package/relay-hooks/HooksImplementation.js.flow +1 -1
  138. package/relay-hooks/InternalLogger.js.flow +1 -1
  139. package/relay-hooks/LRUCache.js.flow +1 -1
  140. package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +19 -10
  141. package/relay-hooks/MatchContainer.js.flow +1 -1
  142. package/relay-hooks/NestedRelayEntryPointBuilderUtils.js.flow +51 -0
  143. package/relay-hooks/ProfilerContext.js.flow +1 -1
  144. package/relay-hooks/QueryResource.js.flow +25 -5
  145. package/relay-hooks/RelayEnvironmentProvider.js.flow +2 -2
  146. package/relay-hooks/SuspenseResource.js.flow +1 -1
  147. package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +3 -1
  148. package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +9 -7
  149. package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_user.graphql.js.flow +3 -1
  150. package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_users.graphql.js.flow +3 -1
  151. package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +40 -33
  152. package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +1 -1
  153. package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +38 -32
  154. package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +20 -18
  155. package/relay-hooks/__flowtests__/utils.js.flow +13 -2
  156. package/relay-hooks/loadEntryPoint.js.flow +15 -8
  157. package/relay-hooks/loadQuery.js.flow +32 -8
  158. package/relay-hooks/preloadQuery_DEPRECATED.js.flow +5 -6
  159. package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +17 -10
  160. package/relay-hooks/react-cache/RelayReactCache.js.flow +1 -1
  161. package/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js.flow +4 -4
  162. package/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js.flow +5 -4
  163. package/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js.flow +32 -14
  164. package/relay-hooks/react-cache/useFragment_REACT_CACHE.js.flow +4 -10
  165. package/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js.flow +1 -1
  166. package/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js.flow +39 -49
  167. package/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js.flow +1 -2
  168. package/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js.flow +29 -16
  169. package/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js.flow +17 -33
  170. package/relay-hooks/useBlockingPaginationFragment.js.flow +85 -58
  171. package/relay-hooks/useClientQuery.js.flow +3 -3
  172. package/relay-hooks/useEntryPointLoader.js.flow +10 -6
  173. package/relay-hooks/useFetchTrackingRef.js.flow +5 -4
  174. package/relay-hooks/useFragment.js.flow +2 -2
  175. package/relay-hooks/useFragmentNode.js.flow +7 -6
  176. package/relay-hooks/useIsMountedRef.js.flow +1 -1
  177. package/relay-hooks/useIsOperationNodeActive.js.flow +1 -1
  178. package/relay-hooks/useIsParentQueryActive.js.flow +1 -1
  179. package/relay-hooks/useLazyLoadQuery.js.flow +2 -2
  180. package/relay-hooks/useLazyLoadQueryNode.js.flow +2 -2
  181. package/relay-hooks/useLoadMoreFunction.js.flow +27 -16
  182. package/relay-hooks/useMemoOperationDescriptor.js.flow +3 -3
  183. package/relay-hooks/useMemoVariables.js.flow +13 -29
  184. package/relay-hooks/useMutation.js.flow +30 -13
  185. package/relay-hooks/usePaginationFragment.js.flow +55 -54
  186. package/relay-hooks/usePreloadedQuery.js.flow +47 -22
  187. package/relay-hooks/useQueryLoader.js.flow +78 -21
  188. package/relay-hooks/useRefetchableFragment.js.flow +65 -33
  189. package/relay-hooks/useRefetchableFragmentNode.js.flow +38 -17
  190. package/relay-hooks/useRelayEnvironment.js.flow +2 -2
  191. package/relay-hooks/useStaticFragmentNodeWarning.js.flow +3 -3
  192. package/relay-hooks/useSubscribeToInvalidationState.js.flow +2 -2
  193. package/relay-hooks/useSubscription.js.flow +1 -1
  194. package/relay-hooks/useUnsafeRef_DEPRECATED.js.flow +25 -0
  195. package/lib/readContext.js +0 -27
  196. package/readContext.js.flow +0 -29
@@ -1,55 +1,33 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @emails oncall+relay
9
- * @format
10
- */
11
1
  'use strict';
12
2
 
13
3
  var _require = require('../loadQuery'),
14
- useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
15
-
4
+ useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
16
5
  var useMemoOperationDescriptor = require('../useMemoOperationDescriptor');
17
-
18
6
  var useRelayEnvironment = require('../useRelayEnvironment');
19
-
20
7
  var getQueryResultOrFetchQuery = require('./getQueryResultOrFetchQuery_REACT_CACHE');
21
-
22
8
  var useFragmentInternal = require('./useFragmentInternal_REACT_CACHE');
23
-
24
9
  var _require2 = require('react'),
25
- useEffect = _require2.useEffect;
26
-
10
+ useEffect = _require2.useEffect;
27
11
  function useLazyLoadQuery_REACT_CACHE(gqlQuery, variables, options) {
28
12
  var _options$networkCache;
29
-
30
13
  useTrackLoadQueryInRender();
31
14
  var environment = useRelayEnvironment();
32
15
  var queryOperationDescriptor = useMemoOperationDescriptor(gqlQuery, variables, (_options$networkCache = options === null || options === void 0 ? void 0 : options.networkCacheConfig) !== null && _options$networkCache !== void 0 ? _options$networkCache : {
33
16
  force: true
34
- }); // Get the query going if needed -- this may suspend.
35
-
17
+ });
36
18
  var _getQueryResultOrFetc = getQueryResultOrFetchQuery(environment, queryOperationDescriptor, {
37
- fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
38
- renderPolicy: options === null || options === void 0 ? void 0 : options.UNSTABLE_renderPolicy,
39
- fetchKey: options === null || options === void 0 ? void 0 : options.fetchKey
40
- }),
41
- queryResult = _getQueryResultOrFetc[0],
42
- effect = _getQueryResultOrFetc[1];
43
-
44
- useEffect(effect); // Read the query's root fragment -- this may suspend.
45
-
19
+ fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
20
+ renderPolicy: options === null || options === void 0 ? void 0 : options.UNSTABLE_renderPolicy,
21
+ fetchKey: options === null || options === void 0 ? void 0 : options.fetchKey
22
+ }),
23
+ queryResult = _getQueryResultOrFetc[0],
24
+ effect = _getQueryResultOrFetc[1];
25
+ useEffect(effect);
46
26
  var fragmentNode = queryResult.fragmentNode,
47
- fragmentRef = queryResult.fragmentRef; // $FlowExpectedError[incompatible-return] Is this a fixable incompatible-return?
48
-
27
+ fragmentRef = queryResult.fragmentRef;
49
28
  return useFragmentInternal(fragmentNode, fragmentRef, 'useLazyLoadQuery()', {
50
29
  fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
51
30
  networkCacheConfig: options === null || options === void 0 ? void 0 : options.networkCacheConfig
52
31
  });
53
32
  }
54
-
55
33
  module.exports = useLazyLoadQuery_REACT_CACHE;
@@ -1,88 +1,62 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @emails oncall+relay
8
- *
9
- * @format
10
- */
11
1
  'use strict';
12
2
 
13
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
14
-
15
4
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
16
-
17
5
  var useLoadMoreFunction = require('../useLoadMoreFunction');
18
-
6
+ var useRelayEnvironment = require('../useRelayEnvironment');
19
7
  var useStaticFragmentNodeWarning = require('../useStaticFragmentNodeWarning');
20
-
21
8
  var useRefetchableFragmentInternal = require('./useRefetchableFragmentInternal_REACT_CACHE');
22
-
23
9
  var _require = require('react'),
24
- useCallback = _require.useCallback,
25
- useDebugValue = _require.useDebugValue,
26
- useState = _require.useState;
27
-
10
+ useCallback = _require.useCallback,
11
+ useDebugValue = _require.useDebugValue,
12
+ useState = _require.useState;
28
13
  var _require2 = require('relay-runtime'),
29
- getFragment = _require2.getFragment,
30
- getFragmentIdentifier = _require2.getFragmentIdentifier,
31
- getPaginationMetadata = _require2.getPaginationMetadata;
32
-
14
+ getFragment = _require2.getFragment,
15
+ getFragmentIdentifier = _require2.getFragmentIdentifier,
16
+ getPaginationMetadata = _require2.getPaginationMetadata;
33
17
  function usePaginationFragment(fragmentInput, parentFragmentRef) {
34
18
  var fragmentNode = getFragment(fragmentInput);
35
19
  useStaticFragmentNodeWarning(fragmentNode, 'first argument of usePaginationFragment()');
36
20
  var componentDisplayName = 'usePaginationFragment()';
37
-
38
21
  var _getPaginationMetadat = getPaginationMetadata(fragmentNode, componentDisplayName),
39
- connectionPathInFragmentData = _getPaginationMetadat.connectionPathInFragmentData,
40
- paginationRequest = _getPaginationMetadat.paginationRequest,
41
- paginationMetadata = _getPaginationMetadat.paginationMetadata,
42
- identifierField = _getPaginationMetadat.identifierField;
43
-
22
+ connectionPathInFragmentData = _getPaginationMetadat.connectionPathInFragmentData,
23
+ paginationRequest = _getPaginationMetadat.paginationRequest,
24
+ paginationMetadata = _getPaginationMetadat.paginationMetadata;
44
25
  var _useRefetchableFragme = useRefetchableFragmentInternal(fragmentNode, parentFragmentRef, componentDisplayName),
45
- fragmentData = _useRefetchableFragme.fragmentData,
46
- fragmentRef = _useRefetchableFragme.fragmentRef,
47
- refetch = _useRefetchableFragme.refetch;
48
-
49
- var fragmentIdentifier = getFragmentIdentifier(fragmentNode, fragmentRef); // Backward pagination
50
-
26
+ fragmentData = _useRefetchableFragme.fragmentData,
27
+ fragmentRef = _useRefetchableFragme.fragmentRef,
28
+ refetch = _useRefetchableFragme.refetch;
29
+ var fragmentIdentifier = getFragmentIdentifier(fragmentNode, fragmentRef);
51
30
  var _useLoadMore = useLoadMore({
52
- componentDisplayName: componentDisplayName,
53
- connectionPathInFragmentData: connectionPathInFragmentData,
54
- direction: 'backward',
55
- fragmentData: fragmentData,
56
- fragmentIdentifier: fragmentIdentifier,
57
- fragmentNode: fragmentNode,
58
- fragmentRef: fragmentRef,
59
- identifierField: identifierField,
60
- paginationMetadata: paginationMetadata,
61
- paginationRequest: paginationRequest
62
- }),
63
- loadPrevious = _useLoadMore[0],
64
- hasPrevious = _useLoadMore[1],
65
- isLoadingPrevious = _useLoadMore[2],
66
- disposeFetchPrevious = _useLoadMore[3]; // Forward pagination
67
-
68
-
31
+ componentDisplayName: componentDisplayName,
32
+ connectionPathInFragmentData: connectionPathInFragmentData,
33
+ direction: 'backward',
34
+ fragmentData: fragmentData,
35
+ fragmentIdentifier: fragmentIdentifier,
36
+ fragmentNode: fragmentNode,
37
+ fragmentRef: fragmentRef,
38
+ paginationMetadata: paginationMetadata,
39
+ paginationRequest: paginationRequest
40
+ }),
41
+ loadPrevious = _useLoadMore[0],
42
+ hasPrevious = _useLoadMore[1],
43
+ isLoadingPrevious = _useLoadMore[2],
44
+ disposeFetchPrevious = _useLoadMore[3];
69
45
  var _useLoadMore2 = useLoadMore({
70
- componentDisplayName: componentDisplayName,
71
- connectionPathInFragmentData: connectionPathInFragmentData,
72
- direction: 'forward',
73
- fragmentData: fragmentData,
74
- fragmentIdentifier: fragmentIdentifier,
75
- fragmentNode: fragmentNode,
76
- fragmentRef: fragmentRef,
77
- identifierField: identifierField,
78
- paginationMetadata: paginationMetadata,
79
- paginationRequest: paginationRequest
80
- }),
81
- loadNext = _useLoadMore2[0],
82
- hasNext = _useLoadMore2[1],
83
- isLoadingNext = _useLoadMore2[2],
84
- disposeFetchNext = _useLoadMore2[3];
85
-
46
+ componentDisplayName: componentDisplayName,
47
+ connectionPathInFragmentData: connectionPathInFragmentData,
48
+ direction: 'forward',
49
+ fragmentData: fragmentData,
50
+ fragmentIdentifier: fragmentIdentifier,
51
+ fragmentNode: fragmentNode,
52
+ fragmentRef: fragmentRef,
53
+ paginationMetadata: paginationMetadata,
54
+ paginationRequest: paginationRequest
55
+ }),
56
+ loadNext = _useLoadMore2[0],
57
+ hasNext = _useLoadMore2[1],
58
+ isLoadingNext = _useLoadMore2[2],
59
+ disposeFetchNext = _useLoadMore2[3];
86
60
  var refetchPagination = useCallback(function (variables, options) {
87
61
  disposeFetchNext();
88
62
  disposeFetchPrevious();
@@ -90,9 +64,7 @@ function usePaginationFragment(fragmentInput, parentFragmentRef) {
90
64
  __environment: undefined
91
65
  }));
92
66
  }, [disposeFetchNext, disposeFetchPrevious, refetch]);
93
-
94
67
  if (process.env.NODE_ENV !== "production") {
95
- // eslint-disable-next-line react-hooks/rules-of-hooks
96
68
  useDebugValue({
97
69
  fragment: fragmentNode.name,
98
70
  data: fragmentData,
@@ -102,7 +74,6 @@ function usePaginationFragment(fragmentInput, parentFragmentRef) {
102
74
  isLoadingPrevious: isLoadingPrevious
103
75
  });
104
76
  }
105
-
106
77
  return {
107
78
  data: fragmentData,
108
79
  loadNext: loadNext,
@@ -114,12 +85,22 @@ function usePaginationFragment(fragmentInput, parentFragmentRef) {
114
85
  refetch: refetchPagination
115
86
  };
116
87
  }
117
-
118
88
  function useLoadMore(args) {
89
+ var environment = useRelayEnvironment();
119
90
  var _useState = useState(false),
120
- isLoadingMore = _useState[0],
121
- setIsLoadingMore = _useState[1];
122
-
91
+ isLoadingMore = _useState[0],
92
+ reallySetIsLoadingMore = _useState[1];
93
+ var setIsLoadingMore = function setIsLoadingMore(value) {
94
+ var _environment$getSched;
95
+ var schedule = (_environment$getSched = environment.getScheduler()) === null || _environment$getSched === void 0 ? void 0 : _environment$getSched.schedule;
96
+ if (schedule) {
97
+ schedule(function () {
98
+ reallySetIsLoadingMore(value);
99
+ });
100
+ } else {
101
+ reallySetIsLoadingMore(value);
102
+ }
103
+ };
123
104
  var observer = {
124
105
  start: function start() {
125
106
  return setIsLoadingMore(true);
@@ -131,20 +112,16 @@ function useLoadMore(args) {
131
112
  return setIsLoadingMore(false);
132
113
  }
133
114
  };
134
-
135
115
  var handleReset = function handleReset() {
136
116
  return setIsLoadingMore(false);
137
117
  };
138
-
139
118
  var _useLoadMoreFunction = useLoadMoreFunction((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, args), {}, {
140
- observer: observer,
141
- onReset: handleReset
142
- })),
143
- loadMore = _useLoadMoreFunction[0],
144
- hasMore = _useLoadMoreFunction[1],
145
- disposeFetch = _useLoadMoreFunction[2];
146
-
119
+ observer: observer,
120
+ onReset: handleReset
121
+ })),
122
+ loadMore = _useLoadMoreFunction[0],
123
+ hasMore = _useLoadMoreFunction[1],
124
+ disposeFetch = _useLoadMoreFunction[2];
147
125
  return [loadMore, hasMore, isLoadingMore, disposeFetch];
148
126
  }
149
-
150
127
  module.exports = usePaginationFragment;
@@ -1,50 +1,30 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @emails oncall+relay
9
- * @format
10
- */
11
1
  'use strict';
12
2
 
13
3
  var _require = require('../loadQuery'),
14
- useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
15
-
4
+ useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
16
5
  var useMemoOperationDescriptor = require('../useMemoOperationDescriptor');
17
-
18
6
  var useRelayEnvironment = require('../useRelayEnvironment');
19
-
20
7
  var getQueryResultOrFetchQuery = require('./getQueryResultOrFetchQuery_REACT_CACHE');
21
-
22
8
  var useFragmentInternal = require('./useFragmentInternal_REACT_CACHE');
23
-
24
9
  var invariant = require('invariant');
25
-
26
10
  var _require2 = require('react'),
27
- useDebugValue = _require2.useDebugValue,
28
- useEffect = _require2.useEffect;
29
-
11
+ useDebugValue = _require2.useDebugValue,
12
+ useEffect = _require2.useEffect;
30
13
  var _require3 = require('relay-runtime'),
31
- _require3$__internal = _require3.__internal,
32
- fetchQueryDeduped = _require3$__internal.fetchQueryDeduped,
33
- fetchQuery = _require3$__internal.fetchQuery;
34
-
14
+ _require3$__internal = _require3.__internal,
15
+ fetchQueryDeduped = _require3$__internal.fetchQueryDeduped,
16
+ fetchQuery = _require3$__internal.fetchQuery;
35
17
  var warning = require("fbjs/lib/warning");
36
-
37
18
  function usePreloadedQuery_REACT_CACHE(gqlQuery, preloadedQuery, options) {
38
19
  var environment = useRelayEnvironment();
39
20
  useTrackLoadQueryInRender();
40
21
  var fetchKey = preloadedQuery.fetchKey,
41
- fetchPolicy = preloadedQuery.fetchPolicy,
42
- source = preloadedQuery.source,
43
- variables = preloadedQuery.variables,
44
- networkCacheConfig = preloadedQuery.networkCacheConfig;
22
+ fetchPolicy = preloadedQuery.fetchPolicy,
23
+ source = preloadedQuery.source,
24
+ variables = preloadedQuery.variables,
25
+ networkCacheConfig = preloadedQuery.networkCacheConfig;
45
26
  var operation = useMemoOperationDescriptor(gqlQuery, variables, networkCacheConfig);
46
27
  var fetchObservable;
47
-
48
28
  if (preloadedQuery.kind === 'PreloadedQuery_DEPRECATED') {
49
29
  !(operation.request.node.params.name === preloadedQuery.name) ? process.env.NODE_ENV !== "production" ? invariant(false, 'usePreloadedQuery(): Expected data to be prefetched for query `%s`, ' + 'got prefetch results for query `%s`.', operation.request.node.params.name, preloadedQuery.name) : invariant(false) : void 0;
50
30
  fetchObservable = fetchQueryDeduped(environment, operation.request.identifier, function () {
@@ -62,52 +42,31 @@ function usePreloadedQuery_REACT_CACHE(gqlQuery, preloadedQuery, options) {
62
42
  } else {
63
43
  process.env.NODE_ENV !== "production" ? warning(preloadedQuery.isDisposed === false, 'usePreloadedQuery(): Expected preloadedQuery to not be disposed yet. ' + 'This is because disposing the query marks it for future garbage ' + 'collection, and as such query results may no longer be present in the Relay ' + 'store. In the future, this will become a hard error.') : void 0;
64
44
  var fallbackFetchObservable = fetchQuery(environment, operation);
65
-
66
45
  if (source != null && environment === preloadedQuery.environment) {
67
- // If the source observable exists and the environments match, reuse
68
- // the source observable.
69
- // If the source observable happens to be empty, we need to fall back
70
- // and re-execute and de-dupe the query (at render time).
71
46
  fetchObservable = source.ifEmpty(fallbackFetchObservable);
72
47
  } else if (environment !== preloadedQuery.environment) {
73
- // If a call to loadQuery is made with a particular environment, and that
74
- // preloaded query is passed to usePreloadedQuery in a different environment
75
- // context, we cannot re-use the existing preloaded query.
76
- // Instead, we need to fall back and re-execute and de-dupe the query with
77
- // the new environment (at render time).
78
- // TODO T68036756 track occurences of this warning and turn it into a hard error
79
48
  process.env.NODE_ENV !== "production" ? warning(false, 'usePreloadedQuery(): usePreloadedQuery was passed a preloaded query ' + 'that was created with a different environment than the one that is currently ' + 'in context. In the future, this will become a hard error.') : void 0;
80
49
  fetchObservable = fallbackFetchObservable;
81
50
  } else {
82
- // if (source == null)
83
- // If the source observable does not exist, we need to
84
- // fall back and re-execute and de-dupe the query (at render time).
85
51
  fetchObservable = fallbackFetchObservable;
86
52
  }
87
- } // Get the query going if needed -- this may suspend.
88
-
89
-
53
+ }
90
54
  var _getQueryResultOrFetc = getQueryResultOrFetchQuery(environment, operation, {
91
- fetchPolicy: fetchPolicy,
92
- renderPolicy: options === null || options === void 0 ? void 0 : options.UNSTABLE_renderPolicy,
93
- fetchKey: fetchKey,
94
- fetchObservable: fetchObservable
95
- }),
96
- queryResult = _getQueryResultOrFetc[0],
97
- effect = _getQueryResultOrFetc[1];
98
-
99
- useEffect(effect); // Read the query's root fragment -- this may suspend.
100
-
55
+ fetchPolicy: fetchPolicy,
56
+ renderPolicy: options === null || options === void 0 ? void 0 : options.UNSTABLE_renderPolicy,
57
+ fetchKey: fetchKey,
58
+ fetchObservable: fetchObservable
59
+ }),
60
+ queryResult = _getQueryResultOrFetc[0],
61
+ effect = _getQueryResultOrFetc[1];
62
+ useEffect(effect);
101
63
  var fragmentNode = queryResult.fragmentNode,
102
- fragmentRef = queryResult.fragmentRef; // $FlowExpectedError[incompatible-return] Is this a fixable incompatible-return?
103
-
64
+ fragmentRef = queryResult.fragmentRef;
104
65
  var data = useFragmentInternal(fragmentNode, fragmentRef, 'usePreloadedQuery()', {
105
66
  fetchPolicy: fetchPolicy,
106
67
  networkCacheConfig: networkCacheConfig
107
68
  });
108
-
109
69
  if (process.env.NODE_ENV !== "production") {
110
- // eslint-disable-next-line react-hooks/rules-of-hooks
111
70
  useDebugValue({
112
71
  query: preloadedQuery.name,
113
72
  variables: preloadedQuery.variables,
@@ -117,8 +76,6 @@ function usePreloadedQuery_REACT_CACHE(gqlQuery, preloadedQuery, options) {
117
76
  renderPolicy: options === null || options === void 0 ? void 0 : options.UNSTABLE_renderPolicy
118
77
  });
119
78
  }
120
-
121
79
  return data;
122
80
  }
123
-
124
81
  module.exports = usePreloadedQuery_REACT_CACHE;