react-relay 14.1.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 -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 +19 -5
  9. package/ReactRelayQueryRenderer.js.flow +32 -1
  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 +1 -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 +7 -5
  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 +2 -2
  47. package/lib/ReactRelayContext.js +3 -3
  48. package/lib/ReactRelayFragmentContainer.js +39 -66
  49. package/lib/ReactRelayFragmentMockRenderer.js +2 -3
  50. package/lib/ReactRelayLocalQueryRenderer.js +18 -30
  51. package/lib/ReactRelayPaginationContainer.js +66 -159
  52. package/lib/ReactRelayQueryFetcher.js +48 -74
  53. package/lib/ReactRelayQueryRenderer.js +62 -82
  54. package/lib/ReactRelayQueryRendererContext.js +2 -1
  55. package/lib/ReactRelayRefetchContainer.js +52 -99
  56. package/lib/ReactRelayTestMocker.js +32 -66
  57. package/lib/ReactRelayTypes.js +2 -0
  58. package/lib/RelayContext.js +4 -6
  59. package/lib/assertFragmentMap.js +3 -4
  60. package/lib/buildReactRelayContainer.js +10 -25
  61. package/lib/getRootVariablesForFragments.js +5 -8
  62. package/lib/hooks.js +5 -17
  63. package/lib/index.js +5 -24
  64. package/lib/isRelayEnvironment.js +5 -3
  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 -7
  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 -7
  72. package/lib/relay-hooks/EntryPointContainer.react.js +9 -14
  73. package/lib/relay-hooks/EntryPointTypes.flow.js +5 -2
  74. package/lib/relay-hooks/FragmentResource.js +102 -196
  75. package/lib/relay-hooks/HooksImplementation.js +2 -5
  76. package/lib/relay-hooks/InternalLogger.js +2 -2
  77. package/lib/relay-hooks/LRUCache.js +2 -19
  78. package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +33 -53
  79. package/lib/relay-hooks/MatchContainer.js +14 -22
  80. package/lib/relay-hooks/ProfilerContext.js +3 -2
  81. package/lib/relay-hooks/QueryResource.js +30 -99
  82. package/lib/relay-hooks/RelayEnvironmentProvider.js +5 -8
  83. package/lib/relay-hooks/SuspenseResource.js +8 -31
  84. package/lib/relay-hooks/loadEntryPoint.js +19 -31
  85. package/lib/relay-hooks/loadQuery.js +41 -77
  86. package/lib/relay-hooks/preloadQuery_DEPRECATED.js +10 -35
  87. package/lib/relay-hooks/prepareEntryPoint_DEPRECATED.js +9 -14
  88. package/lib/relay-hooks/react-cache/RelayReactCache.js +7 -11
  89. package/lib/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js +24 -78
  90. package/lib/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js +23 -56
  91. package/lib/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js +65 -143
  92. package/lib/relay-hooks/react-cache/useFragment_REACT_CACHE.js +5 -14
  93. package/lib/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js +17 -23
  94. package/lib/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js +73 -74
  95. package/lib/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js +24 -38
  96. package/lib/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js +60 -102
  97. package/lib/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js +7 -15
  98. package/lib/relay-hooks/useBlockingPaginationFragment.js +71 -92
  99. package/lib/relay-hooks/useClientQuery.js +3 -6
  100. package/lib/relay-hooks/useEntryPointLoader.js +17 -36
  101. package/lib/relay-hooks/useFetchTrackingRef.js +10 -11
  102. package/lib/relay-hooks/useFragment.js +8 -18
  103. package/lib/relay-hooks/useFragmentNode.js +20 -31
  104. package/lib/relay-hooks/useIsMountedRef.js +4 -5
  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 +6 -9
  108. package/lib/relay-hooks/useLazyLoadQueryNode.js +23 -33
  109. package/lib/relay-hooks/useLoadMoreFunction.js +45 -76
  110. package/lib/relay-hooks/useMemoOperationDescriptor.js +6 -14
  111. package/lib/relay-hooks/useMemoVariables.js +15 -33
  112. package/lib/relay-hooks/useMutation.js +8 -25
  113. package/lib/relay-hooks/usePaginationFragment.js +61 -76
  114. package/lib/relay-hooks/usePreloadedQuery.js +12 -29
  115. package/lib/relay-hooks/useQueryLoader.js +23 -47
  116. package/lib/relay-hooks/useRefetchableFragment.js +8 -18
  117. package/lib/relay-hooks/useRefetchableFragmentNode.js +64 -107
  118. package/lib/relay-hooks/useRelayEnvironment.js +4 -7
  119. package/lib/relay-hooks/useStaticFragmentNodeWarning.js +4 -7
  120. package/lib/relay-hooks/useSubscribeToInvalidationState.js +8 -8
  121. package/lib/relay-hooks/useSubscription.js +5 -9
  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 -2
  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 +1 -1
  134. package/relay-hooks/EntryPointTypes.flow.js.flow +7 -5
  135. package/relay-hooks/FragmentResource.js.flow +34 -8
  136. package/relay-hooks/HooksImplementation.js.flow +1 -1
  137. package/relay-hooks/InternalLogger.js.flow +1 -1
  138. package/relay-hooks/LRUCache.js.flow +1 -1
  139. package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +15 -8
  140. package/relay-hooks/MatchContainer.js.flow +1 -1
  141. package/relay-hooks/ProfilerContext.js.flow +1 -1
  142. package/relay-hooks/QueryResource.js.flow +25 -5
  143. package/relay-hooks/RelayEnvironmentProvider.js.flow +2 -2
  144. package/relay-hooks/SuspenseResource.js.flow +1 -1
  145. package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +3 -1
  146. package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +2 -2
  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 +35 -33
  150. package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +1 -1
  151. package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +33 -32
  152. package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +18 -18
  153. package/relay-hooks/__flowtests__/utils.js.flow +13 -2
  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 +5 -6
  157. package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +13 -8
  158. package/relay-hooks/react-cache/RelayReactCache.js.flow +1 -1
  159. package/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js.flow +4 -4
  160. package/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js.flow +3 -3
  161. package/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js.flow +4 -4
  162. package/relay-hooks/react-cache/useFragment_REACT_CACHE.js.flow +1 -1
  163. package/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js.flow +1 -1
  164. package/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js.flow +41 -22
  165. package/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js.flow +1 -2
  166. package/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js.flow +11 -5
  167. package/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js.flow +2 -2
  168. package/relay-hooks/useBlockingPaginationFragment.js.flow +85 -56
  169. package/relay-hooks/useClientQuery.js.flow +1 -1
  170. package/relay-hooks/useEntryPointLoader.js.flow +10 -6
  171. package/relay-hooks/useFetchTrackingRef.js.flow +5 -4
  172. package/relay-hooks/useFragment.js.flow +2 -2
  173. package/relay-hooks/useFragmentNode.js.flow +5 -4
  174. package/relay-hooks/useIsMountedRef.js.flow +1 -1
  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 +2 -2
  178. package/relay-hooks/useLazyLoadQueryNode.js.flow +2 -2
  179. package/relay-hooks/useLoadMoreFunction.js.flow +14 -9
  180. package/relay-hooks/useMemoOperationDescriptor.js.flow +3 -3
  181. package/relay-hooks/useMemoVariables.js.flow +13 -29
  182. package/relay-hooks/useMutation.js.flow +4 -4
  183. package/relay-hooks/usePaginationFragment.js.flow +53 -46
  184. package/relay-hooks/usePreloadedQuery.js.flow +47 -22
  185. package/relay-hooks/useQueryLoader.js.flow +85 -22
  186. package/relay-hooks/useRefetchableFragment.js.flow +64 -33
  187. package/relay-hooks/useRefetchableFragmentNode.js.flow +10 -4
  188. package/relay-hooks/useRelayEnvironment.js.flow +2 -2
  189. package/relay-hooks/useStaticFragmentNodeWarning.js.flow +3 -3
  190. package/relay-hooks/useSubscribeToInvalidationState.js.flow +2 -2
  191. package/relay-hooks/useSubscription.js.flow +1 -1
  192. package/relay-hooks/useUnsafeRef_DEPRECATED.js.flow +25 -0
  193. package/lib/readContext.js +0 -27
  194. package/readContext.js.flow +0 -29
