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.
- package/ReactRelayContainerUtils.js.flow +1 -0
- package/ReactRelayContext.js +1 -1
- package/ReactRelayContext.js.flow +1 -0
- package/ReactRelayFragmentContainer.js.flow +6 -2
- package/ReactRelayFragmentMockRenderer.js.flow +1 -0
- package/ReactRelayLocalQueryRenderer.js.flow +5 -3
- package/ReactRelayPaginationContainer.js.flow +21 -12
- package/ReactRelayQueryFetcher.js.flow +19 -5
- package/ReactRelayQueryRenderer.js.flow +32 -1
- package/ReactRelayQueryRendererContext.js.flow +1 -0
- package/ReactRelayRefetchContainer.js.flow +9 -5
- package/ReactRelayTestMocker.js.flow +3 -1
- package/ReactRelayTypes.js.flow +1 -0
- package/RelayContext.js.flow +1 -0
- package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +2 -1
- package/__flowtests__/ReactRelayPaginationContainer-flowtest.js.flow +1 -0
- package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +1 -0
- package/__flowtests__/RelayModern-flowtest.js.flow +1 -0
- package/__flowtests__/RelayModernFlowtest_badref.graphql.js.flow +1 -0
- package/__flowtests__/RelayModernFlowtest_notref.graphql.js.flow +1 -0
- package/__flowtests__/RelayModernFlowtest_user.graphql.js.flow +1 -0
- package/__flowtests__/RelayModernFlowtest_users.graphql.js.flow +1 -0
- 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 -0
- package/buildReactRelayContainer.js.flow +7 -5
- package/getRootVariablesForFragments.js.flow +1 -1
- package/hooks.js +1 -1
- package/hooks.js.flow +4 -0
- package/index.js +1 -1
- package/index.js.flow +4 -0
- package/isRelayEnvironment.js.flow +1 -0
- 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 -0
- package/lib/ReactRelayContainerUtils.js +2 -2
- package/lib/ReactRelayContext.js +3 -3
- package/lib/ReactRelayFragmentContainer.js +39 -66
- package/lib/ReactRelayFragmentMockRenderer.js +2 -3
- package/lib/ReactRelayLocalQueryRenderer.js +18 -30
- package/lib/ReactRelayPaginationContainer.js +66 -159
- package/lib/ReactRelayQueryFetcher.js +48 -74
- package/lib/ReactRelayQueryRenderer.js +62 -82
- package/lib/ReactRelayQueryRendererContext.js +2 -1
- package/lib/ReactRelayRefetchContainer.js +52 -99
- package/lib/ReactRelayTestMocker.js +32 -66
- package/lib/ReactRelayTypes.js +2 -0
- package/lib/RelayContext.js +4 -6
- package/lib/assertFragmentMap.js +3 -4
- package/lib/buildReactRelayContainer.js +10 -25
- package/lib/getRootVariablesForFragments.js +5 -8
- package/lib/hooks.js +5 -17
- package/lib/index.js +5 -24
- package/lib/isRelayEnvironment.js +5 -3
- 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 -7
- package/lib/multi-actor/ActorChange.js +2 -5
- package/lib/multi-actor/index.js +2 -1
- package/lib/multi-actor/useRelayActorEnvironment.js +4 -7
- package/lib/relay-hooks/EntryPointContainer.react.js +9 -14
- package/lib/relay-hooks/EntryPointTypes.flow.js +5 -2
- package/lib/relay-hooks/FragmentResource.js +102 -196
- package/lib/relay-hooks/HooksImplementation.js +2 -5
- package/lib/relay-hooks/InternalLogger.js +2 -2
- package/lib/relay-hooks/LRUCache.js +2 -19
- package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +33 -53
- package/lib/relay-hooks/MatchContainer.js +14 -22
- package/lib/relay-hooks/ProfilerContext.js +3 -2
- package/lib/relay-hooks/QueryResource.js +30 -99
- package/lib/relay-hooks/RelayEnvironmentProvider.js +5 -8
- package/lib/relay-hooks/SuspenseResource.js +8 -31
- package/lib/relay-hooks/loadEntryPoint.js +19 -31
- package/lib/relay-hooks/loadQuery.js +41 -77
- package/lib/relay-hooks/preloadQuery_DEPRECATED.js +10 -35
- package/lib/relay-hooks/prepareEntryPoint_DEPRECATED.js +9 -14
- package/lib/relay-hooks/react-cache/RelayReactCache.js +7 -11
- package/lib/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js +24 -78
- package/lib/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js +23 -56
- package/lib/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js +65 -143
- package/lib/relay-hooks/react-cache/useFragment_REACT_CACHE.js +5 -14
- package/lib/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js +17 -23
- package/lib/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js +73 -74
- package/lib/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js +24 -38
- package/lib/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js +60 -102
- package/lib/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js +7 -15
- package/lib/relay-hooks/useBlockingPaginationFragment.js +71 -92
- package/lib/relay-hooks/useClientQuery.js +3 -6
- package/lib/relay-hooks/useEntryPointLoader.js +17 -36
- package/lib/relay-hooks/useFetchTrackingRef.js +10 -11
- package/lib/relay-hooks/useFragment.js +8 -18
- package/lib/relay-hooks/useFragmentNode.js +20 -31
- package/lib/relay-hooks/useIsMountedRef.js +4 -5
- package/lib/relay-hooks/useIsOperationNodeActive.js +8 -20
- package/lib/relay-hooks/useIsParentQueryActive.js +3 -6
- package/lib/relay-hooks/useLazyLoadQuery.js +6 -9
- package/lib/relay-hooks/useLazyLoadQueryNode.js +23 -33
- package/lib/relay-hooks/useLoadMoreFunction.js +45 -76
- package/lib/relay-hooks/useMemoOperationDescriptor.js +6 -14
- package/lib/relay-hooks/useMemoVariables.js +15 -33
- package/lib/relay-hooks/useMutation.js +8 -25
- package/lib/relay-hooks/usePaginationFragment.js +61 -76
- package/lib/relay-hooks/usePreloadedQuery.js +12 -29
- package/lib/relay-hooks/useQueryLoader.js +23 -47
- package/lib/relay-hooks/useRefetchableFragment.js +8 -18
- package/lib/relay-hooks/useRefetchableFragmentNode.js +64 -107
- package/lib/relay-hooks/useRelayEnvironment.js +4 -7
- package/lib/relay-hooks/useStaticFragmentNodeWarning.js +4 -7
- package/lib/relay-hooks/useSubscribeToInvalidationState.js +8 -8
- package/lib/relay-hooks/useSubscription.js +5 -9
- 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 -2
- 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 +1 -1
- package/relay-hooks/EntryPointTypes.flow.js.flow +7 -5
- package/relay-hooks/FragmentResource.js.flow +34 -8
- package/relay-hooks/HooksImplementation.js.flow +1 -1
- package/relay-hooks/InternalLogger.js.flow +1 -1
- package/relay-hooks/LRUCache.js.flow +1 -1
- package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +15 -8
- package/relay-hooks/MatchContainer.js.flow +1 -1
- package/relay-hooks/ProfilerContext.js.flow +1 -1
- package/relay-hooks/QueryResource.js.flow +25 -5
- package/relay-hooks/RelayEnvironmentProvider.js.flow +2 -2
- package/relay-hooks/SuspenseResource.js.flow +1 -1
- package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +3 -1
- package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +2 -2
- 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 +35 -33
- package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +1 -1
- package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +33 -32
- package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +18 -18
- package/relay-hooks/__flowtests__/utils.js.flow +13 -2
- package/relay-hooks/loadEntryPoint.js.flow +11 -6
- package/relay-hooks/loadQuery.js.flow +11 -7
- package/relay-hooks/preloadQuery_DEPRECATED.js.flow +5 -6
- package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +13 -8
- package/relay-hooks/react-cache/RelayReactCache.js.flow +1 -1
- package/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js.flow +4 -4
- package/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js.flow +3 -3
- package/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js.flow +4 -4
- package/relay-hooks/react-cache/useFragment_REACT_CACHE.js.flow +1 -1
- package/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js.flow +1 -1
- package/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js.flow +41 -22
- package/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js.flow +1 -2
- package/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js.flow +11 -5
- package/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js.flow +2 -2
- package/relay-hooks/useBlockingPaginationFragment.js.flow +85 -56
- package/relay-hooks/useClientQuery.js.flow +1 -1
- package/relay-hooks/useEntryPointLoader.js.flow +10 -6
- package/relay-hooks/useFetchTrackingRef.js.flow +5 -4
- package/relay-hooks/useFragment.js.flow +2 -2
- package/relay-hooks/useFragmentNode.js.flow +5 -4
- package/relay-hooks/useIsMountedRef.js.flow +1 -1
- package/relay-hooks/useIsOperationNodeActive.js.flow +1 -1
- package/relay-hooks/useIsParentQueryActive.js.flow +1 -1
- package/relay-hooks/useLazyLoadQuery.js.flow +2 -2
- package/relay-hooks/useLazyLoadQueryNode.js.flow +2 -2
- package/relay-hooks/useLoadMoreFunction.js.flow +14 -9
- package/relay-hooks/useMemoOperationDescriptor.js.flow +3 -3
- package/relay-hooks/useMemoVariables.js.flow +13 -29
- package/relay-hooks/useMutation.js.flow +4 -4
- package/relay-hooks/usePaginationFragment.js.flow +53 -46
- package/relay-hooks/usePreloadedQuery.js.flow +47 -22
- package/relay-hooks/useQueryLoader.js.flow +85 -22
- package/relay-hooks/useRefetchableFragment.js.flow +64 -33
- package/relay-hooks/useRefetchableFragmentNode.js.flow +10 -4
- package/relay-hooks/useRelayEnvironment.js.flow +2 -2
- package/relay-hooks/useStaticFragmentNodeWarning.js.flow +3 -3
- package/relay-hooks/useSubscribeToInvalidationState.js.flow +2 -2
- package/relay-hooks/useSubscription.js.flow +1 -1
- package/relay-hooks/useUnsafeRef_DEPRECATED.js.flow +25 -0
- package/lib/readContext.js +0 -27
- package/readContext.js.flow +0 -29
@@ -5,8 +5,8 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*
|
7
7
|
* @flow strict-local
|
8
|
-
* @emails oncall+relay
|
9
8
|
* @format
|
9
|
+
* @oncall relay
|
10
10
|
*/
|
11
11
|
|
12
12
|
'use strict';
|
@@ -35,6 +35,7 @@ const warning = require('warning');
|
|
35
35
|
|
36
36
|
const CACHE_CAPACITY = 1000;
|
37
37
|
const DEFAULT_FETCH_POLICY = 'store-or-network';
|
38
|
+
const DEFAULT_LIVE_FETCH_POLICY = 'store-and-network';
|
38
39
|
|
39
40
|
export type QueryResource = QueryResourceImpl;
|
40
41
|
|
@@ -83,7 +84,11 @@ function getQueryCacheIdentifier(
|
|
83
84
|
maybeRenderPolicy: ?RenderPolicy,
|
84
85
|
cacheBreaker?: ?string | ?number,
|
85
86
|
): string {
|
86
|
-
const fetchPolicy =
|
87
|
+
const fetchPolicy =
|
88
|
+
maybeFetchPolicy ??
|
89
|
+
(operationIsLiveQuery(operation)
|
90
|
+
? DEFAULT_LIVE_FETCH_POLICY
|
91
|
+
: DEFAULT_FETCH_POLICY);
|
87
92
|
const renderPolicy =
|
88
93
|
maybeRenderPolicy ?? environment.UNSTABLE_getDefaultRenderPolicy();
|
89
94
|
const cacheIdentifier = `${fetchPolicy}-${renderPolicy}-${operation.request.identifier}`;
|
@@ -143,7 +148,18 @@ function createCacheEntry(
|
|
143
148
|
};
|
144
149
|
});
|
145
150
|
|
146
|
-
const cacheEntry
|
151
|
+
const cacheEntry: {
|
152
|
+
cacheIdentifier: string,
|
153
|
+
getValue(): QueryResult | Promise<void> | Error,
|
154
|
+
id: number,
|
155
|
+
operationAvailability: ?OperationAvailability,
|
156
|
+
permanentRetain(environment: IEnvironment): Disposable,
|
157
|
+
processedPayloadsCount: number,
|
158
|
+
releaseTemporaryRetain(): void,
|
159
|
+
setNetworkSubscription(subscription: ?Subscription): void,
|
160
|
+
setValue(val: QueryResult | Promise<void> | Error): void,
|
161
|
+
temporaryRetain(environment: IEnvironment): Disposable,
|
162
|
+
} = {
|
147
163
|
cacheIdentifier,
|
148
164
|
id: nextID++,
|
149
165
|
processedPayloadsCount: 0,
|
@@ -225,7 +241,11 @@ class QueryResourceImpl {
|
|
225
241
|
profilerContext: mixed,
|
226
242
|
): QueryResult {
|
227
243
|
const environment = this._environment;
|
228
|
-
const fetchPolicy =
|
244
|
+
const fetchPolicy =
|
245
|
+
maybeFetchPolicy ??
|
246
|
+
(operationIsLiveQuery(operation)
|
247
|
+
? DEFAULT_LIVE_FETCH_POLICY
|
248
|
+
: DEFAULT_FETCH_POLICY);
|
229
249
|
const renderPolicy =
|
230
250
|
maybeRenderPolicy ?? environment.UNSTABLE_getDefaultRenderPolicy();
|
231
251
|
|
@@ -525,7 +545,7 @@ class QueryResourceImpl {
|
|
525
545
|
|
526
546
|
let cacheEntry = this._cache.get(cacheIdentifier);
|
527
547
|
if (!cacheEntry) {
|
528
|
-
const networkPromise = new Promise(resolve => {
|
548
|
+
const networkPromise = new Promise<void>(resolve => {
|
529
549
|
resolveNetworkPromise = resolve;
|
530
550
|
});
|
531
551
|
|
@@ -4,9 +4,9 @@
|
|
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
|
* @flow strict-local
|
9
8
|
* @format
|
9
|
+
* @oncall relay
|
10
10
|
*/
|
11
11
|
|
12
12
|
'use strict';
|
@@ -17,8 +17,8 @@ import type {
|
|
17
17
|
IActorEnvironment,
|
18
18
|
} from 'relay-runtime/multi-actor-environment';
|
19
19
|
|
20
|
+
const ReactRelayContext = require('./../ReactRelayContext');
|
20
21
|
const React = require('react');
|
21
|
-
const ReactRelayContext = require('react-relay/ReactRelayContext');
|
22
22
|
|
23
23
|
const {useMemo} = React;
|
24
24
|
|
@@ -4,11 +4,13 @@
|
|
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
|
* @flow strict-local
|
9
8
|
* @format
|
9
|
+
* @oncall relay
|
10
10
|
*/
|
11
11
|
|
12
|
+
/* eslint-disable no-unused-vars */
|
13
|
+
|
12
14
|
'use strict';
|
13
15
|
|
14
16
|
import type {
|
@@ -4,19 +4,19 @@
|
|
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
|
* @flow strict-local
|
9
8
|
* @format
|
9
|
+
* @oncall relay
|
10
10
|
*/
|
11
11
|
|
12
12
|
'use strict';
|
13
13
|
|
14
|
-
import type {JSResourceReference} from 'JSResourceReference';
|
15
14
|
import type {
|
16
15
|
EntryPoint,
|
17
16
|
EntryPointProps,
|
18
17
|
PreloadedEntryPoint,
|
19
18
|
} from '../../EntryPointTypes.flow';
|
19
|
+
import type {JSResourceReference} from 'JSResourceReference';
|
20
20
|
|
21
21
|
declare function mockJSResource<TModule>(
|
22
22
|
module: TModule,
|
@@ -4,7 +4,9 @@
|
|
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
|
-
* @
|
7
|
+
* @oncall relay
|
8
|
+
*
|
9
|
+
* @generated SignedSource<<fef9e96f393a59b2e761b70b1c3ddc50>>
|
8
10
|
* @flow
|
9
11
|
* @lightSyntaxTransform
|
10
12
|
* @nogrep
|
@@ -4,7 +4,9 @@
|
|
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
|
-
* @
|
7
|
+
* @oncall relay
|
8
|
+
*
|
9
|
+
* @generated SignedSource<<1bd343735be9917826ee3203cf6756c4>>
|
8
10
|
* @flow
|
9
11
|
* @lightSyntaxTransform
|
10
12
|
* @nogrep
|
@@ -4,9 +4,9 @@
|
|
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
|
* @flow strict-local
|
9
8
|
* @format
|
9
|
+
* @oncall relay
|
10
10
|
*/
|
11
11
|
|
12
12
|
import type {LoadMoreFn} from '../useLoadMoreFunction';
|
@@ -14,80 +14,82 @@ import type {
|
|
14
14
|
FetchFn,
|
15
15
|
NonNullableData,
|
16
16
|
NullableData,
|
17
|
-
QueryOperation,
|
18
17
|
QueryVariables,
|
19
18
|
QueryVariablesSubset,
|
20
19
|
} from './utils';
|
21
|
-
import type {IEnvironment,
|
20
|
+
import type {IEnvironment, Variables} from 'relay-runtime';
|
22
21
|
|
23
22
|
import useBlockingPaginationFragment from '../useBlockingPaginationFragment';
|
24
23
|
import {
|
25
24
|
fragmentData,
|
26
|
-
fragmentInput,
|
27
25
|
keyAnotherNonNullable,
|
28
26
|
keyAnotherNullable,
|
29
27
|
keyNonNullable,
|
30
28
|
keyNullable,
|
29
|
+
refetchableFragmentInput,
|
31
30
|
} from './utils';
|
32
31
|
|
33
32
|
type ExpectedReturnType<
|
34
|
-
|
35
|
-
|
33
|
+
TRefetchVariables: Variables,
|
34
|
+
TLoadMoreVariables: Variables,
|
36
35
|
TFragmentData,
|
37
36
|
> = {
|
38
37
|
data: TFragmentData,
|
39
|
-
loadNext: LoadMoreFn<
|
40
|
-
loadPrevious: LoadMoreFn<
|
38
|
+
loadNext: LoadMoreFn<TLoadMoreVariables>,
|
39
|
+
loadPrevious: LoadMoreFn<TLoadMoreVariables>,
|
41
40
|
hasNext: boolean,
|
42
41
|
hasPrevious: boolean,
|
43
|
-
refetch: FetchFn<
|
42
|
+
refetch: FetchFn<TRefetchVariables>,
|
44
43
|
};
|
45
44
|
|
46
45
|
/* eslint-disable react-hooks/rules-of-hooks */
|
47
46
|
|
48
47
|
// Nullability of returned data type is correct
|
49
|
-
(useBlockingPaginationFragment
|
50
|
-
|
48
|
+
(useBlockingPaginationFragment(
|
49
|
+
refetchableFragmentInput,
|
51
50
|
keyNonNullable,
|
52
|
-
): ExpectedReturnType<
|
51
|
+
): ExpectedReturnType<QueryVariablesSubset, QueryVariables, NonNullableData>);
|
53
52
|
|
54
|
-
(useBlockingPaginationFragment
|
55
|
-
|
53
|
+
(useBlockingPaginationFragment(
|
54
|
+
refetchableFragmentInput,
|
56
55
|
keyNullable,
|
57
|
-
): ExpectedReturnType<
|
56
|
+
): ExpectedReturnType<QueryVariables, QueryVariables, NullableData>);
|
58
57
|
|
59
58
|
// $FlowExpectedError: can't cast nullable to non-nullable
|
60
|
-
(useBlockingPaginationFragment
|
61
|
-
|
59
|
+
(useBlockingPaginationFragment(
|
60
|
+
refetchableFragmentInput,
|
62
61
|
keyNullable,
|
63
|
-
): ExpectedReturnType<
|
62
|
+
): ExpectedReturnType<QueryVariables, QueryVariables, NonNullableData>);
|
64
63
|
|
65
64
|
// $FlowExpectedError: actual type of returned data is correct
|
66
|
-
(useBlockingPaginationFragment
|
67
|
-
|
65
|
+
(useBlockingPaginationFragment(
|
66
|
+
refetchableFragmentInput,
|
67
|
+
// $FlowExpectedError[incompatible-call]
|
68
68
|
keyAnotherNonNullable,
|
69
|
-
): ExpectedReturnType<
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
): ExpectedReturnType<QueryVariables, QueryVariablesSubset, NonNullableData>);
|
70
|
+
|
71
|
+
// $FlowExpectedError[incompatible-call] `Example_user$fragmentType` is incompatible with `FragmentType`
|
72
|
+
(useBlockingPaginationFragment(
|
73
|
+
refetchableFragmentInput,
|
74
|
+
// $FlowExpectedError[incompatible-call]
|
73
75
|
keyAnotherNullable,
|
74
|
-
): ExpectedReturnType<
|
76
|
+
): ExpectedReturnType<QueryVariables, QueryVariables, NullableData>);
|
75
77
|
|
76
78
|
// $FlowExpectedError: Key should not be a user provided object
|
77
|
-
useBlockingPaginationFragment
|
79
|
+
useBlockingPaginationFragment(fragmentInput, {abc: 123});
|
78
80
|
|
79
81
|
// $FlowExpectedError: Key should not be an empty object
|
80
|
-
useBlockingPaginationFragment
|
82
|
+
useBlockingPaginationFragment(fragmentInput, {});
|
81
83
|
|
82
84
|
// $FlowExpectedError: Key should be the `<name>$key` type from generated flow
|
83
|
-
useBlockingPaginationFragment
|
85
|
+
useBlockingPaginationFragment(fragmentInput, fragmentData);
|
84
86
|
|
85
87
|
// Refetch function options:
|
86
88
|
declare var variables: QueryVariables;
|
87
89
|
declare var environment: IEnvironment;
|
88
90
|
|
89
|
-
const {refetch} = useBlockingPaginationFragment
|
90
|
-
|
91
|
+
const {refetch} = useBlockingPaginationFragment(
|
92
|
+
refetchableFragmentInput,
|
91
93
|
keyNonNullable,
|
92
94
|
);
|
93
95
|
// $FlowExpectedError: internal option
|
@@ -104,8 +106,8 @@ refetch(variables, {
|
|
104
106
|
declare var extraVariables: {nickname: string};
|
105
107
|
declare var invalidVariables: {foo: string};
|
106
108
|
|
107
|
-
const {loadNext} = useBlockingPaginationFragment
|
108
|
-
|
109
|
+
const {loadNext} = useBlockingPaginationFragment(
|
110
|
+
refetchableFragmentInput,
|
109
111
|
keyNonNullable,
|
110
112
|
);
|
111
113
|
// Accepts extraVariables
|
@@ -113,8 +115,8 @@ loadNext(10, {
|
|
113
115
|
UNSTABLE_extraVariables: extraVariables,
|
114
116
|
});
|
115
117
|
|
116
|
-
// $FlowExpectedError: doesn't accept variables not available in the Flow type
|
117
118
|
loadNext(10, {
|
119
|
+
// $FlowExpectedError: doesn't accept variables not available in the Flow type
|
118
120
|
UNSTABLE_extraVariables: invalidVariables,
|
119
121
|
});
|
120
122
|
|
@@ -4,9 +4,9 @@
|
|
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
|
* @flow strict-local
|
9
8
|
* @format
|
9
|
+
* @oncall relay
|
10
10
|
*/
|
11
11
|
|
12
12
|
import type {LoadMoreFn} from '../useLoadMoreFunction';
|
@@ -14,82 +14,83 @@ import type {
|
|
14
14
|
FetchFn,
|
15
15
|
NonNullableData,
|
16
16
|
NullableData,
|
17
|
-
QueryOperation,
|
18
17
|
QueryVariables,
|
19
18
|
QueryVariablesSubset,
|
20
19
|
} from './utils';
|
21
|
-
import type {IEnvironment,
|
20
|
+
import type {IEnvironment, Variables} from 'relay-runtime';
|
22
21
|
|
23
22
|
import usePaginationFragment from '../usePaginationFragment';
|
24
23
|
import {
|
25
24
|
fragmentData,
|
26
|
-
fragmentInput,
|
27
25
|
keyAnotherNonNullable,
|
28
26
|
keyAnotherNullable,
|
29
27
|
keyNonNullable,
|
30
28
|
keyNullable,
|
29
|
+
refetchableFragmentInput,
|
31
30
|
} from './utils';
|
32
31
|
|
33
32
|
type ExpectedReturnType<
|
34
|
-
|
35
|
-
|
33
|
+
TRefetchVariables: Variables,
|
34
|
+
TLoadMoreVariables: Variables,
|
36
35
|
TFragmentData,
|
37
36
|
> = {
|
38
37
|
data: TFragmentData,
|
39
|
-
loadNext: LoadMoreFn<
|
40
|
-
loadPrevious: LoadMoreFn<
|
38
|
+
loadNext: LoadMoreFn<TLoadMoreVariables>,
|
39
|
+
loadPrevious: LoadMoreFn<TLoadMoreVariables>,
|
41
40
|
hasNext: boolean,
|
42
41
|
hasPrevious: boolean,
|
43
42
|
isLoadingNext: boolean,
|
44
43
|
isLoadingPrevious: boolean,
|
45
|
-
refetch: FetchFn<
|
44
|
+
refetch: FetchFn<TRefetchVariables>,
|
46
45
|
};
|
47
46
|
|
48
47
|
/* eslint-disable react-hooks/rules-of-hooks */
|
49
48
|
|
50
49
|
// Nullability of returned data type is correct
|
51
|
-
(usePaginationFragment
|
52
|
-
|
50
|
+
(usePaginationFragment(
|
51
|
+
refetchableFragmentInput,
|
53
52
|
keyNonNullable,
|
54
|
-
): ExpectedReturnType<
|
53
|
+
): ExpectedReturnType<QueryVariablesSubset, QueryVariables, NonNullableData>);
|
55
54
|
|
56
|
-
(usePaginationFragment
|
57
|
-
|
55
|
+
(usePaginationFragment(
|
56
|
+
refetchableFragmentInput,
|
58
57
|
keyNullable,
|
59
|
-
): ExpectedReturnType<
|
58
|
+
): ExpectedReturnType<QueryVariables, QueryVariables, NullableData>);
|
60
59
|
|
61
60
|
// $FlowExpectedError: can't cast nullable to non-nullable
|
62
|
-
(usePaginationFragment
|
63
|
-
|
61
|
+
(usePaginationFragment(
|
62
|
+
refetchableFragmentInput,
|
64
63
|
keyNullable,
|
65
|
-
): ExpectedReturnType<
|
64
|
+
): ExpectedReturnType<QueryVariables, QueryVariables, NonNullableData>);
|
66
65
|
|
67
66
|
// $FlowExpectedError: actual type of returned data is correct
|
68
|
-
(usePaginationFragment
|
69
|
-
|
67
|
+
(usePaginationFragment(
|
68
|
+
refetchableFragmentInput,
|
69
|
+
// $FlowFixMe[incompatible-call]
|
70
70
|
keyAnotherNonNullable,
|
71
|
-
): ExpectedReturnType<
|
71
|
+
): ExpectedReturnType<QueryVariables, QueryVariablesSubset, NonNullableData>);
|
72
72
|
// $FlowExpectedError
|
73
|
-
(usePaginationFragment
|
74
|
-
|
73
|
+
(usePaginationFragment(
|
74
|
+
refetchableFragmentInput,
|
75
|
+
// $FlowFixMe[incompatible-call]
|
75
76
|
keyAnotherNullable,
|
76
|
-
): ExpectedReturnType<
|
77
|
+
): ExpectedReturnType<QueryVariables, QueryVariables, NonNullableData>);
|
77
78
|
|
78
79
|
// $FlowExpectedError: Key should not be a user provided object
|
79
|
-
usePaginationFragment
|
80
|
+
usePaginationFragment(refetchableFragmentInput, {abc: 123});
|
80
81
|
|
81
82
|
// $FlowExpectedError: Key should not be an empty object
|
82
|
-
usePaginationFragment
|
83
|
+
usePaginationFragment(refetchableFragmentInput, {});
|
83
84
|
|
84
85
|
// $FlowExpectedError: Key should be the `<name>$key` type from generated flow
|
85
|
-
usePaginationFragment
|
86
|
+
usePaginationFragment(refetchableFragmentInput, fragmentData);
|
86
87
|
|
87
88
|
// Refetch function options:
|
88
89
|
declare var variables: QueryVariables;
|
89
90
|
declare var environment: IEnvironment;
|
90
91
|
|
91
|
-
const {refetch} = usePaginationFragment
|
92
|
-
|
92
|
+
const {refetch} = usePaginationFragment(
|
93
|
+
refetchableFragmentInput,
|
93
94
|
keyNonNullable,
|
94
95
|
);
|
95
96
|
// $FlowExpectedError: internal option
|
@@ -106,8 +107,8 @@ refetch(variables, {
|
|
106
107
|
declare var extraVariables: {nickname: string};
|
107
108
|
declare var invalidVariables: {foo: string};
|
108
109
|
|
109
|
-
const {loadNext} = usePaginationFragment
|
110
|
-
|
110
|
+
const {loadNext} = usePaginationFragment(
|
111
|
+
refetchableFragmentInput,
|
111
112
|
keyNonNullable,
|
112
113
|
);
|
113
114
|
// Accepts extraVariables
|
@@ -115,8 +116,8 @@ loadNext(10, {
|
|
115
116
|
UNSTABLE_extraVariables: extraVariables,
|
116
117
|
});
|
117
118
|
|
118
|
-
// $FlowExpectedError: doesn't accept variables not available in the Flow type
|
119
119
|
loadNext(10, {
|
120
|
+
// $FlowExpectedError: doesn't accept variables not available in the Flow type
|
120
121
|
UNSTABLE_extraVariables: invalidVariables,
|
121
122
|
});
|
122
123
|
|
@@ -4,16 +4,15 @@
|
|
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
|
* @flow strict-local
|
9
8
|
* @format
|
9
|
+
* @oncall relay
|
10
10
|
*/
|
11
11
|
|
12
12
|
import type {
|
13
13
|
FetchFn,
|
14
14
|
NonNullableData,
|
15
15
|
NullableData,
|
16
|
-
QueryOperation,
|
17
16
|
QueryVariables,
|
18
17
|
QueryVariablesSubset,
|
19
18
|
} from './utils';
|
@@ -22,64 +21,65 @@ import type {IEnvironment} from 'relay-runtime';
|
|
22
21
|
import useRefetchableFragment from '../useRefetchableFragment';
|
23
22
|
import {
|
24
23
|
fragmentData,
|
25
|
-
fragmentInput,
|
26
24
|
keyAnotherNonNullable,
|
27
25
|
keyAnotherNullable,
|
28
26
|
keyNonNullable,
|
29
27
|
keyNullable,
|
28
|
+
refetchableFragmentInput,
|
30
29
|
} from './utils';
|
31
30
|
|
32
31
|
/* eslint-disable react-hooks/rules-of-hooks */
|
33
32
|
|
34
33
|
// Nullability of returned data type is correct
|
35
|
-
(useRefetchableFragment
|
34
|
+
(useRefetchableFragment(refetchableFragmentInput, keyNonNullable): [
|
36
35
|
NonNullableData,
|
37
36
|
FetchFn<QueryVariablesSubset>,
|
38
37
|
]);
|
39
38
|
|
40
|
-
(useRefetchableFragment
|
39
|
+
(useRefetchableFragment(refetchableFragmentInput, keyNullable): [
|
41
40
|
NullableData,
|
42
41
|
FetchFn<QueryVariables>,
|
43
42
|
]);
|
44
43
|
|
45
44
|
// $FlowExpectedError: can't cast nullable to non-nullable
|
46
|
-
(useRefetchableFragment
|
45
|
+
(useRefetchableFragment(refetchableFragmentInput, keyNullable): [
|
47
46
|
NonNullableData,
|
48
47
|
FetchFn<QueryVariables>,
|
49
48
|
]);
|
50
49
|
|
51
50
|
// $FlowExpectedError: refetch requires exact type if key is nullable
|
52
|
-
(useRefetchableFragment
|
51
|
+
(useRefetchableFragment(refetchableFragmentInput, keyNullable): [
|
53
52
|
NullableData,
|
54
53
|
FetchFn<QueryVariablesSubset>,
|
55
54
|
]);
|
56
55
|
|
57
56
|
// $FlowExpectedError: actual type of returned data is correct
|
58
|
-
(useRefetchableFragment
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
57
|
+
(useRefetchableFragment(refetchableFragmentInput, keyAnotherNonNullable): [
|
58
|
+
NonNullableData,
|
59
|
+
FetchFn<QueryVariablesSubset>,
|
60
|
+
]);
|
61
|
+
|
62
|
+
// $FlowExpectedError - incompatible key types
|
63
|
+
(useRefetchableFragment(refetchableFragmentInput, keyAnotherNullable): [
|
64
64
|
NullableData,
|
65
65
|
FetchFn<QueryVariables>,
|
66
66
|
]);
|
67
67
|
|
68
68
|
// $FlowExpectedError: Key should not be a user provided object
|
69
|
-
useRefetchableFragment
|
69
|
+
useRefetchableFragment(refetchableFragmentInput, {abc: 123});
|
70
70
|
|
71
71
|
// $FlowExpectedError: Key should not be an empty object
|
72
|
-
useRefetchableFragment
|
72
|
+
useRefetchableFragment(refetchableFragmentInput, {});
|
73
73
|
|
74
74
|
// $FlowExpectedError: Key should be the `<name>$key` type from generated flow
|
75
|
-
useRefetchableFragment
|
75
|
+
useRefetchableFragment(refetchableFragmentInput, fragmentData);
|
76
76
|
|
77
77
|
// Refetch function options:
|
78
78
|
declare var variables: QueryVariables;
|
79
79
|
declare var environment: IEnvironment;
|
80
80
|
|
81
|
-
const [
|
82
|
-
|
81
|
+
const [, refetch] = useRefetchableFragment(
|
82
|
+
refetchableFragmentInput,
|
83
83
|
keyNonNullable,
|
84
84
|
);
|
85
85
|
// $FlowExpectedError: internal option
|
@@ -4,20 +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
|
* @flow strict-local
|
9
8
|
* @format
|
9
|
+
* @oncall relay
|
10
10
|
*/
|
11
11
|
|
12
12
|
'use strict';
|
13
13
|
|
14
|
-
import type {
|
14
|
+
import type {
|
15
|
+
Disposable,
|
16
|
+
Fragment,
|
17
|
+
FragmentType,
|
18
|
+
RefetchableFragment,
|
19
|
+
} from 'relay-runtime';
|
15
20
|
|
16
21
|
declare export var fragmentInput: Fragment<
|
17
22
|
Example_user$fragmentType,
|
18
23
|
Example_user$data,
|
19
24
|
>;
|
20
25
|
|
26
|
+
declare export var refetchableFragmentInput: RefetchableFragment<
|
27
|
+
Example_user$fragmentType,
|
28
|
+
Example_user$data,
|
29
|
+
QueryVariables,
|
30
|
+
>;
|
31
|
+
|
21
32
|
declare export opaque type Example_user$fragmentType: FragmentType;
|
22
33
|
export type Example_user$data = NonNullableData;
|
23
34
|
export type Example_user$key = {
|
@@ -6,7 +6,7 @@
|
|
6
6
|
*
|
7
7
|
* @flow strict-local
|
8
8
|
* @format
|
9
|
-
* @
|
9
|
+
* @oncall relay
|
10
10
|
*/
|
11
11
|
|
12
12
|
'use strict';
|
@@ -58,6 +58,7 @@ function loadEntryPoint<
|
|
58
58
|
environmentProviderOptions,
|
59
59
|
);
|
60
60
|
|
61
|
+
// $FlowFixMe[underconstrained-implicit-instantiation]
|
61
62
|
preloadedQueries[queryPropName] = loadQuery(
|
62
63
|
environment,
|
63
64
|
parameters,
|
@@ -81,11 +82,15 @@ function loadEntryPoint<
|
|
81
82
|
}
|
82
83
|
const {entryPoint: nestedEntryPoint, entryPointParams: nestedParams} =
|
83
84
|
entryPointDescription;
|
84
|
-
preloadedEntryPoints[entryPointPropName] = loadEntryPoint
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
85
|
+
preloadedEntryPoints[entryPointPropName] = loadEntryPoint<
|
86
|
+
_,
|
87
|
+
{...},
|
88
|
+
{...},
|
89
|
+
{...},
|
90
|
+
mixed,
|
91
|
+
EntryPointComponent<{...}, {...}, {...}, mixed>,
|
92
|
+
_,
|
93
|
+
>(environmentProvider, nestedEntryPoint, nestedParams);
|
89
94
|
});
|
90
95
|
}
|
91
96
|
|