react-relay 12.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 +10 -16
- package/ReactRelayFragmentMockRenderer.js.flow +1 -1
- package/ReactRelayLocalQueryRenderer.js.flow +6 -7
- package/ReactRelayPaginationContainer.js.flow +29 -39
- package/ReactRelayQueryFetcher.js.flow +9 -10
- package/ReactRelayQueryRenderer.js.flow +15 -15
- package/ReactRelayRefetchContainer.js.flow +24 -32
- package/ReactRelayTestMocker.js.flow +16 -14
- 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 +1 -2
- package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +1 -2
- 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 +13 -10
- package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer2.graphql.js.flow +13 -10
- package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtestQuery.graphql.js.flow +13 -8
- package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtest_viewer.graphql.js.flow +13 -10
- package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtestQuery.graphql.js.flow +13 -8
- package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtest_viewer.graphql.js.flow +13 -10
- package/__flowtests__/__generated__/RelayModernFlowtest_badref.graphql.js.flow +15 -12
- package/__flowtests__/__generated__/RelayModernFlowtest_notref.graphql.js.flow +15 -12
- package/__flowtests__/__generated__/RelayModernFlowtest_user.graphql.js.flow +13 -10
- package/__flowtests__/__generated__/RelayModernFlowtest_users.graphql.js.flow +13 -10
- package/assertFragmentMap.js.flow +2 -2
- package/buildReactRelayContainer.js.flow +11 -10
- package/getRootVariablesForFragments.js.flow +2 -4
- package/hooks.js +1 -1
- package/hooks.js.flow +3 -5
- package/index.js +1 -1
- package/index.js.flow +4 -6
- package/jest-react/enqueueTask.js.flow +1 -1
- package/jest-react/internalAct.js.flow +1 -2
- package/legacy.js +1 -1
- package/lib/ReactRelayFragmentContainer.js +4 -4
- package/lib/ReactRelayFragmentMockRenderer.js +2 -2
- package/lib/ReactRelayLocalQueryRenderer.js +7 -8
- package/lib/ReactRelayPaginationContainer.js +18 -22
- package/lib/ReactRelayQueryFetcher.js +2 -2
- package/lib/ReactRelayQueryRenderer.js +4 -4
- package/lib/ReactRelayRefetchContainer.js +12 -14
- package/lib/ReactRelayTestMocker.js +7 -8
- package/lib/RelayContext.js +3 -2
- package/lib/assertFragmentMap.js +2 -1
- package/lib/buildReactRelayContainer.js +7 -7
- package/lib/getRootVariablesForFragments.js +1 -2
- package/lib/hooks.js +5 -5
- package/lib/index.js +7 -7
- package/lib/jest-react/internalAct.js +2 -2
- package/lib/multi-actor/ActorChange.js +2 -2
- package/lib/multi-actor/useRelayActorEnvironment.js +2 -2
- package/lib/relay-hooks/EntryPointContainer.react.js +3 -3
- package/lib/relay-hooks/FragmentResource.js +241 -45
- package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +4 -4
- package/lib/relay-hooks/MatchContainer.js +1 -1
- package/lib/relay-hooks/QueryResource.js +83 -4
- package/lib/relay-hooks/SuspenseResource.js +130 -0
- package/lib/relay-hooks/loadQuery.js +8 -9
- package/lib/relay-hooks/preloadQuery_DEPRECATED.js +24 -10
- package/lib/relay-hooks/useBlockingPaginationFragment.js +2 -2
- 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 +2 -2
- package/lib/relay-hooks/useLazyLoadQuery.js +3 -3
- package/lib/relay-hooks/useLazyLoadQueryNode.js +4 -4
- package/lib/relay-hooks/useLoadMoreFunction.js +7 -9
- 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/usePreloadedQuery.js +5 -5
- package/lib/relay-hooks/useQueryLoader.js +4 -4
- package/lib/relay-hooks/useRefetchableFragmentNode.js +10 -12
- package/lib/relay-hooks/useRelayEnvironment.js +2 -2
- package/lib/relay-hooks/useStaticFragmentNodeWarning.js +2 -2
- package/lib/relay-hooks/useSubscribeToInvalidationState.js +2 -1
- package/multi-actor/ActorChange.js.flow +3 -4
- package/multi-actor/useRelayActorEnvironment.js.flow +5 -7
- 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 +8 -15
- package/relay-hooks/EntryPointTypes.flow.js.flow +18 -24
- package/relay-hooks/FragmentResource.js.flow +220 -34
- package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +32 -46
- package/relay-hooks/MatchContainer.js.flow +3 -2
- package/relay-hooks/QueryResource.js.flow +119 -17
- package/relay-hooks/RelayEnvironmentProvider.js.flow +9 -9
- 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 +22 -23
- package/relay-hooks/preloadQuery_DEPRECATED.js.flow +29 -13
- package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +6 -12
- package/relay-hooks/useBlockingPaginationFragment.js.flow +12 -13
- 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 +11 -13
- package/relay-hooks/useLoadMoreFunction.js.flow +19 -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 +37 -46
- package/relay-hooks/usePreloadedQuery.js.flow +13 -19
- package/relay-hooks/useQueryLoader.js.flow +13 -16
- package/relay-hooks/useRefetchableFragment.js.flow +7 -8
- package/relay-hooks/useRefetchableFragmentNode.js.flow +22 -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 +6 -7
@@ -13,24 +13,23 @@
|
|
13
13
|
|
14
14
|
'use strict';
|
15
15
|
|
16
|
-
|
16
|
+
import type {PreloadedQuery} from './EntryPointTypes.flow';
|
17
|
+
import type {
|
18
|
+
GraphQLTaggedNode,
|
19
|
+
OperationType,
|
20
|
+
RenderPolicy,
|
21
|
+
} from 'relay-runtime';
|
22
|
+
|
23
|
+
const {useTrackLoadQueryInRender} = require('./loadQuery');
|
17
24
|
const useLazyLoadQueryNode = require('./useLazyLoadQueryNode');
|
18
25
|
const useMemoOperationDescriptor = require('./useMemoOperationDescriptor');
|
19
26
|
const useRelayEnvironment = require('./useRelayEnvironment');
|
20
|
-
const
|
21
|
-
|
22
|
-
const {useTrackLoadQueryInRender} = require('./loadQuery');
|
27
|
+
const invariant = require('invariant');
|
23
28
|
const {useDebugValue} = require('react');
|
24
29
|
const {
|
25
30
|
__internal: {fetchQueryDeduped, fetchQuery},
|
26
31
|
} = require('relay-runtime');
|
27
|
-
|
28
|
-
import type {PreloadedQuery} from './EntryPointTypes.flow';
|
29
|
-
import type {
|
30
|
-
GraphQLTaggedNode,
|
31
|
-
OperationType,
|
32
|
-
RenderPolicy,
|
33
|
-
} from 'relay-runtime';
|
32
|
+
const warning = require('warning');
|
34
33
|
|
35
34
|
function usePreloadedQuery<TQuery: OperationType>(
|
36
35
|
gqlQuery: GraphQLTaggedNode,
|
@@ -38,19 +37,14 @@ function usePreloadedQuery<TQuery: OperationType>(
|
|
38
37
|
options?: {|
|
39
38
|
UNSTABLE_renderPolicy?: RenderPolicy,
|
40
39
|
|},
|
41
|
-
):
|
40
|
+
): TQuery['response'] {
|
42
41
|
// We need to use this hook in order to be able to track if
|
43
42
|
// loadQuery was called during render
|
44
43
|
useTrackLoadQueryInRender();
|
45
44
|
|
46
45
|
const environment = useRelayEnvironment();
|
47
|
-
const {
|
48
|
-
|
49
|
-
fetchPolicy,
|
50
|
-
source,
|
51
|
-
variables,
|
52
|
-
networkCacheConfig,
|
53
|
-
} = preloadedQuery;
|
46
|
+
const {fetchKey, fetchPolicy, source, variables, networkCacheConfig} =
|
47
|
+
preloadedQuery;
|
54
48
|
const operation = useMemoOperationDescriptor(
|
55
49
|
gqlQuery,
|
56
50
|
variables,
|
@@ -13,16 +13,9 @@
|
|
13
13
|
|
14
14
|
'use strict';
|
15
15
|
|
16
|
-
const useIsMountedRef = require('./useIsMountedRef');
|
17
|
-
const useRelayEnvironment = require('./useRelayEnvironment');
|
18
|
-
|
19
|
-
const {loadQuery, useTrackLoadQueryInRender} = require('./loadQuery');
|
20
|
-
const {useCallback, useEffect, useRef, useState} = require('react');
|
21
|
-
const {getRequest} = require('relay-runtime');
|
22
|
-
|
23
16
|
import type {
|
24
|
-
PreloadableConcreteRequest,
|
25
17
|
LoadQueryOptions,
|
18
|
+
PreloadableConcreteRequest,
|
26
19
|
PreloadedQuery,
|
27
20
|
} from './EntryPointTypes.flow';
|
28
21
|
import type {
|
@@ -31,8 +24,14 @@ import type {
|
|
31
24
|
OperationType,
|
32
25
|
} from 'relay-runtime';
|
33
26
|
|
27
|
+
const {loadQuery, useTrackLoadQueryInRender} = require('./loadQuery');
|
28
|
+
const useIsMountedRef = require('./useIsMountedRef');
|
29
|
+
const useRelayEnvironment = require('./useRelayEnvironment');
|
30
|
+
const {useCallback, useEffect, useRef, useState} = require('react');
|
31
|
+
const {getRequest} = require('relay-runtime');
|
32
|
+
|
34
33
|
export type LoaderFn<TQuery: OperationType> = (
|
35
|
-
variables:
|
34
|
+
variables: TQuery['variables'],
|
36
35
|
options?: UseQueryLoaderLoadQueryOptions,
|
37
36
|
) => void;
|
38
37
|
|
@@ -104,12 +103,10 @@ function useQueryLoader<TQuery: OperationType>(
|
|
104
103
|
PreloadedQuery<TQuery> | NullQueryReference,
|
105
104
|
>(() => initialQueryReferenceInternal);
|
106
105
|
|
107
|
-
const [
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
() => initialQueryReferenceInternal,
|
112
|
-
);
|
106
|
+
const [previousInitialQueryReference, setPreviousInitialQueryReference] =
|
107
|
+
useState<PreloadedQuery<TQuery> | NullQueryReference>(
|
108
|
+
() => initialQueryReferenceInternal,
|
109
|
+
);
|
113
110
|
|
114
111
|
if (initialQueryReferenceInternal !== previousInitialQueryReference) {
|
115
112
|
// Rendering the query reference makes it "managed" by this hook, so
|
@@ -131,7 +128,7 @@ function useQueryLoader<TQuery: OperationType>(
|
|
131
128
|
|
132
129
|
const queryLoaderCallback = useCallback(
|
133
130
|
(
|
134
|
-
variables:
|
131
|
+
variables: TQuery['variables'],
|
135
132
|
options?: ?UseQueryLoaderLoadQueryOptions,
|
136
133
|
) => {
|
137
134
|
const mergedOptions: ?UseQueryLoaderLoadQueryOptions =
|
@@ -13,19 +13,18 @@
|
|
13
13
|
|
14
14
|
'use strict';
|
15
15
|
|
16
|
-
const useRefetchableFragmentNode = require('./useRefetchableFragmentNode');
|
17
|
-
const useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
|
18
|
-
|
19
|
-
const {useDebugValue} = require('react');
|
20
|
-
const {getFragment} = require('relay-runtime');
|
21
|
-
|
22
16
|
import type {RefetchFnDynamic} from './useRefetchableFragmentNode';
|
23
17
|
import type {
|
18
|
+
FragmentType,
|
24
19
|
GraphQLTaggedNode,
|
25
20
|
OperationType,
|
26
|
-
FragmentReference,
|
27
21
|
} from 'relay-runtime';
|
28
22
|
|
23
|
+
const useRefetchableFragmentNode = require('./useRefetchableFragmentNode');
|
24
|
+
const useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
|
25
|
+
const {useDebugValue} = require('react');
|
26
|
+
const {getFragment} = require('relay-runtime');
|
27
|
+
|
29
28
|
type ReturnType<TQuery: OperationType, TKey: ?{+$data?: mixed, ...}> = [
|
30
29
|
// NOTE: This $Call ensures that the type of the returned data is either:
|
31
30
|
// - nullable if the provided ref type is nullable
|
@@ -41,7 +40,7 @@ type ReturnType<TQuery: OperationType, TKey: ?{+$data?: mixed, ...}> = [
|
|
41
40
|
|
42
41
|
function useRefetchableFragment<
|
43
42
|
TQuery: OperationType,
|
44
|
-
TKey: ?{+$data?: mixed, +$
|
43
|
+
TKey: ?{+$data?: mixed, +$fragmentSpreads: FragmentType, ...},
|
45
44
|
>(
|
46
45
|
fragmentInput: GraphQLTaggedNode,
|
47
46
|
fragmentRef: TKey,
|
@@ -13,17 +13,27 @@
|
|
13
13
|
|
14
14
|
'use strict';
|
15
15
|
|
16
|
-
|
16
|
+
import type {LoaderFn} from './useQueryLoader';
|
17
|
+
import type {
|
18
|
+
Disposable,
|
19
|
+
FetchPolicy,
|
20
|
+
IEnvironment,
|
21
|
+
OperationDescriptor,
|
22
|
+
OperationType,
|
23
|
+
ReaderFragment,
|
24
|
+
RenderPolicy,
|
25
|
+
Variables,
|
26
|
+
VariablesOf,
|
27
|
+
} from 'relay-runtime';
|
17
28
|
|
18
|
-
const
|
29
|
+
const {getFragmentResourceForEnvironment} = require('./FragmentResource');
|
30
|
+
const ProfilerContext = require('./ProfilerContext');
|
31
|
+
const {getQueryResourceForEnvironment} = require('./QueryResource');
|
19
32
|
const useFragmentNode = require('./useFragmentNode');
|
20
33
|
const useIsMountedRef = require('./useIsMountedRef');
|
21
34
|
const useQueryLoader = require('./useQueryLoader');
|
22
35
|
const useRelayEnvironment = require('./useRelayEnvironment');
|
23
|
-
const
|
24
|
-
|
25
|
-
const {getFragmentResourceForEnvironment} = require('./FragmentResource');
|
26
|
-
const {getQueryResourceForEnvironment} = require('./QueryResource');
|
36
|
+
const invariant = require('invariant');
|
27
37
|
const {useCallback, useContext, useReducer} = require('react');
|
28
38
|
const {
|
29
39
|
__internal: {fetchQuery},
|
@@ -33,19 +43,7 @@ const {
|
|
33
43
|
getSelector,
|
34
44
|
getValueAtPath,
|
35
45
|
} = require('relay-runtime');
|
36
|
-
|
37
|
-
import type {LoaderFn} from './useQueryLoader';
|
38
|
-
import type {
|
39
|
-
Disposable,
|
40
|
-
FetchPolicy,
|
41
|
-
IEnvironment,
|
42
|
-
OperationDescriptor,
|
43
|
-
OperationType,
|
44
|
-
ReaderFragment,
|
45
|
-
RenderPolicy,
|
46
|
-
Variables,
|
47
|
-
VariablesOf,
|
48
|
-
} from 'relay-runtime';
|
46
|
+
const warning = require('warning');
|
49
47
|
|
50
48
|
export type RefetchFn<
|
51
49
|
TQuery: OperationType,
|
@@ -176,11 +174,8 @@ function useRefetchableFragmentNode<
|
|
176
174
|
componentDisplayName: string,
|
177
175
|
): ReturnType<TQuery, TKey, InternalOptions> {
|
178
176
|
const parentEnvironment = useRelayEnvironment();
|
179
|
-
const {
|
180
|
-
|
181
|
-
fragmentRefPathInResponse,
|
182
|
-
identifierField,
|
183
|
-
} = getRefetchMetadata(fragmentNode, componentDisplayName);
|
177
|
+
const {refetchableRequest, fragmentRefPathInResponse, identifierField} =
|
178
|
+
getRefetchMetadata(fragmentNode, componentDisplayName);
|
184
179
|
const fragmentIdentifier = getFragmentIdentifier(
|
185
180
|
fragmentNode,
|
186
181
|
parentFragmentRef,
|
@@ -213,9 +208,8 @@ function useRefetchableFragmentNode<
|
|
213
208
|
const shouldReset =
|
214
209
|
environment !== mirroredEnvironment ||
|
215
210
|
fragmentIdentifier !== mirroredFragmentIdentifier;
|
216
|
-
const [queryRef, loadQuery, disposeQuery] =
|
217
|
-
refetchableRequest
|
218
|
-
);
|
211
|
+
const [queryRef, loadQuery, disposeQuery] =
|
212
|
+
useQueryLoader<TQuery>(refetchableRequest);
|
219
213
|
|
220
214
|
let fragmentRef = parentFragmentRef;
|
221
215
|
if (shouldReset) {
|
@@ -436,7 +430,6 @@ function useRefetchFunction<TQuery: OperationType>(
|
|
436
430
|
// all variables required by the fragment when calling `refetch()`.
|
437
431
|
// We fill in any variables not passed by the call to `refetch()` with the
|
438
432
|
// variables from the original parent fragment owner.
|
439
|
-
// $FlowFixMe[cannot-spread-interface]
|
440
433
|
const refetchVariables: VariablesOf<TQuery> = {
|
441
434
|
...(parentVariables: $FlowFixMe),
|
442
435
|
...fragmentVariables,
|
@@ -500,7 +493,7 @@ function useRefetchFunction<TQuery: OperationType>(
|
|
500
493
|
// - fragmentNode and parentFragmentRef are also captured by including
|
501
494
|
// fragmentIdentifier
|
502
495
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
503
|
-
[fragmentIdentifier, dispatch, disposeQuery, identifierValue],
|
496
|
+
[fragmentIdentifier, dispatch, disposeQuery, identifierValue, loadQuery],
|
504
497
|
);
|
505
498
|
}
|
506
499
|
|
@@ -513,7 +506,6 @@ if (__DEV__) {
|
|
513
506
|
environment: IEnvironment,
|
514
507
|
): ?DebugIDandTypename {
|
515
508
|
const {Record} = require('relay-runtime');
|
516
|
-
// $FlowFixMe[prop-missing]
|
517
509
|
const id = memoRefetchVariables?.id;
|
518
510
|
if (
|
519
511
|
fragmentRefPathInResponse.length !== 1 ||
|
@@ -13,13 +13,11 @@
|
|
13
13
|
|
14
14
|
'use strict';
|
15
15
|
|
16
|
-
|
16
|
+
import type {IEnvironment} from 'relay-runtime';
|
17
17
|
|
18
18
|
const invariant = require('invariant');
|
19
|
-
|
20
19
|
const {useContext} = require('react');
|
21
|
-
|
22
|
-
import type {IEnvironment} from 'relay-runtime';
|
20
|
+
const ReactRelayContext = require('react-relay/ReactRelayContext');
|
23
21
|
|
24
22
|
function useRelayEnvironment(): IEnvironment {
|
25
23
|
const context = useContext(ReactRelayContext);
|
@@ -13,11 +13,10 @@
|
|
13
13
|
|
14
14
|
'use strict';
|
15
15
|
|
16
|
-
|
16
|
+
import type {ReaderFragment} from 'relay-runtime';
|
17
17
|
|
18
18
|
const {useRef} = require('react');
|
19
|
-
|
20
|
-
import type {ReaderFragment} from 'relay-runtime';
|
19
|
+
const warning = require('warning');
|
21
20
|
|
22
21
|
function useStaticFragmentNodeWarning(
|
23
22
|
fragmentNode: ReaderFragment,
|
@@ -13,12 +13,11 @@
|
|
13
13
|
|
14
14
|
'use strict';
|
15
15
|
|
16
|
-
|
16
|
+
import type {DataID, Disposable, InvalidationState} from 'relay-runtime';
|
17
17
|
|
18
|
+
const useRelayEnvironment = require('./useRelayEnvironment');
|
18
19
|
const {useEffect, useRef} = require('react');
|
19
20
|
|
20
|
-
import type {DataID, Disposable, InvalidationState} from 'relay-runtime';
|
21
|
-
|
22
21
|
/**
|
23
22
|
* This hook subscribes a callback to the invalidation state of the given data
|
24
23
|
* ids.
|
@@ -35,9 +34,7 @@ function useSubscribeToInvalidationState(
|
|
35
34
|
const environment = useRelayEnvironment();
|
36
35
|
const disposableRef = useRef(null);
|
37
36
|
|
38
|
-
const stableDataIDs = Array.from(dataIDs)
|
39
|
-
.sort()
|
40
|
-
.join('');
|
37
|
+
const stableDataIDs = Array.from(dataIDs).sort().join('');
|
41
38
|
useEffect(() => {
|
42
39
|
const store = environment.getStore();
|
43
40
|
const invalidationState = store.lookupInvalidationState(dataIDs);
|
@@ -12,18 +12,17 @@
|
|
12
12
|
|
13
13
|
'use strict';
|
14
14
|
|
15
|
-
const useRelayEnvironment = require('./useRelayEnvironment');
|
16
|
-
|
17
|
-
const {useEffect} = require('react');
|
18
|
-
const {requestSubscription} = require('relay-runtime');
|
19
|
-
|
20
15
|
import type {
|
21
|
-
|
16
|
+
Disposable,
|
22
17
|
GraphQLSubscriptionConfig,
|
18
|
+
IEnvironment,
|
23
19
|
SubscriptionParameters,
|
24
|
-
Disposable,
|
25
20
|
} from 'relay-runtime';
|
26
21
|
|
22
|
+
const useRelayEnvironment = require('./useRelayEnvironment');
|
23
|
+
const {useEffect} = require('react');
|
24
|
+
const {requestSubscription} = require('relay-runtime');
|
25
|
+
|
27
26
|
type RequestSubscriptionFn<TSubscriptionParameters: SubscriptionParameters> = (
|
28
27
|
environment: IEnvironment,
|
29
28
|
config: GraphQLSubscriptionConfig<TSubscriptionParameters>,
|