@@ -4,85 +4,77 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+relay
8
7
  *
9
8
  * @format
9
+ * @oncall relay
10
10
  */
11
+
11
12
  'use strict';
12
13
 
13
14
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
14
-
15
15
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
16
-
17
16
  var useLoadMoreFunction = require('../useLoadMoreFunction');
18
-
17
+ var useRelayEnvironment = require('../useRelayEnvironment');
19
18
  var useStaticFragmentNodeWarning = require('../useStaticFragmentNodeWarning');
20
-
21
19
  var useRefetchableFragmentInternal = require('./useRefetchableFragmentInternal_REACT_CACHE');
22
-
23
20
  var _require = require('react'),
24
- useCallback = _require.useCallback,
25
- useDebugValue = _require.useDebugValue,
26
- useState = _require.useState;
27
-
21
+ useCallback = _require.useCallback,
22
+ useDebugValue = _require.useDebugValue,
23
+ useState = _require.useState;
28
24
  var _require2 = require('relay-runtime'),
29
- getFragment = _require2.getFragment,
30
- getFragmentIdentifier = _require2.getFragmentIdentifier,
31
- getPaginationMetadata = _require2.getPaginationMetadata;
32
-
25
+ getFragment = _require2.getFragment,
26
+ getFragmentIdentifier = _require2.getFragmentIdentifier,
27
+ getPaginationMetadata = _require2.getPaginationMetadata;
33
28
  function usePaginationFragment(fragmentInput, parentFragmentRef) {
34
29
  var fragmentNode = getFragment(fragmentInput);
35
30
  useStaticFragmentNodeWarning(fragmentNode, 'first argument of usePaginationFragment()');
36
31
  var componentDisplayName = 'usePaginationFragment()';
37
-
38
32
  var _getPaginationMetadat = getPaginationMetadata(fragmentNode, componentDisplayName),
39
- connectionPathInFragmentData = _getPaginationMetadat.connectionPathInFragmentData,
40
- paginationRequest = _getPaginationMetadat.paginationRequest,
41
- paginationMetadata = _getPaginationMetadat.paginationMetadata,
42
- identifierField = _getPaginationMetadat.identifierField;
43
-
33
+ connectionPathInFragmentData = _getPaginationMetadat.connectionPathInFragmentData,
34
+ paginationRequest = _getPaginationMetadat.paginationRequest,
35
+ paginationMetadata = _getPaginationMetadat.paginationMetadata,
36
+ identifierField = _getPaginationMetadat.identifierField;
44
37
  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
38
+ fragmentData = _useRefetchableFragme.fragmentData,
39
+ fragmentRef = _useRefetchableFragme.fragmentRef,
40
+ refetch = _useRefetchableFragme.refetch;
41
+ var fragmentIdentifier = getFragmentIdentifier(fragmentNode, fragmentRef);
50
42
 
43
+ // Backward pagination
51
44
  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
-
45
+ componentDisplayName: componentDisplayName,
46
+ connectionPathInFragmentData: connectionPathInFragmentData,
47
+ direction: 'backward',
48
+ fragmentData: fragmentData,
49
+ fragmentIdentifier: fragmentIdentifier,
50
+ fragmentNode: fragmentNode,
51
+ fragmentRef: fragmentRef,
52
+ identifierField: identifierField,
53
+ paginationMetadata: paginationMetadata,
54
+ paginationRequest: paginationRequest
55
+ }),
56
+ loadPrevious = _useLoadMore[0],
57
+ hasPrevious = _useLoadMore[1],
58
+ isLoadingPrevious = _useLoadMore[2],
59
+ disposeFetchPrevious = _useLoadMore[3];
60
+
61
+ // Forward pagination
69
62
  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
