react-relay 12.0.0 → 13.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +47 -0
  3. package/ReactRelayContainerUtils.js.flow +1 -1
  4. package/ReactRelayContext.js +2 -2
  5. package/ReactRelayContext.js.flow +3 -4
  6. package/ReactRelayFragmentContainer.js.flow +11 -17
  7. package/ReactRelayFragmentMockRenderer.js.flow +2 -2
  8. package/ReactRelayLocalQueryRenderer.js.flow +7 -8
  9. package/ReactRelayPaginationContainer.js.flow +30 -40
  10. package/ReactRelayQueryFetcher.js.flow +10 -11
  11. package/ReactRelayQueryRenderer.js.flow +16 -16
  12. package/ReactRelayQueryRendererContext.js.flow +1 -1
  13. package/ReactRelayRefetchContainer.js.flow +25 -33
  14. package/ReactRelayTestMocker.js.flow +17 -15
  15. package/ReactRelayTypes.js.flow +11 -11
  16. package/RelayContext.js.flow +4 -4
  17. package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +2 -3
  18. package/__flowtests__/ReactRelayPaginationContainer-flowtest.js.flow +2 -3
  19. package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +2 -3
  20. package/__flowtests__/RelayModern-flowtest.js.flow +79 -47
  21. package/__flowtests__/RelayModernFlowtest_badref.graphql.js.flow +6 -5
  22. package/__flowtests__/RelayModernFlowtest_notref.graphql.js.flow +6 -5
  23. package/__flowtests__/RelayModernFlowtest_user.graphql.js.flow +5 -4
  24. package/__flowtests__/RelayModernFlowtest_users.graphql.js.flow +5 -4
  25. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer.graphql.js.flow +14 -11
  26. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer2.graphql.js.flow +14 -11
  27. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtestQuery.graphql.js.flow +14 -9
  28. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtest_viewer.graphql.js.flow +14 -11
  29. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtestQuery.graphql.js.flow +14 -9
  30. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtest_viewer.graphql.js.flow +14 -11
  31. package/__flowtests__/__generated__/RelayModernFlowtest_badref.graphql.js.flow +16 -13
  32. package/__flowtests__/__generated__/RelayModernFlowtest_notref.graphql.js.flow +16 -13
  33. package/__flowtests__/__generated__/RelayModernFlowtest_user.graphql.js.flow +14 -11
  34. package/__flowtests__/__generated__/RelayModernFlowtest_users.graphql.js.flow +14 -11
  35. package/assertFragmentMap.js.flow +3 -3
  36. package/buildReactRelayContainer.js.flow +12 -11
  37. package/getRootVariablesForFragments.js.flow +3 -5
  38. package/hooks.js +2 -2
  39. package/hooks.js.flow +4 -6
  40. package/index.js +2 -2
  41. package/index.js.flow +5 -7
  42. package/isRelayEnvironment.js.flow +1 -1
  43. package/jest-react/enqueueTask.js.flow +2 -2
  44. package/jest-react/index.js.flow +1 -1
  45. package/jest-react/internalAct.js.flow +2 -4
  46. package/legacy.js +2 -2
  47. package/legacy.js.flow +1 -1
  48. package/lib/ReactRelayContainerUtils.js +1 -1
  49. package/lib/ReactRelayContext.js +1 -1
  50. package/lib/ReactRelayFragmentContainer.js +5 -5
  51. package/lib/ReactRelayFragmentMockRenderer.js +3 -3
  52. package/lib/ReactRelayLocalQueryRenderer.js +8 -9
  53. package/lib/ReactRelayPaginationContainer.js +19 -23
  54. package/lib/ReactRelayQueryFetcher.js +3 -3
  55. package/lib/ReactRelayQueryRenderer.js +5 -5
  56. package/lib/ReactRelayQueryRendererContext.js +1 -1
  57. package/lib/ReactRelayRefetchContainer.js +13 -15
  58. package/lib/ReactRelayTestMocker.js +8 -9
  59. package/lib/ReactRelayTypes.js +1 -1
  60. package/lib/RelayContext.js +4 -3
  61. package/lib/assertFragmentMap.js +3 -2
  62. package/lib/buildReactRelayContainer.js +8 -8
  63. package/lib/getRootVariablesForFragments.js +2 -3
  64. package/lib/hooks.js +6 -6
  65. package/lib/index.js +8 -8
  66. package/lib/isRelayEnvironment.js +1 -1
  67. package/lib/jest-react/enqueueTask.js +1 -1
  68. package/lib/jest-react/internalAct.js +3 -4
  69. package/lib/legacy.js +1 -1
  70. package/lib/multi-actor/ActorChange.js +3 -3
  71. package/lib/multi-actor/index.js +1 -1
  72. package/lib/multi-actor/useRelayActorEnvironment.js +3 -3
  73. package/lib/readContext.js +1 -1
  74. package/lib/relay-hooks/EntryPointContainer.react.js +4 -4
  75. package/lib/relay-hooks/EntryPointTypes.flow.js +1 -1
  76. package/lib/relay-hooks/FragmentResource.js +242 -46
  77. package/lib/relay-hooks/InternalLogger.js +1 -1
  78. package/lib/relay-hooks/LRUCache.js +1 -1
  79. package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +5 -5
  80. package/lib/relay-hooks/MatchContainer.js +2 -2
  81. package/lib/relay-hooks/ProfilerContext.js +1 -1
  82. package/lib/relay-hooks/QueryResource.js +84 -5
  83. package/lib/relay-hooks/RelayEnvironmentProvider.js +1 -1
  84. package/lib/relay-hooks/SuspenseResource.js +130 -0
  85. package/lib/relay-hooks/loadEntryPoint.js +1 -1
  86. package/lib/relay-hooks/loadQuery.js +9 -10
  87. package/lib/relay-hooks/preloadQuery_DEPRECATED.js +25 -11
  88. package/lib/relay-hooks/prepareEntryPoint_DEPRECATED.js +1 -1
  89. package/lib/relay-hooks/useBlockingPaginationFragment.js +3 -3
  90. package/lib/relay-hooks/useEntryPointLoader.js +3 -3
  91. package/lib/relay-hooks/useFetchTrackingRef.js +3 -2
  92. package/lib/relay-hooks/useFragment.js +7 -7
  93. package/lib/relay-hooks/useFragmentNode.js +5 -5
  94. package/lib/relay-hooks/useIsMountedRef.js +1 -1
  95. package/lib/relay-hooks/useIsOperationNodeActive.js +3 -3
  96. package/lib/relay-hooks/useIsParentQueryActive.js +1 -1
  97. package/lib/relay-hooks/useLazyLoadQuery.js +4 -4
  98. package/lib/relay-hooks/useLazyLoadQueryNode.js +5 -5
  99. package/lib/relay-hooks/useLoadMoreFunction.js +8 -10
  100. package/lib/relay-hooks/useMemoOperationDescriptor.js +3 -3
  101. package/lib/relay-hooks/useMemoVariables.js +3 -3
  102. package/lib/relay-hooks/useMutation.js +18 -7
  103. package/lib/relay-hooks/usePaginationFragment.js +1 -1
  104. package/lib/relay-hooks/usePreloadedQuery.js +6 -6
  105. package/lib/relay-hooks/useQueryLoader.js +5 -5
  106. package/lib/relay-hooks/useRefetchableFragment.js +1 -1
  107. package/lib/relay-hooks/useRefetchableFragmentNode.js +11 -13
  108. package/lib/relay-hooks/useRelayEnvironment.js +3 -3
  109. package/lib/relay-hooks/useStaticFragmentNodeWarning.js +3 -3
  110. package/lib/relay-hooks/useSubscribeToInvalidationState.js +3 -2
  111. package/lib/relay-hooks/useSubscription.js +1 -1
  112. package/multi-actor/ActorChange.js.flow +4 -5
  113. package/multi-actor/index.js.flow +1 -1
  114. package/multi-actor/useRelayActorEnvironment.js.flow +6 -8
  115. package/package.json +3 -3
  116. package/react-relay-hooks.js +2 -2
  117. package/react-relay-hooks.min.js +3 -3
  118. package/react-relay-legacy.js +2 -2
  119. package/react-relay-legacy.min.js +3 -3
  120. package/react-relay.js +2 -2
  121. package/react-relay.min.js +3 -3
  122. package/readContext.js.flow +1 -1
  123. package/relay-hooks/EntryPointContainer.react.js.flow +9 -16
  124. package/relay-hooks/EntryPointTypes.flow.js.flow +19 -25
  125. package/relay-hooks/FragmentResource.js.flow +221 -35
  126. package/relay-hooks/InternalLogger.js.flow +1 -1
  127. package/relay-hooks/LRUCache.js.flow +1 -1
  128. package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +33 -47
  129. package/relay-hooks/MatchContainer.js.flow +4 -3
  130. package/relay-hooks/ProfilerContext.js.flow +1 -1
  131. package/relay-hooks/QueryResource.js.flow +120 -18
  132. package/relay-hooks/RelayEnvironmentProvider.js.flow +10 -10
  133. package/relay-hooks/SuspenseResource.js.flow +115 -0
  134. package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +5 -4
  135. package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +2 -2
  136. package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_user.graphql.js.flow +59 -0
  137. package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_users.graphql.js.flow +61 -0
  138. package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +11 -10
  139. package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +55 -32
  140. package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +11 -10
  141. package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +11 -10
  142. package/relay-hooks/__flowtests__/utils.js.flow +21 -32
  143. package/relay-hooks/loadEntryPoint.js.flow +7 -13
  144. package/relay-hooks/loadQuery.js.flow +23 -24
  145. package/relay-hooks/preloadQuery_DEPRECATED.js.flow +30 -14
  146. package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +7 -13
  147. package/relay-hooks/useBlockingPaginationFragment.js.flow +13 -14
  148. package/relay-hooks/useEntryPointLoader.js.flow +8 -11
  149. package/relay-hooks/useFetchTrackingRef.js.flow +3 -3
  150. package/relay-hooks/useFragment.js.flow +31 -62
  151. package/relay-hooks/useFragmentNode.js.flow +6 -8
  152. package/relay-hooks/useIsMountedRef.js.flow +1 -1
  153. package/relay-hooks/useIsOperationNodeActive.js.flow +4 -6
  154. package/relay-hooks/useIsParentQueryActive.js.flow +4 -5
  155. package/relay-hooks/useLazyLoadQuery.js.flow +14 -16
  156. package/relay-hooks/useLazyLoadQueryNode.js.flow +12 -14
  157. package/relay-hooks/useLoadMoreFunction.js.flow +20 -28
  158. package/relay-hooks/useMemoOperationDescriptor.js.flow +6 -8
  159. package/relay-hooks/useMemoVariables.js.flow +7 -7
  160. package/relay-hooks/useMutation.js.flow +27 -27
  161. package/relay-hooks/usePaginationFragment.js.flow +38 -47
  162. package/relay-hooks/usePreloadedQuery.js.flow +14 -20
  163. package/relay-hooks/useQueryLoader.js.flow +14 -17
  164. package/relay-hooks/useRefetchableFragment.js.flow +8 -9
  165. package/relay-hooks/useRefetchableFragmentNode.js.flow +23 -31
  166. package/relay-hooks/useRelayEnvironment.js.flow +3 -5
  167. package/relay-hooks/useStaticFragmentNodeWarning.js.flow +3 -4
  168. package/relay-hooks/useSubscribeToInvalidationState.js.flow +4 -7
  169. package/relay-hooks/useSubscription.js.flow +7 -8
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
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.
@@ -13,10 +13,19 @@
13
13
 
