react-relay 14.0.0 → 14.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/ReactRelayContainerUtils.js.flow +0 -2
- package/ReactRelayContext.js +1 -1
- package/ReactRelayContext.js.flow +0 -2
- package/ReactRelayFragmentContainer.js.flow +0 -2
- package/ReactRelayFragmentMockRenderer.js.flow +0 -2
- package/ReactRelayLocalQueryRenderer.js.flow +0 -2
- package/ReactRelayPaginationContainer.js.flow +0 -2
- package/ReactRelayQueryFetcher.js.flow +9 -11
- package/ReactRelayQueryRenderer.js.flow +10 -12
- package/ReactRelayQueryRendererContext.js.flow +1 -3
- package/ReactRelayRefetchContainer.js.flow +0 -4
- package/ReactRelayTestMocker.js.flow +0 -2
- package/ReactRelayTypes.js.flow +6 -8
- package/RelayContext.js.flow +0 -2
- package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +2 -4
- package/__flowtests__/ReactRelayPaginationContainer-flowtest.js.flow +3 -5
- package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +3 -5
- package/__flowtests__/RelayModern-flowtest.js.flow +2 -4
- package/__flowtests__/RelayModernFlowtest_badref.graphql.js.flow +2 -4
- package/__flowtests__/RelayModernFlowtest_notref.graphql.js.flow +2 -4
- package/__flowtests__/RelayModernFlowtest_user.graphql.js.flow +2 -4
- package/__flowtests__/RelayModernFlowtest_users.graphql.js.flow +2 -4
- package/assertFragmentMap.js.flow +0 -2
- package/buildReactRelayContainer.js.flow +0 -2
- package/getRootVariablesForFragments.js.flow +0 -2
- package/hooks.js +1 -1
- package/hooks.js.flow +0 -2
- package/index.js +1 -1
- package/index.js.flow +2 -2
- package/isRelayEnvironment.js.flow +0 -2
- package/legacy.js +1 -1
- package/legacy.js.flow +0 -2
- package/lib/ReactRelayContainerUtils.js +0 -1
- package/lib/ReactRelayContext.js +0 -1
- package/lib/ReactRelayFragmentContainer.js +10 -9
- package/lib/ReactRelayFragmentMockRenderer.js +0 -1
- package/lib/ReactRelayLocalQueryRenderer.js +0 -1
- package/lib/ReactRelayPaginationContainer.js +14 -11
- package/lib/ReactRelayQueryFetcher.js +1 -2
- package/lib/ReactRelayQueryRenderer.js +1 -2
- package/lib/ReactRelayQueryRendererContext.js +0 -1
- package/lib/ReactRelayRefetchContainer.js +11 -14
- package/lib/ReactRelayTestMocker.js +1 -2
- package/lib/ReactRelayTypes.js +0 -1
- package/lib/RelayContext.js +0 -1
- package/lib/assertFragmentMap.js +0 -1
- package/lib/buildReactRelayContainer.js +1 -2
- package/lib/getRootVariablesForFragments.js +1 -2
- package/lib/hooks.js +0 -1
- package/lib/index.js +3 -1
- package/lib/isRelayEnvironment.js +0 -1
- package/lib/legacy.js +0 -1
- package/lib/multi-actor/useRelayActorEnvironment.js +0 -1
- package/lib/readContext.js +0 -1
- package/lib/relay-hooks/EntryPointContainer.react.js +0 -1
- package/lib/relay-hooks/EntryPointTypes.flow.js +0 -1
- package/lib/relay-hooks/FragmentResource.js +7 -7
- package/lib/relay-hooks/HooksImplementation.js +1 -1
- package/lib/relay-hooks/InternalLogger.js +0 -1
- package/lib/relay-hooks/LRUCache.js +0 -1
- package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +0 -1
- package/lib/relay-hooks/MatchContainer.js +1 -2
- package/lib/relay-hooks/ProfilerContext.js +0 -1
- package/lib/relay-hooks/QueryResource.js +1 -2
- package/lib/relay-hooks/RelayEnvironmentProvider.js +0 -1
- package/lib/relay-hooks/SuspenseResource.js +1 -2
- package/lib/relay-hooks/loadQuery.js +1 -1
- package/lib/relay-hooks/preloadQuery_DEPRECATED.js +1 -2
- package/lib/relay-hooks/prepareEntryPoint_DEPRECATED.js +0 -1
- package/lib/relay-hooks/react-cache/RelayReactCache.js +0 -1
- package/lib/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js +3 -3
- package/lib/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js +239 -0
- package/lib/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js +183 -125
- package/lib/relay-hooks/react-cache/useFragment_REACT_CACHE.js +0 -1
- package/lib/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js +0 -1
- package/lib/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js +150 -0
- package/lib/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js +0 -1
- package/lib/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js +367 -0
- package/lib/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js +45 -0
- package/lib/relay-hooks/useBlockingPaginationFragment.js +4 -3
- package/lib/relay-hooks/useClientQuery.js +33 -0
- package/lib/relay-hooks/useEntryPointLoader.js +1 -2
- package/lib/relay-hooks/useFetchTrackingRef.js +0 -1
- package/lib/relay-hooks/useFragment.js +0 -1
- package/lib/relay-hooks/useFragmentNode.js +0 -1
- package/lib/relay-hooks/useIsMountedRef.js +0 -1
- package/lib/relay-hooks/useLazyLoadQuery.js +1 -15
- package/lib/relay-hooks/useLazyLoadQueryNode.js +0 -1
- package/lib/relay-hooks/useLoadMoreFunction.js +1 -2
- package/lib/relay-hooks/useMemoOperationDescriptor.js +0 -1
- package/lib/relay-hooks/useMemoVariables.js +0 -1
- package/lib/relay-hooks/useMutation.js +1 -2
- package/lib/relay-hooks/usePaginationFragment.js +15 -3
- package/lib/relay-hooks/usePreloadedQuery.js +1 -15
- package/lib/relay-hooks/useQueryLoader.js +1 -2
- package/lib/relay-hooks/useRefetchableFragment.js +14 -2
- package/lib/relay-hooks/useRefetchableFragmentNode.js +1 -2
- package/lib/relay-hooks/useRelayEnvironment.js +0 -1
- package/lib/relay-hooks/useStaticFragmentNodeWarning.js +0 -1
- package/lib/relay-hooks/useSubscribeToInvalidationState.js +0 -1
- package/lib/relay-hooks/useSubscription.js +0 -1
- package/multi-actor/useRelayActorEnvironment.js.flow +0 -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/readContext.js.flow +0 -2
- package/relay-hooks/EntryPointContainer.react.js.flow +2 -4
- package/relay-hooks/EntryPointTypes.flow.js.flow +30 -32
- package/relay-hooks/FragmentResource.js.flow +9 -11
- package/relay-hooks/HooksImplementation.js.flow +6 -8
- package/relay-hooks/InternalLogger.js.flow +0 -2
- package/relay-hooks/LRUCache.js.flow +0 -2
- package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +4 -6
- package/relay-hooks/MatchContainer.js.flow +5 -7
- package/relay-hooks/ProfilerContext.js.flow +0 -2
- package/relay-hooks/QueryResource.js.flow +4 -6
- package/relay-hooks/RelayEnvironmentProvider.js.flow +2 -4
- package/relay-hooks/SuspenseResource.js.flow +0 -2
- package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +3 -3
- package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +2 -2
- package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +4 -6
- package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +0 -2
- package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +4 -6
- package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +0 -2
- package/relay-hooks/__flowtests__/utils.js.flow +8 -10
- package/relay-hooks/preloadQuery_DEPRECATED.js.flow +4 -6
- package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +0 -2
- package/relay-hooks/react-cache/RelayReactCache.js.flow +0 -2
- package/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js.flow +22 -16
- package/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js.flow +297 -0
- package/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js.flow +134 -94
- package/relay-hooks/react-cache/useFragment_REACT_CACHE.js.flow +0 -2
- package/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js.flow +2 -4
- package/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js.flow +171 -0
- package/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js.flow +2 -4
- package/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js.flow +595 -0
- package/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js.flow +65 -0
- package/relay-hooks/useBlockingPaginationFragment.js.flow +4 -6
- package/relay-hooks/useClientQuery.js.flow +39 -0
- package/relay-hooks/useEntryPointLoader.js.flow +6 -8
- package/relay-hooks/useFetchTrackingRef.js.flow +2 -4
- package/relay-hooks/useFragment.js.flow +0 -2
- package/relay-hooks/useFragmentNode.js.flow +2 -4
- package/relay-hooks/useIsMountedRef.js.flow +1 -3
- package/relay-hooks/useLazyLoadQuery.js.flow +7 -30
- package/relay-hooks/useLazyLoadQueryNode.js.flow +2 -4
- package/relay-hooks/useLoadMoreFunction.js.flow +6 -8
- package/relay-hooks/useMemoOperationDescriptor.js.flow +0 -2
- package/relay-hooks/useMemoVariables.js.flow +0 -2
- package/relay-hooks/useMutation.js.flow +2 -4
- package/relay-hooks/usePaginationFragment.js.flow +44 -19
- package/relay-hooks/usePreloadedQuery.js.flow +5 -24
- package/relay-hooks/useQueryLoader.js.flow +4 -6
- package/relay-hooks/useRefetchableFragment.js.flow +32 -3
- package/relay-hooks/useRefetchableFragmentNode.js.flow +16 -18
- package/relay-hooks/useRelayEnvironment.js.flow +0 -2
- package/relay-hooks/useStaticFragmentNodeWarning.js.flow +0 -2
- package/relay-hooks/useSubscribeToInvalidationState.js.flow +0 -2
- package/relay-hooks/useSubscription.js.flow +0 -2
@@ -11,19 +11,17 @@
|
|
11
11
|
|
12
12
|
'use strict';
|
13
13
|
|
14
|
-
// flowlint ambiguous-object-type:error
|
15
|
-
|
16
14
|
import typeof useFragment from './useFragment';
|
17
|
-
import type {
|
18
|
-
import type {
|
15
|
+
import type {UsePaginationFragmentType} from './usePaginationFragment';
|
16
|
+
import type {UseRefetchableFragmentType} from './useRefetchableFragment';
|
19
17
|
|
20
18
|
const warning = require('warning');
|
21
19
|
|
22
|
-
type HooksImplementation = {
|
20
|
+
type HooksImplementation = {
|
23
21
|
useFragment: useFragment,
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
usePaginationFragment: UsePaginationFragmentType,
|
23
|
+
useRefetchableFragment: UseRefetchableFragmentType,
|
24
|
+
};
|
27
25
|
|
28
26
|
let implementation: HooksImplementation | null = null;
|
29
27
|
|
@@ -9,8 +9,6 @@
|
|
9
9
|
* @format
|
10
10
|
*/
|
11
11
|
|
12
|
-
// flowlint ambiguous-object-type:error
|
13
|
-
|
14
12
|
'use strict';
|
15
13
|
|
16
14
|
import type {
|
@@ -27,13 +25,13 @@ const React = require('react');
|
|
27
25
|
const {useContext, useEffect, useMemo} = require('react');
|
28
26
|
const {stableCopy} = require('relay-runtime');
|
29
27
|
|
30
|
-
type PreloadedEntryPoint<TEntryPointComponent> = $ReadOnly<{
|
28
|
+
type PreloadedEntryPoint<TEntryPointComponent> = $ReadOnly<{
|
31
29
|
entryPoints: React.ElementConfig<TEntryPointComponent>['entryPoints'],
|
32
30
|
extraProps: React.ElementConfig<TEntryPointComponent>['extraProps'],
|
33
31
|
getComponent: () => TEntryPointComponent,
|
34
32
|
queries: React.ElementConfig<TEntryPointComponent>['queries'],
|
35
33
|
rootModuleID: string,
|
36
|
-
|
34
|
+
}>;
|
37
35
|
|
38
36
|
type EntryPointContainerProps<
|
39
37
|
TEntryPointParams,
|
@@ -42,7 +40,7 @@ type EntryPointContainerProps<
|
|
42
40
|
TRuntimeProps,
|
43
41
|
TExtraProps,
|
44
42
|
> = $ReadOnly<
|
45
|
-
$ReadOnly<{
|
43
|
+
$ReadOnly<{
|
46
44
|
entryPoint: EntryPoint<
|
47
45
|
TEntryPointParams,
|
48
46
|
EntryPointComponent<
|
@@ -55,7 +53,7 @@ type EntryPointContainerProps<
|
|
55
53
|
entryPointParams: TEntryPointParams,
|
56
54
|
environmentProvider?: IEnvironmentProvider<EnvironmentProviderOptions>,
|
57
55
|
props: TRuntimeProps,
|
58
|
-
|
56
|
+
}>,
|
59
57
|
>;
|
60
58
|
|
61
59
|
function stableStringify(value: mixed): string {
|
@@ -9,8 +9,6 @@
|
|
9
9
|
* @format
|
10
10
|
*/
|
11
11
|
|
12
|
-
// flowlint ambiguous-object-type:error
|
13
|
-
|
14
12
|
'use strict';
|
15
13
|
|
16
14
|
const React = require('react');
|
@@ -87,7 +85,7 @@ const {useMemo} = React;
|
|
87
85
|
|
88
86
|
// Note: this type is intentionally non-exact, it is expected that the
|
89
87
|
// object may contain sibling fields.
|
90
|
-
type TypenameOnlyPointer = {
|
88
|
+
type TypenameOnlyPointer = {+__typename: string};
|
91
89
|
export type MatchPointer = {
|
92
90
|
+__fragmentPropName?: ?string,
|
93
91
|
+__module_component?: mixed,
|
@@ -95,12 +93,12 @@ export type MatchPointer = {
|
|
95
93
|
...
|
96
94
|
};
|
97
95
|
|
98
|
-
export type MatchContainerProps<TProps: {...}, TFallback: React.Node> = {
|
96
|
+
export type MatchContainerProps<TProps: {...}, TFallback: React.Node> = {
|
99
97
|
+fallback?: ?TFallback,
|
100
98
|
+loader: (module: mixed) => React.AbstractComponent<TProps>,
|
101
99
|
+match: ?MatchPointer | ?TypenameOnlyPointer,
|
102
100
|
+props?: TProps,
|
103
|
-
|
101
|
+
};
|
104
102
|
|
105
103
|
function MatchContainer<TProps: {...}, TFallback: React.Node | null>({
|
106
104
|
fallback,
|
@@ -150,11 +148,11 @@ function MatchContainer<TProps: {...}, TFallback: React.Node | null>({
|
|
150
148
|
// output of subscriptions already has a stable identity.
|
151
149
|
if (__fragmentPropName != null && __id != null && __fragments != null) {
|
152
150
|
const fragProps: {
|
153
|
-
[string]: {
|
151
|
+
[string]: {
|
154
152
|
__fragmentOwner: $FlowFixMe,
|
155
153
|
__fragments: $FlowFixMe,
|
156
154
|
__id: string,
|
157
|
-
|
155
|
+
},
|
158
156
|
} = {};
|
159
157
|
fragProps[__fragmentPropName] = {__id, __fragments, __fragmentOwner};
|
160
158
|
return fragProps;
|
@@ -9,8 +9,6 @@
|
|
9
9
|
* @format
|
10
10
|
*/
|
11
11
|
|
12
|
-
// flowlint ambiguous-object-type:error
|
13
|
-
|
14
12
|
// This contextual profiler can be used to wrap a react sub-tree. It will bind
|
15
13
|
// the RelayProfiler during the render phase of these components. Allows
|
16
14
|
// collecting metrics for a specific part of your application.
|
@@ -9,8 +9,6 @@
|
|
9
9
|
* @format
|
10
10
|
*/
|
11
11
|
|
12
|
-
// flowlint ambiguous-object-type:error
|
13
|
-
|
14
12
|
'use strict';
|
15
13
|
|
16
14
|
import type {Cache} from './LRUCache';
|
@@ -41,7 +39,7 @@ const DEFAULT_FETCH_POLICY = 'store-or-network';
|
|
41
39
|
export type QueryResource = QueryResourceImpl;
|
42
40
|
|
43
41
|
type QueryResourceCache = Cache<QueryResourceCacheEntry>;
|
44
|
-
type QueryResourceCacheEntry = {
|
42
|
+
type QueryResourceCacheEntry = {
|
45
43
|
+id: number,
|
46
44
|
+cacheIdentifier: string,
|
47
45
|
+operationAvailability: ?OperationAvailability,
|
@@ -56,17 +54,17 @@ type QueryResourceCacheEntry = {|
|
|
56
54
|
temporaryRetain(environment: IEnvironment): Disposable,
|
57
55
|
permanentRetain(environment: IEnvironment): Disposable,
|
58
56
|
releaseTemporaryRetain(): void,
|
59
|
-
|
57
|
+
};
|
60
58
|
export opaque type QueryResult: {
|
61
59
|
fragmentNode: ReaderFragment,
|
62
60
|
fragmentRef: mixed,
|
63
61
|
...
|
64
|
-
} = {
|
62
|
+
} = {
|
65
63
|
cacheIdentifier: string,
|
66
64
|
fragmentNode: ReaderFragment,
|
67
65
|
fragmentRef: mixed,
|
68
66
|
operation: OperationDescriptor,
|
69
|
-
|
67
|
+
};
|
70
68
|
|
71
69
|
const WEAKMAP_SUPPORTED = typeof WeakMap === 'function';
|
72
70
|
interface IMap<K, V> {
|
@@ -9,8 +9,6 @@
|
|
9
9
|
* @format
|
10
10
|
*/
|
11
11
|
|
12
|
-
// flowlint ambiguous-object-type:error
|
13
|
-
|
14
12
|
'use strict';
|
15
13
|
|
16
14
|
import type {IEnvironment} from 'relay-runtime';
|
@@ -24,13 +22,13 @@ const ReactRelayContext = require('react-relay/ReactRelayContext');
|
|
24
22
|
|
25
23
|
const {useMemo} = React;
|
26
24
|
|
27
|
-
type Props = $ReadOnly<{
|
25
|
+
type Props = $ReadOnly<{
|
28
26
|
children: React.Node,
|
29
27
|
environment: IEnvironment,
|
30
28
|
getEnvironmentForActor?: ?(
|
31
29
|
actorIdentifier: ActorIdentifier,
|
32
30
|
) => IActorEnvironment,
|
33
|
-
|
31
|
+
}>;
|
34
32
|
|
35
33
|
function RelayEnvironmentProvider(props: Props): React.Node {
|
36
34
|
const {children, environment, getEnvironmentForActor} = props;
|
@@ -17,15 +17,15 @@ import type {
|
|
17
17
|
EntryPointProps,
|
18
18
|
} from '../../EntryPointTypes.flow';
|
19
19
|
|
20
|
-
type MyComponentOtherProps = $ReadOnly<{
|
20
|
+
type MyComponentOtherProps = $ReadOnly<{
|
21
21
|
foo: string,
|
22
|
-
|
22
|
+
}>;
|
23
23
|
|
24
24
|
type MyComponentProps = EntryPointProps<{}, {}, MyComponentOtherProps, {}>;
|
25
25
|
|
26
26
|
const MyComponent = (_props: MyComponentProps) => null;
|
27
27
|
|
28
|
-
type PreloadParams = $ReadOnly<{
|
28
|
+
type PreloadParams = $ReadOnly<{}>;
|
29
29
|
|
30
30
|
type MyComponentEntryPointType = EntryPoint<PreloadParams, typeof MyComponent>;
|
31
31
|
|
@@ -27,9 +27,9 @@ type NestedEntrypointComponentProps = EntryPointProps<{}>;
|
|
27
27
|
const NestedEntrypointComponent = (_props: NestedEntrypointComponentProps) =>
|
28
28
|
null;
|
29
29
|
|
30
|
-
type NestedEntrypointPreloadParams = $ReadOnly<{
|
30
|
+
type NestedEntrypointPreloadParams = $ReadOnly<{
|
31
31
|
subEntrypointPreloadParam: string,
|
32
|
-
|
32
|
+
}>;
|
33
33
|
|
34
34
|
type NestedEntryPointType = EntryPoint<
|
35
35
|
NestedEntrypointPreloadParams,
|
@@ -9,8 +9,6 @@
|
|
9
9
|
* @format
|
10
10
|
*/
|
11
11
|
|
12
|
-
// flowlint ambiguous-object-type:error
|
13
|
-
|
14
12
|
import type {LoadMoreFn} from '../useLoadMoreFunction';
|
15
13
|
import type {
|
16
14
|
FetchFn,
|
@@ -36,14 +34,14 @@ type ExpectedReturnType<
|
|
36
34
|
TQuery: OperationType,
|
37
35
|
TQueryVariables,
|
38
36
|
TFragmentData,
|
39
|
-
> = {
|
37
|
+
> = {
|
40
38
|
data: TFragmentData,
|
41
39
|
loadNext: LoadMoreFn<TQuery>,
|
42
40
|
loadPrevious: LoadMoreFn<TQuery>,
|
43
41
|
hasNext: boolean,
|
44
42
|
hasPrevious: boolean,
|
45
43
|
refetch: FetchFn<TQueryVariables>,
|
46
|
-
|
44
|
+
};
|
47
45
|
|
48
46
|
/* eslint-disable react-hooks/rules-of-hooks */
|
49
47
|
|
@@ -103,8 +101,8 @@ refetch(variables, {
|
|
103
101
|
});
|
104
102
|
|
105
103
|
// LoadMore options
|
106
|
-
declare var extraVariables: {
|
107
|
-
declare var invalidVariables: {
|
104
|
+
declare var extraVariables: {nickname: string};
|
105
|
+
declare var invalidVariables: {foo: string};
|
108
106
|
|
109
107
|
const {loadNext} = useBlockingPaginationFragment<QueryOperation, _>(
|
110
108
|
fragmentInput,
|
@@ -9,8 +9,6 @@
|
|
9
9
|
* @format
|
10
10
|
*/
|
11
11
|
|
12
|
-
// flowlint ambiguous-object-type:error
|
13
|
-
|
14
12
|
import type {LoadMoreFn} from '../useLoadMoreFunction';
|
15
13
|
import type {
|
16
14
|
FetchFn,
|
@@ -36,7 +34,7 @@ type ExpectedReturnType<
|
|
36
34
|
TQuery: OperationType,
|
37
35
|
TQueryVariables,
|
38
36
|
TFragmentData,
|
39
|
-
> = {
|
37
|
+
> = {
|
40
38
|
data: TFragmentData,
|
41
39
|
loadNext: LoadMoreFn<TQuery>,
|
42
40
|
loadPrevious: LoadMoreFn<TQuery>,
|
@@ -45,7 +43,7 @@ type ExpectedReturnType<
|
|
45
43
|
isLoadingNext: boolean,
|
46
44
|
isLoadingPrevious: boolean,
|
47
45
|
refetch: FetchFn<TQueryVariables>,
|
48
|
-
|
46
|
+
};
|
49
47
|
|
50
48
|
/* eslint-disable react-hooks/rules-of-hooks */
|
51
49
|
|
@@ -105,8 +103,8 @@ refetch(variables, {
|
|
105
103
|
});
|
106
104
|
|
107
105
|
// LoadMore options
|
108
|
-
declare var extraVariables: {
|
109
|
-
declare var invalidVariables: {
|
106
|
+
declare var extraVariables: {nickname: string};
|
107
|
+
declare var invalidVariables: {foo: string};
|
110
108
|
|
111
109
|
const {loadNext} = usePaginationFragment<QueryOperation, _>(
|
112
110
|
fragmentInput,
|
@@ -9,8 +9,6 @@
|
|
9
9
|
* @format
|
10
10
|
*/
|
11
11
|
|
12
|
-
// flowlint ambiguous-object-type:error
|
13
|
-
|
14
12
|
'use strict';
|
15
13
|
|
16
14
|
import type {Disposable, Fragment, FragmentType} from 'relay-runtime';
|
@@ -28,18 +26,18 @@ export type Example_user$key = {
|
|
28
26
|
...
|
29
27
|
};
|
30
28
|
|
31
|
-
export type NonNullableData = {
|
29
|
+
export type NonNullableData = {
|
32
30
|
+id: string,
|
33
31
|
+count: number,
|
34
|
-
|
32
|
+
};
|
35
33
|
export type NullableData = ?NonNullableData;
|
36
34
|
export type NonNullablePluralData = $ReadOnlyArray<NonNullableData>;
|
37
35
|
export type NullablePluralData = ?$ReadOnlyArray<NonNullableData>;
|
38
36
|
|
39
|
-
export type AnotherNonNullableData = {
|
37
|
+
export type AnotherNonNullableData = {
|
40
38
|
+name: ?string,
|
41
39
|
+friends: ?number,
|
42
|
-
|
40
|
+
};
|
43
41
|
|
44
42
|
declare export var keyNonNullable: Example_user$key;
|
45
43
|
|
@@ -66,16 +64,16 @@ declare export var fragmentData: {
|
|
66
64
|
...
|
67
65
|
};
|
68
66
|
|
69
|
-
export type QueryOperation = {
|
67
|
+
export type QueryOperation = {
|
70
68
|
+variables: QueryVariables,
|
71
69
|
+response: {...},
|
72
|
-
|
70
|
+
};
|
73
71
|
|
74
|
-
export type QueryVariables = {
|
72
|
+
export type QueryVariables = {
|
75
73
|
id: string,
|
76
74
|
nickname: ?string,
|
77
75
|
name: string,
|
78
|
-
|
76
|
+
};
|
79
77
|
|
80
78
|
export type QueryVariablesSubset = {
|
81
79
|
id: string,
|
@@ -9,8 +9,6 @@
|
|
9
9
|
* @format
|
10
10
|
*/
|
11
11
|
|
12
|
-
// flowlint ambiguous-object-type:error
|
13
|
-
|
14
12
|
'use strict';
|
15
13
|
|
16
14
|
import type {
|
@@ -51,7 +49,7 @@ const pendingQueriesByEnvironment = WEAKMAP_SUPPORTED
|
|
51
49
|
: new Map();
|
52
50
|
|
53
51
|
type PendingQueryEntry =
|
54
|
-
| $ReadOnly<{
|
52
|
+
| $ReadOnly<{
|
55
53
|
cacheKey: string,
|
56
54
|
fetchKey: ?string | ?number,
|
57
55
|
fetchPolicy: PreloadFetchPolicy,
|
@@ -61,8 +59,8 @@ type PendingQueryEntry =
|
|
61
59
|
status: PreloadQueryStatus,
|
62
60
|
subject: ReplaySubject<GraphQLResponse>,
|
63
61
|
subscription: Subscription,
|
64
|
-
|
65
|
-
| $ReadOnly<{
|
62
|
+
}>
|
63
|
+
| $ReadOnly<{
|
66
64
|
cacheKey: string,
|
67
65
|
fetchKey: ?string | ?number,
|
68
66
|
fetchPolicy: PreloadFetchPolicy,
|
@@ -70,7 +68,7 @@ type PendingQueryEntry =
|
|
70
68
|
id: ?string,
|
71
69
|
name: string,
|
72
70
|
status: PreloadQueryStatus,
|
73
|
-
|
71
|
+
}>;
|
74
72
|
|
75
73
|
function preloadQuery<TQuery: OperationType, TEnvironmentProviderOptions>(
|
76
74
|
environment: IEnvironment,
|
@@ -9,8 +9,6 @@
|
|
9
9
|
* @format
|
10
10
|
*/
|
11
11
|
|
12
|
-
// flowlint ambiguous-object-type:error
|
13
|
-
|
14
12
|
'use strict';
|
15
13
|
|
16
14
|
import type {
|
@@ -34,10 +32,10 @@ const warning = require('warning');
|
|
34
32
|
|
35
33
|
type QueryCacheCommitable = () => () => void;
|
36
34
|
|
37
|
-
type QueryResult = {
|
35
|
+
type QueryResult = {
|
38
36
|
fragmentNode: ReaderFragment,
|
39
37
|
fragmentRef: mixed,
|
40
|
-
|
38
|
+
};
|
41
39
|
|
42
40
|
// Note that the status of a cache entry will be 'resolved' when partial
|
43
41
|
// rendering is allowed, even if a fetch is ongoing. The pending status
|
@@ -49,34 +47,42 @@ type QueryResult = {|
|
|
49
47
|
// before any components have mounted. It is unused when Legacy Timeouts
|
50
48
|
// mode is off.
|
51
49
|
type QueryCacheEntryStatus =
|
52
|
-
| {
|
50
|
+
| {
|
53
51
|
status: 'resolved',
|
54
52
|
result: QueryResult,
|
55
|
-
|
56
|
-
| {
|
53
|
+
}
|
54
|
+
| {
|
57
55
|
status: 'pending',
|
58
56
|
promise: Promise<void>,
|
59
|
-
|
60
|
-
| {
|
57
|
+
}
|
58
|
+
| {
|
61
59
|
status: 'rejected',
|
62
60
|
error: Error,
|
63
|
-
|
61
|
+
};
|
64
62
|
|
65
|
-
type QueryCacheEntry = {
|
63
|
+
type QueryCacheEntry = {
|
66
64
|
...QueryCacheEntryStatus,
|
67
65
|
onCommit: QueryCacheCommitable,
|
68
66
|
suspenseResource: SuspenseResource | null,
|
69
|
-
|
67
|
+
};
|
70
68
|
|
71
69
|
const DEFAULT_FETCH_POLICY = 'store-or-network';
|
72
70
|
|
71
|
+
const WEAKMAP_SUPPORTED = typeof WeakMap === 'function';
|
72
|
+
|
73
|
+
interface IMap<K, V> {
|
74
|
+
delete(key: K): boolean;
|
75
|
+
get(key: K): V | void;
|
76
|
+
set(key: K, value: V): IMap<K, V>;
|
77
|
+
}
|
78
|
+
|
73
79
|
type QueryCacheKey = string;
|
74
80
|
|
75
81
|
class QueryCache {
|
76
|
-
_map:
|
82
|
+
_map: IMap<IEnvironment, Map<QueryCacheKey, QueryCacheEntry>>;
|
77
83
|
|
78
84
|
constructor() {
|
79
|
-
this._map = new Map();
|
85
|
+
this._map = WEAKMAP_SUPPORTED ? new WeakMap() : new Map();
|
80
86
|
}
|
81
87
|
|
82
88
|
get(environment: IEnvironment, key: QueryCacheKey): QueryCacheEntry | void {
|
@@ -160,12 +166,12 @@ function makeInitialCacheEntry() {
|
|
160
166
|
function getQueryResultOrFetchQuery_REACT_CACHE(
|
161
167
|
environment: IEnvironment,
|
162
168
|
queryOperationDescriptor: OperationDescriptor,
|
163
|
-
options?: {
|
169
|
+
options?: {
|
164
170
|
fetchPolicy?: FetchPolicy,
|
165
171
|
renderPolicy?: RenderPolicy,
|
166
172
|
fetchKey?: ?string | ?number,
|
167
173
|
fetchObservable?: Observable<GraphQLResponse>,
|
168
|
-
|
174
|
+
},
|
169
175
|
): [QueryResult, QueryCacheCommitable] {
|
170
176
|
const fetchPolicy = options?.fetchPolicy ?? DEFAULT_FETCH_POLICY;
|
171
177
|
const renderPolicy =
|