-
63
+ componentDisplayName: componentDisplayName,
64
+ connectionPathInFragmentData: connectionPathInFragmentData,
65
+ direction: 'forward',
66
+ fragmentData: fragmentData,
67
+ fragmentIdentifier: fragmentIdentifier,
68
+ fragmentNode: fragmentNode,
69
+ fragmentRef: fragmentRef,
70
+ identifierField: identifierField,
71
+ paginationMetadata: paginationMetadata,
72
+ paginationRequest: paginationRequest
73
+ }),
74
+ loadNext = _useLoadMore2[0],
75
+ hasNext = _useLoadMore2[1],
76
+ isLoadingNext = _useLoadMore2[2],
77
+ disposeFetchNext = _useLoadMore2[3];
86
78
  var refetchPagination = useCallback(function (variables, options) {
87
79
  disposeFetchNext();
88
80
  disposeFetchPrevious();
@@ -90,7 +82,6 @@ function usePaginationFragment(fragmentInput, parentFragmentRef) {
90
82
  __environment: undefined
91
83
  }));
92
84
  }, [disposeFetchNext, disposeFetchPrevious, refetch]);
93
-
94
85
  if (process.env.NODE_ENV !== "production") {
95
86
  // eslint-disable-next-line react-hooks/rules-of-hooks
96
87
  useDebugValue({
@@ -102,7 +93,6 @@ function usePaginationFragment(fragmentInput, parentFragmentRef) {
102
93
  isLoadingPrevious: isLoadingPrevious
103
94
  });
104
95
  }
105
-
106
96
  return {
107
97
  data: fragmentData,
108
98
  loadNext: loadNext,
@@ -114,12 +104,25 @@ function usePaginationFragment(fragmentInput, parentFragmentRef) {
114
104
  refetch: refetchPagination
115
105
  };
116
106
  }
117
-
118
107
  function useLoadMore(args) {
108
+ var environment = useRelayEnvironment();
119
109
  var _useState = useState(false),
120
- isLoadingMore = _useState[0],
121
- setIsLoadingMore = _useState[1];
122
-
110
+ isLoadingMore = _useState[0],
111
+ reallySetIsLoadingMore = _useState[1];
112
+ // Schedule this update since it must be observed by components at the same
113
+ // batch as when hasNext changes. hasNext is read from the store and store
114
+ // updates are scheduled, so this must be scheduled too.
115
+ var setIsLoadingMore = function setIsLoadingMore(value) {
116
+ var _environment$getSched;
117
+ var schedule = (_environment$getSched = environment.getScheduler()) === null || _environment$getSched === void 0 ? void 0 : _environment$getSched.schedule;
118
+ if (schedule) {
119
+ schedule(function () {
120
+ reallySetIsLoadingMore(value);
121
+ });
122
+ } else {
123
+ reallySetIsLoadingMore(value);
124
+ }
125
+ };
123
126
  var observer = {
124
127
  start: function start() {
125
128
  return setIsLoadingMore(true);
@@ -131,20 +134,16 @@ function useLoadMore(args) {
131
134
  return setIsLoadingMore(false);
132
135
  }
133
136
  };
134
-
135
137
  var handleReset = function handleReset() {
136
138
  return setIsLoadingMore(false);
137
139
  };
138
-
139
140
  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
-
141
+ observer: observer,
142
+ onReset: handleReset
143
+ })),
144
+ loadMore = _useLoadMoreFunction[0],
145
+ hasMore = _useLoadMoreFunction[1],
146
+ disposeFetch = _useLoadMoreFunction[2];
147
147
  return [loadMore, hasMore, isLoadingMore, disposeFetch];