14
14
  'use strict';
15
15
 
16
+ import type {LoadMoreFn, UseLoadMoreFunctionArgs} from './useLoadMoreFunction';
17
+ import type {RefetchFnDynamic} from './useRefetchableFragmentNode';
18
+ import type {
19
+ FragmentType,
20
+ GraphQLResponse,
21
+ GraphQLTaggedNode,
22
+ Observer,
23
+ OperationType,
24
+ } from 'relay-runtime';
25
+
16
26
  const useLoadMoreFunction = require('./useLoadMoreFunction');
17
27
  const useRefetchableFragmentNode = require('./useRefetchableFragmentNode');
18
28
  const useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
19
-
20
29
  const {useCallback, useDebugValue, useState} = require('react');
21
30
  const {
22
31
  getFragment,
@@ -24,16 +33,6 @@ const {
24
33
  getPaginationMetadata,
25
34
  } = require('relay-runtime');
26
35
 
27
- import type {LoadMoreFn, UseLoadMoreFunctionArgs} from './useLoadMoreFunction';
28
- import type {RefetchFnDynamic} from './useRefetchableFragmentNode';
29
- import type {
30
- GraphQLResponse,
31
- GraphQLTaggedNode,
32
- Observer,
33
- OperationType,
34
- FragmentReference,
35
- } from 'relay-runtime';
36
-
37
36
  export type ReturnType<TQuery: OperationType, TKey, TFragmentData> = {|
38
37
  data: TFragmentData,
39
38
  loadNext: LoadMoreFn<TQuery>,
@@ -47,7 +46,7 @@ export type ReturnType<TQuery: OperationType, TKey, TFragmentData> = {|
47
46
 
48
47
  function usePaginationFragment<
49
48
  TQuery: OperationType,
50
- TKey: ?{+$data?: mixed, +$fragmentRefs: FragmentReference, ...},
49
+ TKey: ?{+$data?: mixed, +$fragmentSpreads: FragmentType, ...},
51
50
  >(
52
51
  fragmentInput: GraphQLTaggedNode,
53
52
  parentFragmentRef: TKey,
@@ -85,42 +84,34 @@ function usePaginationFragment<
85
84
  const fragmentIdentifier = getFragmentIdentifier(fragmentNode, fragmentRef);
86
85
 
87
86
  // Backward pagination
88
- const [
89
- loadPrevious,
90
- hasPrevious,
91
- isLoadingPrevious,
92
- disposeFetchPrevious,
93
- ] = useLoadMore<TQuery>({
94
- componentDisplayName,
95
- connectionPathInFragmentData,
96
- direction: 'backward',
97
- fragmentData,
98
- fragmentIdentifier,
99
- fragmentNode,
100
- fragmentRef,
101
- identifierField,
102
- paginationMetadata,
103
- paginationRequest,
104
- });
87
+ const [loadPrevious, hasPrevious, isLoadingPrevious, disposeFetchPrevious] =
88
+ useLoadMore<TQuery>({
89
+ componentDisplayName,
90
+ connectionPathInFragmentData,
91
+ direction: 'backward',
92
+ fragmentData,
93
+ fragmentIdentifier,
94
+ fragmentNode,
95
+ fragmentRef,
96
+ identifierField,
97
+ paginationMetadata,
98
+ paginationRequest,
99
+ });
105
100
 
106
101
  // Forward pagination
107
- const [
108
- loadNext,
109
- hasNext,
110
- isLoadingNext,
111
- disposeFetchNext,
112
- ] = useLoadMore<TQuery>({
113
- componentDisplayName,
114
- connectionPathInFragmentData,
115
- direction: 'forward',
116
- fragmentData,
117
- fragmentIdentifier,
118
- fragmentNode,
119
- fragmentRef,
120
- identifierField,
121
- paginationMetadata,
122
- paginationRequest,
123
- });
102
+ const [loadNext, hasNext, isLoadingNext, disposeFetchNext] =
103
+ useLoadMore<TQuery>({
104
+ componentDisplayName,
105
+ connectionPathInFragmentData,
106
+ direction: 'forward',
107
+ fragmentData,
108
+ fragmentIdentifier,
109
+ fragmentNode,
110
+ fragmentRef,
111
+ identifierField,
112
+ paginationMetadata,
113
+ paginationRequest,
114
+ });
124
115
 
125
116
  const refetchPagination: RefetchFnDynamic<TQuery, TKey> = useCallback(
126
117
  (variables, options) => {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
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.
@@ -13,24 +13,23 @@
13
13
 
14
14
  'use strict';
15
15
 
16
- const invariant = require('invariant');
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 warning = require('warning');
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
- ): $ElementType<TQuery, 'response'> {
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
- fetchKey,
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,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
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.
@@ -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: $ElementType<TQuery, '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
- previousInitialQueryReference,
109
- setPreviousInitialQueryReference,
110
- ] = useState<PreloadedQuery<TQuery> | NullQueryReference>(
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: $ElementType<TQuery, 'variables'>,
131
+ variables: TQuery['variables'],
135
132
  options?: ?UseQueryLoaderLoadQueryOptions,
136
133
  ) => {
137
134
  const mergedOptions: ?UseQueryLoaderLoadQueryOptions =
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
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.
@@ -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, +$fragmentRefs: FragmentReference, ...},
43
+ TKey: ?{+$data?: mixed, +$fragmentSpreads: FragmentType, ...},
45
44
  >(
46
45
  fragmentInput: GraphQLTaggedNode,
47
46
  fragmentRef: TKey,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
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.
@@ -13,17 +13,27 @@
13
13
 
14
14
  'use strict';
15
15
 
16
- const ProfilerContext = require('./ProfilerContext');
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 invariant = require('invariant');
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 warning = require('warning');
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
- refetchableRequest,
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] = useQueryLoader<TQuery>(
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 ||
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
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.
@@ -13,13 +13,11 @@
13
13
 
14
14
  'use strict';
15
15
 
16
- const ReactRelayContext = require('react-relay/ReactRelayContext');
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);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
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.
@@ -13,11 +13,10 @@
13
13
 
14
14
  'use strict';
15
15
 
16
- const warning = require('warning');
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,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
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.
@@ -13,12 +13,11 @@
13
13
 
14
14
  'use strict';
15
15
 
16
- const useRelayEnvironment = require('./useRelayEnvironment');
16
+ import type {DataID, Disposable} 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);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
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.
@@ -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
- IEnvironment,
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>,