react-relay 11.0.0 → 13.0.0-rc.0
Sign up to get free protection for your applications and to get access to all the features.
- package/ReactRelayContext.js +1 -1
- package/ReactRelayContext.js.flow +2 -3
- package/ReactRelayFragmentContainer.js.flow +24 -24
- package/ReactRelayFragmentMockRenderer.js.flow +1 -1
- package/ReactRelayLocalQueryRenderer.js.flow +7 -8
- package/ReactRelayPaginationContainer.js.flow +111 -54
- package/ReactRelayQueryFetcher.js.flow +9 -10
- package/ReactRelayQueryRenderer.js.flow +115 -81
- package/ReactRelayRefetchContainer.js.flow +40 -35
- package/ReactRelayTestMocker.js.flow +16 -12
- package/ReactRelayTypes.js.flow +10 -10
- package/RelayContext.js.flow +3 -3
- package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +1 -2
- package/__flowtests__/ReactRelayPaginationContainer-flowtest.js.flow +12 -7
- package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +10 -6
- package/__flowtests__/RelayModern-flowtest.js.flow +78 -46
- package/__flowtests__/RelayModernFlowtest_badref.graphql.js.flow +5 -4
- package/__flowtests__/RelayModernFlowtest_notref.graphql.js.flow +5 -4
- package/__flowtests__/RelayModernFlowtest_user.graphql.js.flow +4 -3
- package/__flowtests__/RelayModernFlowtest_users.graphql.js.flow +4 -3
- package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer.graphql.js.flow +72 -0
- package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer2.graphql.js.flow +72 -0
- package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtestQuery.graphql.js.flow +227 -0
- package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtest_viewer.graphql.js.flow +164 -0
- package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtestQuery.graphql.js.flow +227 -0
- package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtest_viewer.graphql.js.flow +164 -0
- package/__flowtests__/__generated__/RelayModernFlowtest_badref.graphql.js.flow +66 -0
- package/__flowtests__/__generated__/RelayModernFlowtest_notref.graphql.js.flow +66 -0
- package/__flowtests__/__generated__/RelayModernFlowtest_user.graphql.js.flow +59 -0
- package/__flowtests__/__generated__/RelayModernFlowtest_users.graphql.js.flow +61 -0
- package/assertFragmentMap.js.flow +2 -2
- package/buildReactRelayContainer.js.flow +15 -12
- package/getRootVariablesForFragments.js.flow +2 -3
- package/hooks.js +1 -1
- package/hooks.js.flow +5 -6
- package/index.js +1 -1
- package/index.js.flow +6 -7
- package/jest-react/enqueueTask.js.flow +56 -0
- package/jest-react/index.js.flow +12 -0
- package/jest-react/internalAct.js.flow +139 -0
- package/legacy.js +1 -1
- package/lib/ReactRelayFragmentContainer.js +21 -15
- package/lib/ReactRelayFragmentMockRenderer.js +2 -2
- package/lib/ReactRelayLocalQueryRenderer.js +7 -8
- package/lib/ReactRelayPaginationContainer.js +92 -30
- package/lib/ReactRelayQueryFetcher.js +3 -3
- package/lib/ReactRelayQueryRenderer.js +86 -53
- package/lib/ReactRelayRefetchContainer.js +36 -21
- package/lib/ReactRelayTestMocker.js +7 -6
- package/lib/RelayContext.js +3 -2
- package/lib/assertFragmentMap.js +3 -2
- package/lib/buildReactRelayContainer.js +14 -11
- package/lib/hooks.js +5 -5
- package/lib/index.js +7 -7
- package/lib/jest-react/enqueueTask.js +53 -0
- package/lib/jest-react/index.js +13 -0
- package/lib/jest-react/internalAct.js +116 -0
- package/lib/multi-actor/ActorChange.js +30 -0
- package/lib/multi-actor/index.js +11 -0
- package/lib/multi-actor/useRelayActorEnvironment.js +29 -0
- package/lib/relay-hooks/EntryPointContainer.react.js +3 -3
- package/lib/relay-hooks/FragmentResource.js +351 -94
- package/lib/relay-hooks/LRUCache.js +1 -1
- package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +4 -4
- package/lib/relay-hooks/MatchContainer.js +1 -1
- package/lib/relay-hooks/QueryResource.js +172 -29
- package/lib/relay-hooks/RelayEnvironmentProvider.js +5 -3
- package/lib/relay-hooks/SuspenseResource.js +130 -0
- package/lib/relay-hooks/loadQuery.js +42 -20
- package/lib/relay-hooks/preloadQuery_DEPRECATED.js +24 -15
- package/lib/relay-hooks/useBlockingPaginationFragment.js +4 -5
- package/lib/relay-hooks/useEntryPointLoader.js +2 -2
- package/lib/relay-hooks/useFetchTrackingRef.js +2 -1
- package/lib/relay-hooks/useFragment.js +8 -7
- package/lib/relay-hooks/useFragmentNode.js +4 -4
- package/lib/relay-hooks/useIsOperationNodeActive.js +3 -3
- package/lib/relay-hooks/useLazyLoadQuery.js +3 -3
- package/lib/relay-hooks/useLazyLoadQueryNode.js +10 -4
- package/lib/relay-hooks/useLoadMoreFunction.js +6 -8
- package/lib/relay-hooks/useMemoOperationDescriptor.js +2 -2
- package/lib/relay-hooks/useMemoVariables.js +2 -2
- package/lib/relay-hooks/useMutation.js +17 -6
- package/lib/relay-hooks/usePaginationFragment.js +2 -3
- package/lib/relay-hooks/usePreloadedQuery.js +8 -7
- package/lib/relay-hooks/useQueryLoader.js +30 -10
- package/lib/relay-hooks/useRefetchableFragmentNode.js +12 -14
- package/lib/relay-hooks/useRelayEnvironment.js +3 -3
- package/lib/relay-hooks/useStaticFragmentNodeWarning.js +2 -2
- package/lib/relay-hooks/useSubscribeToInvalidationState.js +2 -1
- package/lib/relay-hooks/useSubscription.js +10 -7
- package/multi-actor/ActorChange.js.flow +58 -0
- package/multi-actor/index.js.flow +14 -0
- package/multi-actor/useRelayActorEnvironment.js.flow +49 -0
- package/package.json +3 -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 +8 -15
- package/relay-hooks/EntryPointTypes.flow.js.flow +24 -25
- package/relay-hooks/FragmentResource.js.flow +376 -95
- package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +32 -46
- package/relay-hooks/MatchContainer.js.flow +3 -2
- package/relay-hooks/QueryResource.js.flow +216 -25
- package/relay-hooks/RelayEnvironmentProvider.js.flow +14 -4
- package/relay-hooks/SuspenseResource.js.flow +115 -0
- package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +4 -3
- package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +1 -1
- package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +10 -9
- package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +8 -7
- package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +10 -9
- package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +10 -9
- package/relay-hooks/__flowtests__/utils.js.flow +8 -12
- package/relay-hooks/loadEntryPoint.js.flow +6 -12
- package/relay-hooks/loadQuery.js.flow +49 -31
- package/relay-hooks/preloadQuery_DEPRECATED.js.flow +30 -21
- package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +6 -12
- package/relay-hooks/useBlockingPaginationFragment.js.flow +13 -11
- package/relay-hooks/useEntryPointLoader.js.flow +7 -10
- package/relay-hooks/useFetchTrackingRef.js.flow +2 -2
- package/relay-hooks/useFragment.js.flow +26 -46
- package/relay-hooks/useFragmentNode.js.flow +5 -7
- package/relay-hooks/useIsOperationNodeActive.js.flow +3 -5
- package/relay-hooks/useIsParentQueryActive.js.flow +3 -4
- package/relay-hooks/useLazyLoadQuery.js.flow +9 -10
- package/relay-hooks/useLazyLoadQueryNode.js.flow +19 -13
- package/relay-hooks/useLoadMoreFunction.js.flow +20 -27
- package/relay-hooks/useMemoOperationDescriptor.js.flow +5 -7
- package/relay-hooks/useMemoVariables.js.flow +6 -6
- package/relay-hooks/useMutation.js.flow +26 -26
- package/relay-hooks/usePaginationFragment.js.flow +38 -44
- package/relay-hooks/usePreloadedQuery.js.flow +18 -14
- package/relay-hooks/useQueryLoader.js.flow +41 -22
- package/relay-hooks/useRefetchableFragment.js.flow +7 -8
- package/relay-hooks/useRefetchableFragmentNode.js.flow +24 -30
- package/relay-hooks/useRelayEnvironment.js.flow +2 -4
- package/relay-hooks/useStaticFragmentNodeWarning.js.flow +2 -3
- package/relay-hooks/useSubscribeToInvalidationState.js.flow +3 -6
- package/relay-hooks/useSubscription.js.flow +20 -10
- package/lib/relay-hooks/getPaginationMetadata.js +0 -41
- package/lib/relay-hooks/getPaginationVariables.js +0 -66
- package/lib/relay-hooks/getRefetchMetadata.js +0 -36
- package/lib/relay-hooks/getValueAtPath.js +0 -51
- package/relay-hooks/getPaginationMetadata.js.flow +0 -74
- package/relay-hooks/getPaginationVariables.js.flow +0 -108
- package/relay-hooks/getRefetchMetadata.js.flow +0 -80
- package/relay-hooks/getValueAtPath.js.flow +0 -46
@@ -15,18 +15,16 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
15
15
|
|
16
16
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
17
17
|
|
18
|
-
var invariant = require("fbjs/lib/invariant");
|
19
|
-
|
20
18
|
var _require = require('relay-runtime'),
|
21
|
-
createOperationDescriptor = _require.createOperationDescriptor,
|
22
|
-
Environment = _require.Environment,
|
23
|
-
getRequest = _require.getRequest,
|
24
|
-
getRequestIdentifier = _require.getRequestIdentifier,
|
25
19
|
Observable = _require.Observable,
|
26
20
|
PreloadableQueryRegistry = _require.PreloadableQueryRegistry,
|
27
|
-
|
21
|
+
RelayFeatureFlags = _require.RelayFeatureFlags,
|
22
|
+
ReplaySubject = _require.ReplaySubject,
|
23
|
+
createOperationDescriptor = _require.createOperationDescriptor,
|
24
|
+
getRequest = _require.getRequest,
|
25
|
+
getRequestIdentifier = _require.getRequestIdentifier; // Expire results by this delay after they resolve.
|
26
|
+
|
28
27
|
|
29
|
-
// Expire results by this delay after they resolve.
|
30
28
|
var DEFAULT_PREFETCH_TIMEOUT = 30 * 1000; // 30 seconds
|
31
29
|
|
32
30
|
var WEAKMAP_SUPPORTED = typeof WeakMap === 'function';
|
@@ -34,8 +32,6 @@ var STORE_OR_NETWORK_DEFAULT = 'store-or-network';
|
|
34
32
|
var pendingQueriesByEnvironment = WEAKMAP_SUPPORTED ? new WeakMap() : new Map();
|
35
33
|
|
36
34
|
function preloadQuery(environment, preloadableRequest, variables, options, environmentProviderOptions) {
|
37
|
-
!(environment instanceof Environment) ? process.env.NODE_ENV !== "production" ? invariant(false, 'preloadQuery(): Expected a RelayModernEnvironment') : invariant(false) : void 0;
|
38
|
-
|
39
35
|
var _pendingQueries = pendingQueriesByEnvironment.get(environment);
|
40
36
|
|
41
37
|
if (_pendingQueries == null) {
|
@@ -63,7 +59,22 @@ function preloadQuery(environment, preloadableRequest, variables, options, envir
|
|
63
59
|
var _subscription;
|
64
60
|
|
65
61
|
(_subscription = subscription) === null || _subscription === void 0 ? void 0 : _subscription.unsubscribe();
|
66
|
-
|
62
|
+
|
63
|
+
if (environment.isServer()) {
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
|
67
|
+
if (RelayFeatureFlags.DELAY_CLEANUP_OF_PENDING_PRELOAD_QUERIES === true) {
|
68
|
+
setTimeout(function () {
|
69
|
+
// Clear the cache entry after the default timeout
|
70
|
+
// null-check for Flow
|
71
|
+
if (queryEntry != null) {
|
72
|
+
cleanup(pendingQueries, queryEntry);
|
73
|
+
}
|
74
|
+
}, DEFAULT_PREFETCH_TIMEOUT);
|
75
|
+
} else {
|
76
|
+
cleanup(pendingQueries, queryEntry);
|
77
|
+
}
|
67
78
|
};
|
68
79
|
}) : null;
|
69
80
|
return {
|
@@ -178,11 +189,9 @@ function preloadQueryDeduped(environment, pendingQueries, preloadableRequest, va
|
|
178
189
|
};
|
179
190
|
} else {
|
180
191
|
nextQueryEntry = prevQueryEntry;
|
181
|
-
}
|
182
|
-
|
183
|
-
|
184
|
-
pendingQueries.set(cacheKey, nextQueryEntry); // $FlowFixMe[incompatible-return]
|
192
|
+
}
|
185
193
|
|
194
|
+
pendingQueries.set(cacheKey, nextQueryEntry);
|
186
195
|
return nextQueryEntry;
|
187
196
|
}
|
188
197
|
|
@@ -17,16 +17,14 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
|
|
17
17
|
|
18
18
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
19
19
|
|
20
|
-
var getPaginationMetadata = require('./getPaginationMetadata');
|
21
|
-
|
22
|
-
var invariant = require("fbjs/lib/invariant");
|
23
|
-
|
24
20
|
var useLoadMoreFunction = require('./useLoadMoreFunction');
|
25
21
|
|
26
22
|
var useRefetchableFragmentNode = require('./useRefetchableFragmentNode');
|
27
23
|
|
28
24
|
var useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
|
29
25
|
|
26
|
+
var invariant = require('invariant');
|
27
|
+
|
30
28
|
var _require = require('react'),
|
31
29
|
useCallback = _require.useCallback,
|
32
30
|
useEffect = _require.useEffect,
|
@@ -35,7 +33,8 @@ var _require = require('react'),
|
|
35
33
|
|
36
34
|
var _require2 = require('relay-runtime'),
|
37
35
|
getFragment = _require2.getFragment,
|
38
|
-
getFragmentIdentifier = _require2.getFragmentIdentifier
|
36
|
+
getFragmentIdentifier = _require2.getFragmentIdentifier,
|
37
|
+
getPaginationMetadata = _require2.getPaginationMetadata;
|
39
38
|
|
40
39
|
function useBlockingPaginationFragment(fragmentInput, parentFragmentRef) {
|
41
40
|
var componentDisplayName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'useBlockingPaginationFragment()';
|
@@ -17,11 +17,11 @@ var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime
|
|
17
17
|
|
18
18
|
var loadEntryPoint = require('./loadEntryPoint');
|
19
19
|
|
20
|
-
var useIsMountedRef = require('./useIsMountedRef');
|
21
|
-
|
22
20
|
var _require = require('./loadQuery'),
|
23
21
|
useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
|
24
22
|
|
23
|
+
var useIsMountedRef = require('./useIsMountedRef');
|
24
|
+
|
25
25
|
var _require2 = require('react'),
|
26
26
|
useCallback = _require2.useCallback,
|
27
27
|
useEffect = _require2.useEffect,
|
@@ -15,7 +15,6 @@ var _require = require('react'),
|
|
15
15
|
useCallback = _require.useCallback,
|
16
16
|
useEffect = _require.useEffect,
|
17
17
|
useRef = _require.useRef;
|
18
|
-
|
19
18
|
/**
|
20
19
|
* This hook returns a mutable React ref that holds the value of whether a
|
21
20
|
* fetch request is in flight. The reason this is a mutable ref instead of
|
@@ -28,6 +27,8 @@ var _require = require('react'),
|
|
28
27
|
* The additional functions returned by this Hook can be used to mutate
|
29
28
|
* the ref.
|
30
29
|
*/
|
30
|
+
|
31
|
+
|
31
32
|
function useFetchTrackingRef() {
|
32
33
|
var subscriptionRef = useRef(null);
|
33
34
|
var isFetchingRef = useRef(false);
|
@@ -11,27 +11,28 @@
|
|
11
11
|
// flowlint ambiguous-object-type:error
|
12
12
|
'use strict';
|
13
13
|
|
14
|
+
var _require = require('./loadQuery'),
|
15
|
+
useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
|
16
|
+
|
14
17
|
var useFragmentNode = require('./useFragmentNode');
|
15
18
|
|
16
19
|
var useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
|
17
20
|
|
18
|
-
var _require = require('./loadQuery'),
|
19
|
-
useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
|
20
|
-
|
21
21
|
var _require2 = require('react'),
|
22
22
|
useDebugValue = _require2.useDebugValue;
|
23
23
|
|
24
24
|
var _require3 = require('relay-runtime'),
|
25
|
-
getFragment = _require3.getFragment;
|
25
|
+
getFragment = _require3.getFragment; // if the key is non-nullable, return non-nullable value
|
26
|
+
|
26
27
|
|
27
|
-
function useFragment(
|
28
|
+
function useFragment(fragment, key) {
|
28
29
|
// We need to use this hook in order to be able to track if
|
29
30
|
// loadQuery was called during render
|
30
31
|
useTrackLoadQueryInRender();
|
31
|
-
var fragmentNode = getFragment(
|
32
|
+
var fragmentNode = getFragment(fragment);
|
32
33
|
useStaticFragmentNodeWarning(fragmentNode, 'first argument of useFragment()');
|
33
34
|
|
34
|
-
var _useFragmentNode = useFragmentNode(fragmentNode,
|
35
|
+
var _useFragmentNode = useFragmentNode(fragmentNode, key, 'useFragment()'),
|
35
36
|
data = _useFragmentNode.data;
|
36
37
|
|
37
38
|
if (process.env.NODE_ENV !== "production") {
|
@@ -11,13 +11,11 @@
|
|
11
11
|
// flowlint ambiguous-object-type:error
|
12
12
|
'use strict';
|
13
13
|
|
14
|
-
var useRelayEnvironment = require('./useRelayEnvironment');
|
15
|
-
|
16
|
-
var warning = require("fbjs/lib/warning");
|
17
|
-
|
18
14
|
var _require = require('./FragmentResource'),
|
19
15
|
getFragmentResourceForEnvironment = _require.getFragmentResourceForEnvironment;
|
20
16
|
|
17
|
+
var useRelayEnvironment = require('./useRelayEnvironment');
|
18
|
+
|
21
19
|
var _require2 = require('react'),
|
22
20
|
useEffect = _require2.useEffect,
|
23
21
|
useRef = _require2.useRef,
|
@@ -26,6 +24,8 @@ var _require2 = require('react'),
|
|
26
24
|
var _require3 = require('relay-runtime'),
|
27
25
|
getFragmentIdentifier = _require3.getFragmentIdentifier;
|
28
26
|
|
27
|
+
var warning = require("fbjs/lib/warning");
|
28
|
+
|
29
29
|
function useFragmentNode(fragmentNode, fragmentRef, componentDisplayName) {
|
30
30
|
var environment = useRelayEnvironment();
|
31
31
|
var FragmentResource = getFragmentResourceForEnvironment(environment);
|
@@ -10,11 +10,11 @@
|
|
10
10
|
*/
|
11
11
|
'use strict';
|
12
12
|
|
13
|
-
var
|
13
|
+
var useRelayEnvironment = require('./useRelayEnvironment');
|
14
14
|
|
15
|
-
var invariant = require(
|
15
|
+
var invariant = require('invariant');
|
16
16
|
|
17
|
-
var
|
17
|
+
var React = require('react');
|
18
18
|
|
19
19
|
var _require = require('relay-runtime'),
|
20
20
|
getObservableForActiveRequest = _require.__internal.getObservableForActiveRequest,
|
@@ -11,15 +11,15 @@
|
|
11
11
|
// flowlint ambiguous-object-type:error
|
12
12
|
'use strict';
|
13
13
|
|
14
|
+
var _require = require('./loadQuery'),
|
15
|
+
useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
|
16
|
+
|
14
17
|
var useLazyLoadQueryNode = require('./useLazyLoadQueryNode');
|
15
18
|
|
16
19
|
var useMemoOperationDescriptor = require('./useMemoOperationDescriptor');
|
17
20
|
|
18
21
|
var useRelayEnvironment = require('./useRelayEnvironment');
|
19
22
|
|
20
|
-
var _require = require('./loadQuery'),
|
21
|
-
useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
|
22
|
-
|
23
23
|
var _require2 = require('relay-runtime'),
|
24
24
|
fetchQuery = _require2.__internal.fetchQuery;
|
25
25
|
|
@@ -13,7 +13,9 @@
|
|
13
13
|
|
14
14
|
var ProfilerContext = require('./ProfilerContext');
|
15
15
|
|
16
|
-
var
|
16
|
+
var _require = require('./QueryResource'),
|
17
|
+
getQueryCacheIdentifier = _require.getQueryCacheIdentifier,
|
18
|
+
getQueryResourceForEnvironment = _require.getQueryResourceForEnvironment;
|
17
19
|
|
18
20
|
var useFetchTrackingRef = require('./useFetchTrackingRef');
|
19
21
|
|
@@ -21,9 +23,7 @@ var useFragmentNode = require('./useFragmentNode');
|
|
21
23
|
|
22
24
|
var useRelayEnvironment = require('./useRelayEnvironment');
|
23
25
|
|
24
|
-
var
|
25
|
-
getQueryResourceForEnvironment = _require.getQueryResourceForEnvironment,
|
26
|
-
getQueryCacheIdentifier = _require.getQueryCacheIdentifier;
|
26
|
+
var React = require('react');
|
27
27
|
|
28
28
|
var useContext = React.useContext,
|
29
29
|
useEffect = React.useEffect,
|
@@ -96,6 +96,12 @@ function useLazyLoadQueryNode(_ref) {
|
|
96
96
|
// the effect should be re-executed and the query re-retained.
|
97
97
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
98
98
|
}, [environment, cacheIdentifier]);
|
99
|
+
useEffect(function () {
|
100
|
+
// Release any temporary retain that's not released. At this point, if the
|
101
|
+
// cacheIdentifier doesn't change, the query is still permanently retained,
|
102
|
+
// and the temporary retain is redundant.
|
103
|
+
QueryResource.releaseTemporaryRetain(preparedQueryResult); // This effect is intended to run on every commit, thus no dependency
|
104
|
+
});
|
99
105
|
var fragmentNode = preparedQueryResult.fragmentNode,
|
100
106
|
fragmentRef = preparedQueryResult.fragmentRef;
|
101
107
|
|
@@ -15,12 +15,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
15
15
|
|
16
16
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
17
17
|
|
18
|
-
var getPaginationVariables = require('./getPaginationVariables');
|
19
|
-
|
20
|
-
var getValueAtPath = require('./getValueAtPath');
|
21
|
-
|
22
|
-
var invariant = require("fbjs/lib/invariant");
|
23
|
-
|
24
18
|
var useFetchTrackingRef = require('./useFetchTrackingRef');
|
25
19
|
|
26
20
|
var useIsMountedRef = require('./useIsMountedRef');
|
@@ -29,7 +23,7 @@ var useIsOperationNodeActive = require('./useIsOperationNodeActive');
|
|
29
23
|
|
30
24
|
var useRelayEnvironment = require('./useRelayEnvironment');
|
31
25
|
|
32
|
-
var
|
26
|
+
var invariant = require('invariant');
|
33
27
|
|
34
28
|
var _require = require('react'),
|
35
29
|
useCallback = _require.useCallback,
|
@@ -40,7 +34,11 @@ var _require2 = require('relay-runtime'),
|
|
40
34
|
ConnectionInterface = _require2.ConnectionInterface,
|
41
35
|
fetchQuery = _require2.__internal.fetchQuery,
|
42
36
|
createOperationDescriptor = _require2.createOperationDescriptor,
|
43
|
-
|
37
|
+
getPaginationVariables = _require2.getPaginationVariables,
|
38
|
+
getSelector = _require2.getSelector,
|
39
|
+
getValueAtPath = _require2.getValueAtPath;
|
40
|
+
|
41
|
+
var warning = require("fbjs/lib/warning");
|
44
42
|
|
45
43
|
function useLoadMoreFunction(args) {
|
46
44
|
var direction = args.direction,
|
@@ -11,10 +11,10 @@
|
|
11
11
|
// flowlint ambiguous-object-type:error
|
12
12
|
'use strict';
|
13
13
|
|
14
|
-
var React = require('react');
|
15
|
-
|
16
14
|
var useMemoVariables = require('./useMemoVariables');
|
17
15
|
|
16
|
+
var React = require('react');
|
17
|
+
|
18
18
|
var _require = require('relay-runtime'),
|
19
19
|
createOperationDescriptor = _require.createOperationDescriptor,
|
20
20
|
getRequest = _require.getRequest;
|
@@ -11,10 +11,10 @@
|
|
11
11
|
// flowlint ambiguous-object-type:error
|
12
12
|
'use strict';
|
13
13
|
|
14
|
-
var React = require('react');
|
15
|
-
|
16
14
|
var areEqual = require("fbjs/lib/areEqual");
|
17
15
|
|
16
|
+
var React = require('react');
|
17
|
+
|
18
18
|
var useMemo = React.useMemo,
|
19
19
|
useRef = React.useRef,
|
20
20
|
useState = React.useState;
|
@@ -15,10 +15,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
15
15
|
|
16
16
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
17
17
|
|
18
|
-
var
|
18
|
+
var useIsMountedRef = require('./useIsMountedRef');
|
19
19
|
|
20
20
|
var useRelayEnvironment = require('./useRelayEnvironment');
|
21
21
|
|
22
|
+
var React = require('react');
|
23
|
+
|
22
24
|
var _require = require('relay-runtime'),
|
23
25
|
defaultCommitMutation = _require.commitMutation;
|
24
26
|
|
@@ -27,8 +29,6 @@ var useState = React.useState,
|
|
27
29
|
useRef = React.useRef,
|
28
30
|
useCallback = React.useCallback;
|
29
31
|
|
30
|
-
var useIsMountedRef = require('./useIsMountedRef');
|
31
|
-
|
32
32
|
function useMutation(mutation) {
|
33
33
|
var commitMutationFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultCommitMutation;
|
34
34
|
var environment = useRelayEnvironment();
|
@@ -66,16 +66,27 @@ function useMutation(mutation) {
|
|
66
66
|
var disposable = commitMutationFn(environment, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, config), {}, {
|
67
67
|
mutation: mutation,
|
68
68
|
onCompleted: function onCompleted(response, errors) {
|
69
|
+
var _config$onCompleted;
|
70
|
+
|
69
71
|
cleanup(disposable);
|
70
|
-
config.onCompleted
|
72
|
+
(_config$onCompleted = config.onCompleted) === null || _config$onCompleted === void 0 ? void 0 : _config$onCompleted.call(config, response, errors);
|
71
73
|
},
|
72
74
|
onError: function onError(error) {
|
75
|
+
var _config$onError;
|
76
|
+
|
73
77
|
cleanup(disposable);
|
74
|
-
config.onError
|
78
|
+
(_config$onError = config.onError) === null || _config$onError === void 0 ? void 0 : _config$onError.call(config, error);
|
75
79
|
},
|
76
80
|
onUnsubscribe: function onUnsubscribe() {
|
81
|
+
var _config$onUnsubscribe;
|
82
|
+
|
77
83
|
cleanup(disposable);
|
78
|
-
config.onUnsubscribe
|
84
|
+
(_config$onUnsubscribe = config.onUnsubscribe) === null || _config$onUnsubscribe === void 0 ? void 0 : _config$onUnsubscribe.call(config);
|
85
|
+
},
|
86
|
+
onNext: function onNext() {
|
87
|
+
var _config$onNext;
|
88
|
+
|
89
|
+
(_config$onNext = config.onNext) === null || _config$onNext === void 0 ? void 0 : _config$onNext.call(config);
|
79
90
|
}
|
80
91
|
}));
|
81
92
|
inFlightMutationsRef.current.add(disposable);
|
@@ -15,8 +15,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
15
15
|
|
16
16
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
17
17
|
|
18
|
-
var getPaginationMetadata = require('./getPaginationMetadata');
|
19
|
-
|
20
18
|
var useLoadMoreFunction = require('./useLoadMoreFunction');
|
21
19
|
|
22
20
|
var useRefetchableFragmentNode = require('./useRefetchableFragmentNode');
|
@@ -30,7 +28,8 @@ var _require = require('react'),
|
|
30
28
|
|
31
29
|
var _require2 = require('relay-runtime'),
|
32
30
|
getFragment = _require2.getFragment,
|
33
|
-
getFragmentIdentifier = _require2.getFragmentIdentifier
|
31
|
+
getFragmentIdentifier = _require2.getFragmentIdentifier,
|
32
|
+
getPaginationMetadata = _require2.getPaginationMetadata;
|
34
33
|
|
35
34
|
function usePaginationFragment(fragmentInput, parentFragmentRef) {
|
36
35
|
var fragmentNode = getFragment(fragmentInput);
|
@@ -11,7 +11,8 @@
|
|
11
11
|
// flowlint ambiguous-object-type:error
|
12
12
|
'use strict';
|
13
13
|
|
14
|
-
var
|
14
|
+
var _require = require('./loadQuery'),
|
15
|
+
useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
|
15
16
|
|
16
17
|
var useLazyLoadQueryNode = require('./useLazyLoadQueryNode');
|
17
18
|
|
@@ -19,10 +20,7 @@ var useMemoOperationDescriptor = require('./useMemoOperationDescriptor');
|
|
19
20
|
|
20
21
|
var useRelayEnvironment = require('./useRelayEnvironment');
|
21
22
|
|
22
|
-
var
|
23
|
-
|
24
|
-
var _require = require('./loadQuery'),
|
25
|
-
useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
|
23
|
+
var invariant = require('invariant');
|
26
24
|
|
27
25
|
var _require2 = require('react'),
|
28
26
|
useDebugValue = _require2.useDebugValue;
|
@@ -32,6 +30,8 @@ var _require3 = require('relay-runtime'),
|
|
32
30
|
fetchQueryDeduped = _require3$__internal.fetchQueryDeduped,
|
33
31
|
fetchQuery = _require3$__internal.fetchQuery;
|
34
32
|
|
33
|
+
var warning = require("fbjs/lib/warning");
|
34
|
+
|
35
35
|
function usePreloadedQuery(gqlQuery, preloadedQuery, options) {
|
36
36
|
// We need to use this hook in order to be able to track if
|
37
37
|
// loadQuery was called during render
|
@@ -40,8 +40,9 @@ function usePreloadedQuery(gqlQuery, preloadedQuery, options) {
|
|
40
40
|
var fetchKey = preloadedQuery.fetchKey,
|
41
41
|
fetchPolicy = preloadedQuery.fetchPolicy,
|
42
42
|
source = preloadedQuery.source,
|
43
|
-
variables = preloadedQuery.variables
|
44
|
-
|
43
|
+
variables = preloadedQuery.variables,
|
44
|
+
networkCacheConfig = preloadedQuery.networkCacheConfig;
|
45
|
+
var operation = useMemoOperationDescriptor(gqlQuery, variables, networkCacheConfig);
|
45
46
|
var useLazyLoadQueryNodeParams;
|
46
47
|
|
47
48
|
if (preloadedQuery.kind === 'PreloadedQuery_DEPRECATED') {
|
@@ -15,24 +15,36 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
15
15
|
|
16
16
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
17
17
|
|
18
|
-
var useIsMountedRef = require('./useIsMountedRef');
|
19
|
-
|
20
|
-
var useRelayEnvironment = require('./useRelayEnvironment');
|
21
|
-
|
22
18
|
var _require = require('./loadQuery'),
|
23
19
|
loadQuery = _require.loadQuery,
|
24
20
|
useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
|
25
21
|
|
22
|
+
var useIsMountedRef = require('./useIsMountedRef');
|
23
|
+
|
24
|
+
var useRelayEnvironment = require('./useRelayEnvironment');
|
25
|
+
|
26
26
|
var _require2 = require('react'),
|
27
27
|
useCallback = _require2.useCallback,
|
28
28
|
useEffect = _require2.useEffect,
|
29
29
|
useRef = _require2.useRef,
|
30
30
|
useState = _require2.useState;
|
31
31
|
|
32
|
+
var _require3 = require('relay-runtime'),
|
33
|
+
getRequest = _require3.getRequest;
|
34
|
+
|
32
35
|
var initialNullQueryReferenceState = {
|
33
36
|
kind: 'NullQueryReference'
|
34
37
|
};
|
35
38
|
|
39
|
+
function requestIsLiveQuery(preloadableRequest) {
|
40
|
+
if (preloadableRequest.kind === 'PreloadableConcreteRequest') {
|
41
|
+
return preloadableRequest.params.metadata.live !== undefined;
|
42
|
+
}
|
43
|
+
|
44
|
+
var request = getRequest(preloadableRequest);
|
45
|
+
return request.params.metadata.live !== undefined;
|
46
|
+
}
|
47
|
+
|
36
48
|
function useQueryLoader(preloadableRequest, initialQueryReference) {
|
37
49
|
/**
|
38
50
|
* We want to always call `queryReference.dispose()` for every call to
|
@@ -175,7 +187,11 @@ function useQueryLoader(preloadableRequest, initialQueryReference) {
|
|
175
187
|
undisposedQueryReferences["delete"](undisposedQueryReference);
|
176
188
|
|
177
189
|
if (undisposedQueryReference.kind !== 'NullQueryReference') {
|
178
|
-
|
190
|
+
if (requestIsLiveQuery(preloadableRequest)) {
|
191
|
+
undisposedQueryReference.dispose && undisposedQueryReference.dispose();
|
192
|
+
} else {
|
193
|
+
undisposedQueryReference.releaseQuery && undisposedQueryReference.releaseQuery();
|
194
|
+
}
|
179
195
|
}
|
180
196
|
}
|
181
197
|
} catch (err) {
|
@@ -184,7 +200,7 @@ function useQueryLoader(preloadableRequest, initialQueryReference) {
|
|
184
200
|
_iterator.f();
|
185
201
|
}
|
186
202
|
}
|
187
|
-
}, [queryReference, isMountedRef, queryLoaderCallback]);
|
203
|
+
}, [queryReference, isMountedRef, queryLoaderCallback, preloadableRequest]);
|
188
204
|
useEffect(function () {
|
189
205
|
return function disposeAllRemainingQueryReferences() {
|
190
206
|
// undisposedQueryReferences.current is never reassigned
|
@@ -194,10 +210,14 @@ function useQueryLoader(preloadableRequest, initialQueryReference) {
|
|
194
210
|
|
195
211
|
try {
|
196
212
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
197
|
-
var
|
213
|
+
var undisposedQueryReference = _step2.value;
|
198
214
|
|
199
|
-
if (
|
200
|
-
|
215
|
+
if (undisposedQueryReference.kind !== 'NullQueryReference') {
|
216
|
+
if (requestIsLiveQuery(preloadableRequest)) {
|
217
|
+
undisposedQueryReference.dispose && undisposedQueryReference.dispose();
|
218
|
+
} else {
|
219
|
+
undisposedQueryReference.releaseQuery && undisposedQueryReference.releaseQuery();
|
220
|
+
}
|
201
221
|
}
|
202
222
|
}
|
203
223
|
} catch (err) {
|
@@ -206,7 +226,7 @@ function useQueryLoader(preloadableRequest, initialQueryReference) {
|
|
206
226
|
_iterator2.f();
|
207
227
|
}
|
208
228
|
};
|
209
|
-
}, []);
|
229
|
+
}, [preloadableRequest]);
|
210
230
|
return [queryReference.kind === 'NullQueryReference' ? null : queryReference, queryLoaderCallback, disposeQuery];
|
211
231
|
}
|
212
232
|
|
@@ -15,13 +15,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
15
15
|
|
16
16
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
17
17
|
|
18
|
-
var
|
19
|
-
|
20
|
-
var getRefetchMetadata = require('./getRefetchMetadata');
|
18
|
+
var _require = require('./FragmentResource'),
|
19
|
+
getFragmentResourceForEnvironment = _require.getFragmentResourceForEnvironment;
|
21
20
|
|
22
|
-
var
|
21
|
+
var ProfilerContext = require('./ProfilerContext');
|
23
22
|
|
24
|
-
var
|
23
|
+
var _require2 = require('./QueryResource'),
|
24
|
+
getQueryResourceForEnvironment = _require2.getQueryResourceForEnvironment;
|
25
25
|
|
26
26
|
var useFragmentNode = require('./useFragmentNode');
|
27
27
|
|
@@ -31,13 +31,7 @@ var useQueryLoader = require('./useQueryLoader');
|
|
31
31
|
|
32
32
|
var useRelayEnvironment = require('./useRelayEnvironment');
|
33
33
|
|
34
|
-
var
|
35
|
-
|
36
|
-
var _require = require('./FragmentResource'),
|
37
|
-
getFragmentResourceForEnvironment = _require.getFragmentResourceForEnvironment;
|
38
|
-
|
39
|
-
var _require2 = require('./QueryResource'),
|
40
|
-
getQueryResourceForEnvironment = _require2.getQueryResourceForEnvironment;
|
34
|
+
var invariant = require('invariant');
|
41
35
|
|
42
36
|
var _require3 = require('react'),
|
43
37
|
useCallback = _require3.useCallback,
|
@@ -48,7 +42,11 @@ var _require4 = require('relay-runtime'),
|
|
48
42
|
fetchQuery = _require4.__internal.fetchQuery,
|
49
43
|
createOperationDescriptor = _require4.createOperationDescriptor,
|
50
44
|
getFragmentIdentifier = _require4.getFragmentIdentifier,
|
51
|
-
|
45
|
+
getRefetchMetadata = _require4.getRefetchMetadata,
|
46
|
+
getSelector = _require4.getSelector,
|
47
|
+
getValueAtPath = _require4.getValueAtPath;
|
48
|
+
|
49
|
+
var warning = require("fbjs/lib/warning");
|
52
50
|
|
53
51
|
function reducer(state, action) {
|
54
52
|
switch (action.type) {
|
@@ -311,7 +309,7 @@ function useRefetchFunction(componentDisplayName, dispatch, disposeQuery, fragme
|
|
311
309
|
// - fragmentNode and parentFragmentRef are also captured by including
|
312
310
|
// fragmentIdentifier
|
313
311
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
314
|
-
[fragmentIdentifier, dispatch, disposeQuery, identifierValue]);
|
312
|
+
[fragmentIdentifier, dispatch, disposeQuery, identifierValue, loadQuery]);
|
315
313
|
}
|
316
314
|
|
317
315
|
var debugFunctions;
|
@@ -11,13 +11,13 @@
|
|
11
11
|
// flowlint ambiguous-object-type:error
|
12
12
|
'use strict';
|
13
13
|
|
14
|
-
var
|
15
|
-
|
16
|
-
var invariant = require("fbjs/lib/invariant");
|
14
|
+
var invariant = require('invariant');
|
17
15
|
|
18
16
|
var _require = require('react'),
|
19
17
|
useContext = _require.useContext;
|
20
18
|
|
19
|
+
var ReactRelayContext = require('react-relay/ReactRelayContext');
|
20
|
+
|
21
21
|
function useRelayEnvironment() {
|
22
22
|
var context = useContext(ReactRelayContext);
|
23
23
|
!(context != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'useRelayEnvironment: Expected to have found a Relay environment provided by ' + 'a `RelayEnvironmentProvider` component. ' + 'This usually means that useRelayEnvironment was used in a ' + 'component that is not a descendant of a `RelayEnvironmentProvider`. ' + 'Please make sure a `RelayEnvironmentProvider` has been rendered somewhere ' + 'as a parent or ancestor of your component.') : invariant(false) : void 0;
|
@@ -11,11 +11,11 @@
|
|
11
11
|
// flowlint ambiguous-object-type:error
|
12
12
|
'use strict';
|
13
13
|
|
14
|
-
var warning = require("fbjs/lib/warning");
|
15
|
-
|
16
14
|
var _require = require('react'),
|
17
15
|
useRef = _require.useRef;
|
18
16
|
|
17
|
+
var warning = require("fbjs/lib/warning");
|
18
|
+
|
19
19
|
function useStaticFragmentNodeWarning(fragmentNode, warningContext) {
|
20
20
|
if (process.env.NODE_ENV !== "production") {
|
21
21
|
// This is calling `useRef` conditionally, but based on the environment
|
@@ -16,7 +16,6 @@ var useRelayEnvironment = require('./useRelayEnvironment');
|
|
16
16
|
var _require = require('react'),
|
17
17
|
useEffect = _require.useEffect,
|
18
18
|
useRef = _require.useRef;
|
19
|
-
|
20
19
|
/**
|
21
20
|
* This hook subscribes a callback to the invalidation state of the given data
|
22
21
|
* ids.
|
@@ -26,6 +25,8 @@ var _require = require('react'),
|
|
26
25
|
* re-established and the previous one will be disposed.
|
27
26
|
* The subscription will automatically be disposed on unmount
|
28
27
|
*/
|
28
|
+
|
29
|
+
|
29
30
|
function useSubscribeToInvalidationState(dataIDs, callback) {
|
30
31
|
var environment = useRelayEnvironment();
|
31
32
|
var disposableRef = useRef(null);
|