148
148
  }
149
-
150
149
  module.exports = usePaginationFragment;
@@ -5,46 +5,37 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  *
8
- * @emails oncall+relay
9
8
  * @format
9
+ * @oncall relay
10
10
  */
11
+
11
12
  'use strict';
12
13
 
13
14
  var _require = require('../loadQuery'),
14
- useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
15
-
15
+ useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
16
16
  var useMemoOperationDescriptor = require('../useMemoOperationDescriptor');
17
-
18
17
  var useRelayEnvironment = require('../useRelayEnvironment');
19
-
20
18
  var getQueryResultOrFetchQuery = require('./getQueryResultOrFetchQuery_REACT_CACHE');
21
-
22
19
  var useFragmentInternal = require('./useFragmentInternal_REACT_CACHE');
23
-
24
20
  var invariant = require('invariant');
25
-
26
21
  var _require2 = require('react'),
27
- useDebugValue = _require2.useDebugValue,
28
- useEffect = _require2.useEffect;
29
-
22
+ useDebugValue = _require2.useDebugValue,
23
+ useEffect = _require2.useEffect;
30
24
  var _require3 = require('relay-runtime'),
31
- _require3$__internal = _require3.__internal,
32
- fetchQueryDeduped = _require3$__internal.fetchQueryDeduped,
33
- fetchQuery = _require3$__internal.fetchQuery;
34
-
25
+ _require3$__internal = _require3.__internal,
26
+ fetchQueryDeduped = _require3$__internal.fetchQueryDeduped,
27
+ fetchQuery = _require3$__internal.fetchQuery;
35
28
  var warning = require("fbjs/lib/warning");
