react-relay 14.0.0 → 15.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ReactRelayContainerUtils.js.flow +1 -2
- package/ReactRelayContext.js +1 -1
- package/ReactRelayContext.js.flow +1 -2
- package/ReactRelayFragmentContainer.js.flow +6 -4
- package/ReactRelayFragmentMockRenderer.js.flow +1 -2
- package/ReactRelayLocalQueryRenderer.js.flow +5 -5
- package/ReactRelayPaginationContainer.js.flow +21 -14
- package/ReactRelayQueryFetcher.js.flow +28 -16
- package/ReactRelayQueryRenderer.js.flow +42 -13
- package/ReactRelayQueryRendererContext.js.flow +2 -3
- package/ReactRelayRefetchContainer.js.flow +9 -9
- package/ReactRelayTestMocker.js.flow +3 -3
- package/ReactRelayTypes.js.flow +7 -8
- package/RelayContext.js.flow +1 -2
- package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +4 -5
- package/__flowtests__/ReactRelayPaginationContainer-flowtest.js.flow +4 -5
- package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +4 -5
- package/__flowtests__/RelayModern-flowtest.js.flow +3 -4
- package/__flowtests__/RelayModernFlowtest_badref.graphql.js.flow +3 -4
- package/__flowtests__/RelayModernFlowtest_notref.graphql.js.flow +3 -4
- package/__flowtests__/RelayModernFlowtest_user.graphql.js.flow +3 -4
- package/__flowtests__/RelayModernFlowtest_users.graphql.js.flow +3 -4
- package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer.graphql.js.flow +3 -1
- package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer2.graphql.js.flow +3 -1
- package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtestQuery.graphql.js.flow +4 -2
- package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtest_viewer.graphql.js.flow +3 -1
- package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtestQuery.graphql.js.flow +4 -2
- package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtest_viewer.graphql.js.flow +3 -1
- package/__flowtests__/__generated__/RelayModernFlowtest_badref.graphql.js.flow +4 -2
- package/__flowtests__/__generated__/RelayModernFlowtest_notref.graphql.js.flow +4 -2
- package/__flowtests__/__generated__/RelayModernFlowtest_user.graphql.js.flow +3 -1
- package/__flowtests__/__generated__/RelayModernFlowtest_users.graphql.js.flow +3 -1
- package/assertFragmentMap.js.flow +1 -2
- package/buildReactRelayContainer.js.flow +7 -7
- package/getRootVariablesForFragments.js.flow +1 -3
- package/hooks.js +1 -1
- package/hooks.js.flow +4 -2
- package/index.js +1 -1
- package/index.js.flow +6 -2
- package/isRelayEnvironment.js.flow +1 -2
- package/jest-react/enqueueTask.js.flow +1 -1
- package/jest-react/index.js.flow +1 -1
- package/jest-react/internalAct.js.flow +1 -1
- package/legacy.js +1 -1
- package/legacy.js.flow +1 -2
- package/lib/ReactRelayContainerUtils.js +2 -3
- package/lib/ReactRelayContext.js +3 -4
- package/lib/ReactRelayFragmentContainer.js +47 -73
- package/lib/ReactRelayFragmentMockRenderer.js +2 -4
- package/lib/ReactRelayLocalQueryRenderer.js +18 -31
- package/lib/ReactRelayPaginationContainer.js +74 -164
- package/lib/ReactRelayQueryFetcher.js +49 -76
- package/lib/ReactRelayQueryRenderer.js +63 -84
- package/lib/ReactRelayQueryRendererContext.js +2 -2
- package/lib/ReactRelayRefetchContainer.js +58 -108
- package/lib/ReactRelayTestMocker.js +33 -68
- package/lib/ReactRelayTypes.js +2 -1
- package/lib/RelayContext.js +4 -7
- package/lib/assertFragmentMap.js +3 -5
- package/lib/buildReactRelayContainer.js +11 -27
- package/lib/getRootVariablesForFragments.js +6 -10
- package/lib/hooks.js +5 -18
- package/lib/index.js +7 -24
- package/lib/isRelayEnvironment.js +5 -4
- package/lib/jest-react/enqueueTask.js +5 -9
- package/lib/jest-react/index.js +0 -1
- package/lib/jest-react/internalAct.js +9 -20
- package/lib/legacy.js +2 -8
- package/lib/multi-actor/ActorChange.js +2 -5
- package/lib/multi-actor/index.js +2 -1
- package/lib/multi-actor/useRelayActorEnvironment.js +4 -8
- package/lib/relay-hooks/EntryPointContainer.react.js +9 -15
- package/lib/relay-hooks/EntryPointTypes.flow.js +5 -3
- package/lib/relay-hooks/FragmentResource.js +109 -203
- package/lib/relay-hooks/HooksImplementation.js +3 -6
- package/lib/relay-hooks/InternalLogger.js +2 -3
- package/lib/relay-hooks/LRUCache.js +2 -20
- package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +33 -54
- package/lib/relay-hooks/MatchContainer.js +15 -24
- package/lib/relay-hooks/ProfilerContext.js +3 -3
- package/lib/relay-hooks/QueryResource.js +31 -101
- package/lib/relay-hooks/RelayEnvironmentProvider.js +5 -9
- package/lib/relay-hooks/SuspenseResource.js +9 -33
- package/lib/relay-hooks/loadEntryPoint.js +19 -31
- package/lib/relay-hooks/loadQuery.js +42 -78
- package/lib/relay-hooks/preloadQuery_DEPRECATED.js +11 -37
- package/lib/relay-hooks/prepareEntryPoint_DEPRECATED.js +9 -15
- package/lib/relay-hooks/react-cache/RelayReactCache.js +7 -12
- package/lib/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js +27 -81
- package/lib/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js +206 -0
- package/lib/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js +195 -215
- package/lib/relay-hooks/react-cache/useFragment_REACT_CACHE.js +5 -15
- package/lib/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js +17 -24
- package/lib/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js +149 -0
- package/lib/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js +24 -39
- package/lib/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js +325 -0
- package/lib/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js +37 -0
- package/lib/relay-hooks/useBlockingPaginationFragment.js +73 -93
- package/lib/relay-hooks/useClientQuery.js +30 -0
- package/lib/relay-hooks/useEntryPointLoader.js +18 -38
- package/lib/relay-hooks/useFetchTrackingRef.js +10 -12
- package/lib/relay-hooks/useFragment.js +8 -19
- package/lib/relay-hooks/useFragmentNode.js +20 -32
- package/lib/relay-hooks/useIsMountedRef.js +4 -6
- package/lib/relay-hooks/useIsOperationNodeActive.js +8 -20
- package/lib/relay-hooks/useIsParentQueryActive.js +3 -6
- package/lib/relay-hooks/useLazyLoadQuery.js +7 -24
- package/lib/relay-hooks/useLazyLoadQueryNode.js +23 -34
- package/lib/relay-hooks/useLoadMoreFunction.js +46 -78
- package/lib/relay-hooks/useMemoOperationDescriptor.js +6 -15
- package/lib/relay-hooks/useMemoVariables.js +15 -34
- package/lib/relay-hooks/useMutation.js +9 -27
- package/lib/relay-hooks/usePaginationFragment.js +73 -76
- package/lib/relay-hooks/usePreloadedQuery.js +13 -44
- package/lib/relay-hooks/useQueryLoader.js +24 -49
- package/lib/relay-hooks/useRefetchableFragment.js +19 -17
- package/lib/relay-hooks/useRefetchableFragmentNode.js +65 -109
- package/lib/relay-hooks/useRelayEnvironment.js +4 -8
- package/lib/relay-hooks/useStaticFragmentNodeWarning.js +4 -8
- package/lib/relay-hooks/useSubscribeToInvalidationState.js +8 -9
- package/lib/relay-hooks/useSubscription.js +5 -10
- package/lib/relay-hooks/useUnsafeRef_DEPRECATED.js +29 -0
- package/multi-actor/ActorChange.js.flow +1 -1
- package/multi-actor/index.js.flow +1 -1
- package/multi-actor/useRelayActorEnvironment.js.flow +2 -4
- package/package.json +2 -2
- package/react-relay-hooks.js +2 -2
- package/react-relay-hooks.min.js +2 -2
- package/react-relay-legacy.js +2 -2
- package/react-relay-legacy.min.js +2 -2
- package/react-relay.js +2 -2
- package/react-relay.min.js +2 -2
- package/relay-hooks/EntryPointContainer.react.js.flow +3 -5
- package/relay-hooks/EntryPointTypes.flow.js.flow +37 -37
- package/relay-hooks/FragmentResource.js.flow +43 -19
- package/relay-hooks/HooksImplementation.js.flow +7 -9
- package/relay-hooks/InternalLogger.js.flow +1 -3
- package/relay-hooks/LRUCache.js.flow +1 -3
- package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +19 -14
- package/relay-hooks/MatchContainer.js.flow +6 -8
- package/relay-hooks/ProfilerContext.js.flow +1 -3
- package/relay-hooks/QueryResource.js.flow +29 -11
- package/relay-hooks/RelayEnvironmentProvider.js.flow +4 -6
- package/relay-hooks/SuspenseResource.js.flow +1 -3
- package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +6 -4
- package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +4 -4
- package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_user.graphql.js.flow +3 -1
- package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_users.graphql.js.flow +3 -1
- package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +39 -39
- package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +1 -3
- package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +37 -38
- package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +18 -20
- package/relay-hooks/__flowtests__/utils.js.flow +21 -12
- package/relay-hooks/loadEntryPoint.js.flow +11 -6
- package/relay-hooks/loadQuery.js.flow +11 -7
- package/relay-hooks/preloadQuery_DEPRECATED.js.flow +9 -12
- package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +13 -10
- package/relay-hooks/react-cache/RelayReactCache.js.flow +1 -3
- package/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js.flow +26 -20
- package/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js.flow +297 -0
- package/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js.flow +136 -96
- package/relay-hooks/react-cache/useFragment_REACT_CACHE.js.flow +1 -3
- package/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js.flow +3 -5
- package/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js.flow +190 -0
- package/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js.flow +3 -6
- package/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js.flow +601 -0
- package/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js.flow +65 -0
- package/relay-hooks/useBlockingPaginationFragment.js.flow +86 -59
- package/relay-hooks/useClientQuery.js.flow +39 -0
- package/relay-hooks/useEntryPointLoader.js.flow +16 -14
- package/relay-hooks/useFetchTrackingRef.js.flow +7 -8
- package/relay-hooks/useFragment.js.flow +2 -4
- package/relay-hooks/useFragmentNode.js.flow +7 -8
- package/relay-hooks/useIsMountedRef.js.flow +2 -4
- package/relay-hooks/useIsOperationNodeActive.js.flow +1 -1
- package/relay-hooks/useIsParentQueryActive.js.flow +1 -1
- package/relay-hooks/useLazyLoadQuery.js.flow +9 -32
- package/relay-hooks/useLazyLoadQueryNode.js.flow +4 -6
- package/relay-hooks/useLoadMoreFunction.js.flow +20 -17
- package/relay-hooks/useMemoOperationDescriptor.js.flow +3 -5
- package/relay-hooks/useMemoVariables.js.flow +13 -31
- package/relay-hooks/useMutation.js.flow +6 -8
- package/relay-hooks/usePaginationFragment.js.flow +75 -43
- package/relay-hooks/usePreloadedQuery.js.flow +49 -43
- package/relay-hooks/useQueryLoader.js.flow +89 -28
- package/relay-hooks/useRefetchableFragment.js.flow +83 -23
- package/relay-hooks/useRefetchableFragmentNode.js.flow +26 -22
- package/relay-hooks/useRelayEnvironment.js.flow +2 -4
- package/relay-hooks/useStaticFragmentNodeWarning.js.flow +3 -5
- package/relay-hooks/useSubscribeToInvalidationState.js.flow +2 -4
- package/relay-hooks/useSubscription.js.flow +1 -3
- package/relay-hooks/useUnsafeRef_DEPRECATED.js.flow +25 -0
- package/lib/readContext.js +0 -28
- package/readContext.js.flow +0 -31
|
@@ -4,89 +4,72 @@
|
|
|
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
|
-
// flowlint ambiguous-object-type:error
|
|
12
|
-
'use strict';
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
'use strict';
|
|
15
13
|
|
|
14
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
16
15
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
17
|
-
|
|
18
16
|
var useFetchTrackingRef = require('./useFetchTrackingRef');
|
|
19
|
-
|
|
20
17
|
var useIsMountedRef = require('./useIsMountedRef');
|
|
21
|
-
|
|
22
18
|
var useIsOperationNodeActive = require('./useIsOperationNodeActive');
|
|
23
|
-
|
|
24
19
|
var useRelayEnvironment = require('./useRelayEnvironment');
|
|
25
|
-
|
|
26
20
|
var invariant = require('invariant');
|
|
27
|
-
|
|
28
21
|
var _require = require('react'),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
useCallback = _require.useCallback,
|
|
23
|
+
useEffect = _require.useEffect,
|
|
24
|
+
useState = _require.useState;
|
|
33
25
|
var _require2 = require('relay-runtime'),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
fetchQuery = _require2.__internal.fetchQuery,
|
|
27
|
+
ConnectionInterface = _require2.ConnectionInterface,
|
|
28
|
+
createOperationDescriptor = _require2.createOperationDescriptor,
|
|
29
|
+
getPaginationVariables = _require2.getPaginationVariables,
|
|
30
|
+
getSelector = _require2.getSelector,
|
|
31
|
+
getValueAtPath = _require2.getValueAtPath;
|
|
41
32
|
var warning = require("fbjs/lib/warning");
|
|
42
|
-
|
|
43
33
|
function useLoadMoreFunction(args) {
|
|
44
34
|
var direction = args.direction,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
35
|
+
fragmentNode = args.fragmentNode,
|
|
36
|
+
fragmentRef = args.fragmentRef,
|
|
37
|
+
fragmentIdentifier = args.fragmentIdentifier,
|
|
38
|
+
fragmentData = args.fragmentData,
|
|
39
|
+
connectionPathInFragmentData = args.connectionPathInFragmentData,
|
|
40
|
+
paginationRequest = args.paginationRequest,
|
|
41
|
+
paginationMetadata = args.paginationMetadata,
|
|
42
|
+
componentDisplayName = args.componentDisplayName,
|
|
43
|
+
observer = args.observer,
|
|
44
|
+
onReset = args.onReset,
|
|
45
|
+
identifierField = args.identifierField;
|
|
56
46
|
var environment = useRelayEnvironment();
|
|
57
|
-
|
|
58
47
|
var _useFetchTrackingRef = useFetchTrackingRef(),
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
48
|
+
isFetchingRef = _useFetchTrackingRef.isFetchingRef,
|
|
49
|
+
startFetch = _useFetchTrackingRef.startFetch,
|
|
50
|
+
disposeFetch = _useFetchTrackingRef.disposeFetch,
|
|
51
|
+
completeFetch = _useFetchTrackingRef.completeFetch;
|
|
64
52
|
var identifierValue = identifierField != null && fragmentData != null && typeof fragmentData === 'object' ? fragmentData[identifierField] : null;
|
|
65
53
|
var isMountedRef = useIsMountedRef();
|
|
66
|
-
|
|
67
54
|
var _useState = useState(environment),
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
55
|
+
mirroredEnvironment = _useState[0],
|
|
56
|
+
setMirroredEnvironment = _useState[1];
|
|
71
57
|
var _useState2 = useState(fragmentIdentifier),
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
58
|
+
mirroredFragmentIdentifier = _useState2[0],
|
|
59
|
+
setMirroredFragmentIdentifier = _useState2[1];
|
|
75
60
|
var isParentQueryActive = useIsOperationNodeActive(fragmentNode, fragmentRef);
|
|
76
61
|
var shouldReset = environment !== mirroredEnvironment || fragmentIdentifier !== mirroredFragmentIdentifier;
|
|
77
|
-
|
|
78
62
|
if (shouldReset) {
|
|
79
63
|
disposeFetch();
|
|
80
64
|
onReset();
|
|
81
65
|
setMirroredEnvironment(environment);
|
|
82
66
|
setMirroredFragmentIdentifier(fragmentIdentifier);
|
|
83
67
|
}
|
|
84
|
-
|
|
85
68
|
var _getConnectionState = getConnectionState(direction, fragmentNode, fragmentData, connectionPathInFragmentData),
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
69
|
+
cursor = _getConnectionState.cursor,
|
|
70
|
+
hasMore = _getConnectionState.hasMore;
|
|
89
71
|
|
|
72
|
+
// Dispose of pagination requests in flight when unmounting
|
|
90
73
|
useEffect(function () {
|
|
91
74
|
return function () {
|
|
92
75
|
disposeFetch();
|
|
@@ -94,8 +77,8 @@ function useLoadMoreFunction(args) {
|
|
|
94
77
|
}, [disposeFetch]);
|
|
95
78
|
var loadMore = useCallback(function (count, options) {
|
|
96
79
|
// TODO(T41131846): Fetch/Caching policies for loadMore
|
|
97
|
-
var onComplete = options === null || options === void 0 ? void 0 : options.onComplete;
|
|
98
80
|
|
|
81
|
+
var onComplete = options === null || options === void 0 ? void 0 : options.onComplete;
|
|
99
82
|
if (isMountedRef.current !== true) {
|
|
100
83
|
// Bail out and warn if we're trying to paginate after the component
|
|
101
84
|
// has unmounted
|
|
@@ -104,31 +87,27 @@ function useLoadMoreFunction(args) {
|
|
|
104
87
|
dispose: function dispose() {}
|
|
105
88
|
};
|
|
106
89
|
}
|
|
107
|
-
|
|
108
90
|
var fragmentSelector = getSelector(fragmentNode, fragmentRef);
|
|
109
|
-
|
|
110
91
|
if (isFetchingRef.current === true || fragmentData == null || isParentQueryActive) {
|
|
111
92
|
if (fragmentSelector == null) {
|
|
112
93
|
process.env.NODE_ENV !== "production" ? warning(false, 'Relay: Unexpected fetch while using a null fragment ref ' + 'for fragment `%s` in `%s`. When fetching more items, we expect ' + "initial fragment data to be non-null. Please make sure you're " + 'passing a valid fragment ref to `%s` before paginating.', fragmentNode.name, componentDisplayName, componentDisplayName) : void 0;
|
|
113
94
|
}
|
|
114
|
-
|
|
115
95
|
if (onComplete) {
|
|
116
96
|
onComplete(null);
|
|
117
97
|
}
|
|
118
|
-
|
|
119
98
|
return {
|
|
120
99
|
dispose: function dispose() {}
|
|
121
100
|
};
|
|
122
101
|
}
|
|
123
|
-
|
|
124
102
|
!(fragmentSelector != null && fragmentSelector.kind !== 'PluralReaderSelector') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected to be able to find a non-plural fragment owner for ' + "fragment `%s` when using `%s`. If you're seeing this, " + 'this is likely a bug in Relay.', fragmentNode.name, componentDisplayName) : invariant(false) : void 0;
|
|
125
103
|
var parentVariables = fragmentSelector.owner.variables;
|
|
126
104
|
var fragmentVariables = fragmentSelector.variables;
|
|
127
105
|
var extraVariables = options === null || options === void 0 ? void 0 : options.UNSTABLE_extraVariables;
|
|
128
106
|
var baseVariables = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, parentVariables), fragmentVariables);
|
|
129
|
-
var paginationVariables = getPaginationVariables(direction, count, cursor, baseVariables, (0, _objectSpread2["default"])({}, extraVariables), paginationMetadata);
|
|
130
|
-
// was not explicitly provided, read it from the fragment data.
|
|
107
|
+
var paginationVariables = getPaginationVariables(direction, count, cursor, baseVariables, (0, _objectSpread2["default"])({}, extraVariables), paginationMetadata);
|
|
131
108
|
|
|
109
|
+
// If the query needs an identifier value ('id' or similar) and one
|
|
110
|
+
// was not explicitly provided, read it from the fragment data.
|
|
132
111
|
if (identifierField != null) {
|
|
133
112
|
// @refetchable fragments are guaranteed to have an `id` selection
|
|
134
113
|
// if the type is Node, implements Node, or is @fetchable. Double-check
|
|
@@ -136,10 +115,8 @@ function useLoadMoreFunction(args) {
|
|
|
136
115
|
if (typeof identifierValue !== 'string') {
|
|
137
116
|
process.env.NODE_ENV !== "production" ? warning(false, 'Relay: Expected result to have a string ' + '`%s` in order to refetch, got `%s`.', identifierField, identifierValue) : void 0;
|
|
138
117
|
}
|
|
139
|
-
|
|
140
118
|
paginationVariables.id = identifierValue;
|
|
141
119
|
}
|
|
142
|
-
|
|
143
120
|
var paginationQuery = createOperationDescriptor(paginationRequest, paginationVariables, {
|
|
144
121
|
force: true
|
|
145
122
|
});
|
|
@@ -162,60 +139,51 @@ function useLoadMoreFunction(args) {
|
|
|
162
139
|
return {
|
|
163
140
|
dispose: disposeFetch
|
|
164
141
|
};
|
|
165
|
-
},
|
|
142
|
+
},
|
|
143
|
+
// NOTE: We disable react-hooks-deps warning because all values
|
|
166
144
|
// inside paginationMetadata are static
|
|
167
145
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
168
146
|
[environment, identifierValue, direction, cursor, startFetch, disposeFetch, completeFetch, isFetchingRef, isParentQueryActive, fragmentData, fragmentNode.name, fragmentRef, componentDisplayName]);
|
|
169
147
|
return [loadMore, hasMore, disposeFetch];
|
|
170
148
|
}
|
|
171
|
-
|
|
172
149
|
function getConnectionState(direction, fragmentNode, fragmentData, connectionPathInFragmentData) {
|
|
173
150
|
var _pageInfo$END_CURSOR, _pageInfo$START_CURSO;
|
|
174
|
-
|
|
175
151
|
var _ConnectionInterface$ = ConnectionInterface.get(),
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
152
|
+
EDGES = _ConnectionInterface$.EDGES,
|
|
153
|
+
PAGE_INFO = _ConnectionInterface$.PAGE_INFO,
|
|
154
|
+
HAS_NEXT_PAGE = _ConnectionInterface$.HAS_NEXT_PAGE,
|
|
155
|
+
HAS_PREV_PAGE = _ConnectionInterface$.HAS_PREV_PAGE,
|
|
156
|
+
END_CURSOR = _ConnectionInterface$.END_CURSOR,
|
|
157
|
+
START_CURSOR = _ConnectionInterface$.START_CURSOR;
|
|
183
158
|
var connection = getValueAtPath(fragmentData, connectionPathInFragmentData);
|
|
184
|
-
|
|
185
159
|
if (connection == null) {
|
|
186
160
|
return {
|
|
187
161
|
cursor: null,
|
|
188
162
|
hasMore: false
|
|
189
163
|
};
|
|
190
164
|
}
|
|
191
|
-
|
|
192
165
|
!(typeof connection === 'object') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected connection in fragment `%s` to have been `null`, or ' + 'a plain object with %s and %s properties. Instead got `%s`.', fragmentNode.name, EDGES, PAGE_INFO, connection) : invariant(false) : void 0;
|
|
193
166
|
var edges = connection[EDGES];
|
|
194
167
|
var pageInfo = connection[PAGE_INFO];
|
|
195
|
-
|
|
196
168
|
if (edges == null || pageInfo == null) {
|
|
197
169
|
return {
|
|
198
170
|
cursor: null,
|
|
199
171
|
hasMore: false
|
|
200
172
|
};
|
|
201
173
|
}
|
|
202
|
-
|
|
203
174
|
!Array.isArray(edges) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected connection in fragment `%s` to have a plural `%s` field. ' + 'Instead got `%s`.', fragmentNode.name, EDGES, edges) : invariant(false) : void 0;
|
|
204
175
|
!(typeof pageInfo === 'object') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected connection in fragment `%s` to have a `%s` field. ' + 'Instead got `%s`.', fragmentNode.name, PAGE_INFO, pageInfo) : invariant(false) : void 0;
|
|
205
176
|
var cursor = direction === 'forward' ? (_pageInfo$END_CURSOR = pageInfo[END_CURSOR]) !== null && _pageInfo$END_CURSOR !== void 0 ? _pageInfo$END_CURSOR : null : (_pageInfo$START_CURSO = pageInfo[START_CURSOR]) !== null && _pageInfo$START_CURSO !== void 0 ? _pageInfo$START_CURSO : null;
|
|
206
177
|
!(cursor === null || typeof cursor === 'string') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected page info for connection in fragment `%s` to have a ' + 'valid `%s`. Instead got `%s`.', fragmentNode.name, START_CURSOR, cursor) : invariant(false) : void 0;
|
|
207
178
|
var hasMore;
|
|
208
|
-
|
|
209
179
|
if (direction === 'forward') {
|
|
210
180
|
hasMore = cursor != null && pageInfo[HAS_NEXT_PAGE] === true;
|
|
211
181
|
} else {
|
|
212
182
|
hasMore = cursor != null && pageInfo[HAS_PREV_PAGE] === true;
|
|
213
183
|
}
|
|
214
|
-
|
|
215
184
|
return {
|
|
216
185
|
cursor: cursor,
|
|
217
186
|
hasMore: hasMore
|
|
218
187
|
};
|
|
219
188
|
}
|
|
220
|
-
|
|
221
189
|
module.exports = useLoadMoreFunction;
|
|
@@ -4,33 +4,24 @@
|
|
|
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
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
var useMemoVariables = require('./useMemoVariables');
|
|
15
|
-
|
|
16
15
|
var React = require('react');
|
|
17
|
-
|
|
18
16
|
var _require = require('relay-runtime'),
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
createOperationDescriptor = _require.createOperationDescriptor,
|
|
18
|
+
getRequest = _require.getRequest;
|
|
22
19
|
var useMemo = React.useMemo;
|
|
23
|
-
|
|
24
20
|
function useMemoOperationDescriptor(gqlQuery, variables, cacheConfig) {
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var _useMemoVariables2 = useMemoVariables(cacheConfig || {}),
|
|
29
|
-
memoCacheConfig = _useMemoVariables2[0];
|
|
30
|
-
|
|
21
|
+
var memoVariables = useMemoVariables(variables);
|
|
22
|
+
var memoCacheConfig = useMemoVariables(cacheConfig || {});
|
|
31
23
|
return useMemo(function () {
|
|
32
24
|
return createOperationDescriptor(getRequest(gqlQuery), memoVariables, memoCacheConfig);
|
|
33
25
|
}, [gqlQuery, memoVariables, memoCacheConfig]);
|
|
34
26
|
}
|
|
35
|
-
|
|
36
27
|
module.exports = useMemoOperationDescriptor;
|
|
@@ -4,50 +4,31 @@
|
|
|
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
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
var areEqual = require("fbjs/lib/areEqual");
|
|
15
|
+
var _require = require('react'),
|
|
16
|
+
useState = _require.useState;
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Memoizes the passed in `variables` object based on `areEqual` equality.
|
|
20
|
+
* This is useful when a `variables` object is used as a value in a depencency
|
|
21
|
+
* array as it might often be constructed during render.
|
|
22
|
+
*/
|
|
22
23
|
function useMemoVariables(variables) {
|
|
23
|
-
var _variablesChangedGene2;
|
|
24
|
-
|
|
25
|
-
// The value of this ref is a counter that should be incremented when
|
|
26
|
-
// variables change. This allows us to use the counter as a
|
|
27
|
-
// memoization value to indicate if the computation for useMemo
|
|
28
|
-
// should be re-executed.
|
|
29
|
-
var variablesChangedGenerationRef = useRef(0); // We mirror the variables to check if they have changed between renders
|
|
30
|
-
|
|
31
24
|
var _useState = useState(variables),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (variablesChanged) {
|
|
38
|
-
var _variablesChangedGene;
|
|
39
|
-
|
|
40
|
-
variablesChangedGenerationRef.current = ((_variablesChangedGene = variablesChangedGenerationRef.current) !== null && _variablesChangedGene !== void 0 ? _variablesChangedGene : 0) + 1;
|
|
25
|
+
mirroredVariables = _useState[0],
|
|
26
|
+
setMirroredVariables = _useState[1];
|
|
27
|
+
if (areEqual(variables, mirroredVariables)) {
|
|
28
|
+
return mirroredVariables;
|
|
29
|
+
} else {
|
|
41
30
|
setMirroredVariables(variables);
|
|
42
|
-
} // NOTE: We disable react-hooks-deps warning because we explicitly
|
|
43
|
-
// don't want to memoize on object identity
|
|
44
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var memoVariables = useMemo(function () {
|
|
48
31
|
return variables;
|
|
49
|
-
}
|
|
50
|
-
return [memoVariables, (_variablesChangedGene2 = variablesChangedGenerationRef.current) !== null && _variablesChangedGene2 !== void 0 ? _variablesChangedGene2 : 0];
|
|
32
|
+
}
|
|
51
33
|
}
|
|
52
|
-
|
|
53
34
|
module.exports = useMemoVariables;
|
|
@@ -4,31 +4,24 @@
|
|
|
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
|
-
// flowlint ambiguous-object-type:error
|
|
12
|
-
'use strict';
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
'use strict';
|
|
15
13
|
|
|
14
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
16
15
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
17
|
-
|
|
18
16
|
var useIsMountedRef = require('./useIsMountedRef');
|
|
19
|
-
|
|
20
17
|
var useRelayEnvironment = require('./useRelayEnvironment');
|
|
21
|
-
|
|
22
18
|
var React = require('react');
|
|
23
|
-
|
|
24
19
|
var _require = require('relay-runtime'),
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
defaultCommitMutation = _require.commitMutation;
|
|
27
21
|
var useState = React.useState,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
useEffect = React.useEffect,
|
|
23
|
+
useRef = React.useRef,
|
|
24
|
+
useCallback = React.useCallback;
|
|
32
25
|
function useMutation(mutation) {
|
|
33
26
|
var commitMutationFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultCommitMutation;
|
|
34
27
|
var environment = useRelayEnvironment();
|
|
@@ -36,15 +29,12 @@ function useMutation(mutation) {
|
|
|
36
29
|
var environmentRef = useRef(environment);
|
|
37
30
|
var mutationRef = useRef(mutation);
|
|
38
31
|
var inFlightMutationsRef = useRef(new Set());
|
|
39
|
-
|
|
40
32
|
var _useState = useState(false),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
isMutationInFlight = _useState[0],
|
|
34
|
+
setMutationInFlight = _useState[1];
|
|
44
35
|
var cleanup = useCallback(function (disposable) {
|
|
45
36
|
if (environmentRef.current === environment && mutationRef.current === mutation) {
|
|
46
37
|
inFlightMutationsRef.current["delete"](disposable);
|
|
47
|
-
|
|
48
38
|
if (isMountedRef.current) {
|
|
49
39
|
setMutationInFlight(inFlightMutationsRef.current.size > 0);
|
|
50
40
|
}
|
|
@@ -53,11 +43,9 @@ function useMutation(mutation) {
|
|
|
53
43
|
useEffect(function () {
|
|
54
44
|
if (environmentRef.current !== environment || mutationRef.current !== mutation) {
|
|
55
45
|
inFlightMutationsRef.current = new Set();
|
|
56
|
-
|
|
57
46
|
if (isMountedRef.current) {
|
|
58
47
|
setMutationInFlight(false);
|
|
59
48
|
}
|
|
60
|
-
|
|
61
49
|
environmentRef.current = environment;
|
|
62
50
|
mutationRef.current = mutation;
|
|
63
51
|
}
|
|
@@ -66,30 +54,25 @@ function useMutation(mutation) {
|
|
|
66
54
|
if (isMountedRef.current) {
|
|
67
55
|
setMutationInFlight(true);
|
|
68
56
|
}
|
|
69
|
-
|
|
70
57
|
var disposable = commitMutationFn(environment, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, config), {}, {
|
|
71
58
|
mutation: mutation,
|
|
72
59
|
onCompleted: function onCompleted(response, errors) {
|
|
73
60
|
var _config$onCompleted;
|
|
74
|
-
|
|
75
61
|
cleanup(disposable);
|
|
76
62
|
(_config$onCompleted = config.onCompleted) === null || _config$onCompleted === void 0 ? void 0 : _config$onCompleted.call(config, response, errors);
|
|
77
63
|
},
|
|
78
64
|
onError: function onError(error) {
|
|
79
65
|
var _config$onError;
|
|
80
|
-
|
|
81
66
|
cleanup(disposable);
|
|
82
67
|
(_config$onError = config.onError) === null || _config$onError === void 0 ? void 0 : _config$onError.call(config, error);
|
|
83
68
|
},
|
|
84
69
|
onUnsubscribe: function onUnsubscribe() {
|
|
85
70
|
var _config$onUnsubscribe;
|
|
86
|
-
|
|
87
71
|
cleanup(disposable);
|
|
88
72
|
(_config$onUnsubscribe = config.onUnsubscribe) === null || _config$onUnsubscribe === void 0 ? void 0 : _config$onUnsubscribe.call(config);
|
|
89
73
|
},
|
|
90
74
|
onNext: function onNext() {
|
|
91
75
|
var _config$onNext;
|
|
92
|
-
|
|
93
76
|
(_config$onNext = config.onNext) === null || _config$onNext === void 0 ? void 0 : _config$onNext.call(config);
|
|
94
77
|
}
|
|
95
78
|
}));
|
|
@@ -98,5 +81,4 @@ function useMutation(mutation) {
|
|
|
98
81
|
}, [cleanup, commitMutationFn, environment, isMountedRef, mutation]);
|
|
99
82
|
return [commit, isMutationInFlight];
|
|
100
83
|
}
|
|
101
|
-
|
|
102
84
|
module.exports = useMutation;
|
|
@@ -4,86 +4,82 @@
|
|
|
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
|
-
// flowlint ambiguous-object-type:error
|
|
12
|
-
'use strict';
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
'use strict';
|
|
15
13
|
|
|
14
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
16
15
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
17
|
-
|
|
16
|
+
var HooksImplementation = require('./HooksImplementation');
|
|
18
17
|
var useLoadMoreFunction = require('./useLoadMoreFunction');
|
|
19
|
-
|
|
20
18
|
var useRefetchableFragmentNode = require('./useRefetchableFragmentNode');
|
|
21
|
-
|
|
22
19
|
var useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
|
|
23
|
-
|
|
24
20
|
var _require = require('react'),
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
useCallback = _require.useCallback,
|
|
22
|
+
useDebugValue = _require.useDebugValue,
|
|
23
|
+
useState = _require.useState;
|
|
29
24
|
var _require2 = require('relay-runtime'),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
getFragment = _require2.getFragment,
|
|
26
|
+
getFragmentIdentifier = _require2.getFragmentIdentifier,
|
|
27
|
+
getPaginationMetadata = _require2.getPaginationMetadata;
|
|
33
28
|
|
|
34
|
-
|
|
29
|
+
// This separate type export is only needed as long as we are injecting
|
|
30
|
+
// a separate hooks implementation in ./HooksImplementation -- it can
|
|
31
|
+
// be removed after we stop doing that.
|
|
32
|
+
|
|
33
|
+
function usePaginationFragment_LEGACY(fragmentInput, parentFragmentRef) {
|
|
35
34
|
var fragmentNode = getFragment(fragmentInput);
|
|
36
35
|
useStaticFragmentNodeWarning(fragmentNode, 'first argument of usePaginationFragment()');
|
|
37
36
|
var componentDisplayName = 'usePaginationFragment()';
|
|
38
|
-
|
|
39
37
|
var _getPaginationMetadat = getPaginationMetadata(fragmentNode, componentDisplayName),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
connectionPathInFragmentData = _getPaginationMetadat.connectionPathInFragmentData,
|
|
39
|
+
paginationRequest = _getPaginationMetadat.paginationRequest,
|
|
40
|
+
paginationMetadata = _getPaginationMetadat.paginationMetadata,
|
|
41
|
+
identifierField = _getPaginationMetadat.identifierField;
|
|
45
42
|
var _useRefetchableFragme = useRefetchableFragmentNode(fragmentNode, parentFragmentRef, componentDisplayName),
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var fragmentIdentifier = getFragmentIdentifier(fragmentNode, fragmentRef); // Backward pagination
|
|
43
|
+
fragmentData = _useRefetchableFragme.fragmentData,
|
|
44
|
+
fragmentRef = _useRefetchableFragme.fragmentRef,
|
|
45
|
+
refetch = _useRefetchableFragme.refetch;
|
|
46
|
+
var fragmentIdentifier = getFragmentIdentifier(fragmentNode, fragmentRef);
|
|
51
47
|
|
|
48
|
+
// Backward pagination
|
|
52
49
|
var _useLoadMore = useLoadMore({
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
50
|
+
componentDisplayName: componentDisplayName,
|
|
51
|
+
connectionPathInFragmentData: connectionPathInFragmentData,
|
|
52
|
+
direction: 'backward',
|
|
53
|
+
fragmentData: fragmentData,
|
|
54
|
+
fragmentIdentifier: fragmentIdentifier,
|
|
55
|
+
fragmentNode: fragmentNode,
|
|
56
|
+
fragmentRef: fragmentRef,
|
|
57
|
+
identifierField: identifierField,
|
|
58
|
+
paginationMetadata: paginationMetadata,
|
|
59
|
+
paginationRequest: paginationRequest
|
|
60
|
+
}),
|
|
61
|
+
loadPrevious = _useLoadMore[0],
|
|
62
|
+
hasPrevious = _useLoadMore[1],
|
|
63
|
+
isLoadingPrevious = _useLoadMore[2],
|
|
64
|
+
disposeFetchPrevious = _useLoadMore[3];
|
|
65
|
+
|
|
66
|
+
// Forward pagination
|
|
70
67
|
var _useLoadMore2 = useLoadMore({
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
68
|
+
componentDisplayName: componentDisplayName,
|
|
69
|
+
connectionPathInFragmentData: connectionPathInFragmentData,
|
|
70
|
+
direction: 'forward',
|
|
71
|
+
fragmentData: fragmentData,
|
|
72
|
+
fragmentIdentifier: fragmentIdentifier,
|
|
73
|
+
fragmentNode: fragmentNode,
|
|
74
|
+
fragmentRef: fragmentRef,
|
|
75
|
+
identifierField: identifierField,
|
|
76
|
+
paginationMetadata: paginationMetadata,
|
|
77
|
+
paginationRequest: paginationRequest
|
|
78
|
+
}),
|
|
79
|
+
loadNext = _useLoadMore2[0],
|
|
80
|
+
hasNext = _useLoadMore2[1],
|
|
81
|
+
isLoadingNext = _useLoadMore2[2],
|
|
82
|
+
disposeFetchNext = _useLoadMore2[3];
|
|
87
83
|
var refetchPagination = useCallback(function (variables, options) {
|
|
88
84
|
disposeFetchNext();
|
|
89
85
|
disposeFetchPrevious();
|
|
@@ -91,7 +87,6 @@ function usePaginationFragment(fragmentInput, parentFragmentRef) {
|
|
|
91
87
|
__environment: undefined
|
|
92
88
|
}));
|
|
93
89
|
}, [disposeFetchNext, disposeFetchPrevious, refetch]);
|
|
94
|
-
|
|
95
90
|
if (process.env.NODE_ENV !== "production") {
|
|
96
91
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
97
92
|
useDebugValue({
|
|
@@ -103,7 +98,6 @@ function usePaginationFragment(fragmentInput, parentFragmentRef) {
|
|
|
103
98
|
isLoadingPrevious: isLoadingPrevious
|
|
104
99
|
});
|
|
105
100
|
}
|
|
106
|
-
|
|
107
101
|
return {
|
|
108
102
|
data: fragmentData,
|
|
109
103
|
loadNext: loadNext,
|
|
@@ -115,12 +109,10 @@ function usePaginationFragment(fragmentInput, parentFragmentRef) {
|
|
|
115
109
|
refetch: refetchPagination
|
|
116
110
|
};
|
|
117
111
|
}
|
|
118
|
-
|
|
119
112
|
function useLoadMore(args) {
|
|
120
113
|
var _useState = useState(false),
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
114
|
+
isLoadingMore = _useState[0],
|
|
115
|
+
setIsLoadingMore = _useState[1];
|
|
124
116
|
var observer = {
|
|
125
117
|
start: function start() {
|
|
126
118
|
return setIsLoadingMore(true);
|
|
@@ -132,20 +124,25 @@ function useLoadMore(args) {
|
|
|
132
124
|
return setIsLoadingMore(false);
|
|
133
125
|
}
|
|
134
126
|
};
|
|
135
|
-
|
|
136
127
|
var handleReset = function handleReset() {
|
|
137
128
|
return setIsLoadingMore(false);
|
|
138
129
|
};
|
|
139
|
-
|
|
140
130
|
var _useLoadMoreFunction = useLoadMoreFunction((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, args), {}, {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
131
|
+
observer: observer,
|
|
132
|
+
onReset: handleReset
|
|
133
|
+
})),
|
|
134
|
+
loadMore = _useLoadMoreFunction[0],
|
|
135
|
+
hasMore = _useLoadMoreFunction[1],
|
|
136
|
+
disposeFetch = _useLoadMoreFunction[2];
|
|
148
137
|
return [loadMore, hasMore, isLoadingMore, disposeFetch];
|
|
149
138
|
}
|
|
150
|
-
|
|
139
|
+
function usePaginationFragment(fragmentInput, parentFragmentRef) {
|
|
140
|
+
var impl = HooksImplementation.get();
|
|
141
|
+
if (impl) {
|
|
142
|
+
return impl.usePaginationFragment(fragmentInput, parentFragmentRef);
|
|
143
|
+
} else {
|
|
144
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
145
|
+
return usePaginationFragment_LEGACY(fragmentInput, parentFragmentRef);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
151
148
|
module.exports = usePaginationFragment;
|