36
-
37
29
  function usePreloadedQuery_REACT_CACHE(gqlQuery, preloadedQuery, options) {
38
30
  var environment = useRelayEnvironment();
39
31
  useTrackLoadQueryInRender();
40
32
  var fetchKey = preloadedQuery.fetchKey,
41
- fetchPolicy = preloadedQuery.fetchPolicy,
42
- source = preloadedQuery.source,
43
- variables = preloadedQuery.variables,
44
- networkCacheConfig = preloadedQuery.networkCacheConfig;
33
+ fetchPolicy = preloadedQuery.fetchPolicy,
34
+ source = preloadedQuery.source,
35
+ variables = preloadedQuery.variables,
36
+ networkCacheConfig = preloadedQuery.networkCacheConfig;
45
37
  var operation = useMemoOperationDescriptor(gqlQuery, variables, networkCacheConfig);
46
38
  var fetchObservable;
47
-
48
39
  if (preloadedQuery.kind === 'PreloadedQuery_DEPRECATED') {
49
40
  !(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
41
  fetchObservable = fetchQueryDeduped(environment, operation.request.identifier, function () {
@@ -62,7 +53,6 @@ function usePreloadedQuery_REACT_CACHE(gqlQuery, preloadedQuery, options) {
62
53
  } else {
63
54
  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
55
  var fallbackFetchObservable = fetchQuery(environment, operation);
65
-
66
56
  if (source != null && environment === preloadedQuery.environment) {
67
57
  // If the source observable exists and the environments match, reuse
68
58
  // the source observable.
@@ -84,28 +74,26 @@ function usePreloadedQuery_REACT_CACHE(gqlQuery, preloadedQuery, options) {
84
74
  // fall back and re-execute and de-dupe the query (at render time).
85
75
  fetchObservable = fallbackFetchObservable;
86
76
  }
87
- } // Get the query going if needed -- this may suspend.
88
-
77
+ }
89
78
 
79
+ // Get the query going if needed -- this may suspend.
90
80
  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.
81
+ fetchPolicy: fetchPolicy,
82
+ renderPolicy: options === null || options === void 0 ? void 0 : options.UNSTABLE_renderPolicy,
83
+ fetchKey: fetchKey,
84
+ fetchObservable: fetchObservable
85
+ }),
86
+ queryResult = _getQueryResultOrFetc[0],
87
+ effect = _getQueryResultOrFetc[1];
88
+ useEffect(effect);
100
89
 
90
+ // Read the query's root fragment -- this may suspend.
101
91
  var fragmentNode = queryResult.fragmentNode,
102
- fragmentRef = queryResult.fragmentRef; // $FlowExpectedError[incompatible-return] Is this a fixable incompatible-return?
103
-
92
+ fragmentRef = queryResult.fragmentRef;
104
93
  var data = useFragmentInternal(fragmentNode, fragmentRef, 'usePreloadedQuery()', {
105
94
  fetchPolicy: fetchPolicy,
106
95
  networkCacheConfig: networkCacheConfig
107
96
  });
108
-
109
97
  if (process.env.NODE_ENV !== "production") {
110
98
  // eslint-disable-next-line react-hooks/rules-of-hooks
111
99
  useDebugValue({
@@ -117,8 +105,6 @@ function usePreloadedQuery_REACT_CACHE(gqlQuery, preloadedQuery, options) {
117
105
  renderPolicy: options === null || options === void 0 ? void 0 : options.UNSTABLE_renderPolicy
118
106
  });
119
107
  }
120
-
121
108
  return data;
122
109
  }
123
-
124
110
  module.exports = usePreloadedQuery_REACT_CACHE;