react-relay 14.1.0 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/ReactRelayContainerUtils.js.flow +1 -0
  2. package/ReactRelayContext.js +1 -1
  3. package/ReactRelayContext.js.flow +1 -0
  4. package/ReactRelayFragmentContainer.js.flow +6 -2
  5. package/ReactRelayFragmentMockRenderer.js.flow +1 -0
  6. package/ReactRelayLocalQueryRenderer.js.flow +5 -3
  7. package/ReactRelayPaginationContainer.js.flow +21 -12
  8. package/ReactRelayQueryFetcher.js.flow +19 -5
  9. package/ReactRelayQueryRenderer.js.flow +32 -1
  10. package/ReactRelayQueryRendererContext.js.flow +1 -0
  11. package/ReactRelayRefetchContainer.js.flow +9 -5
  12. package/ReactRelayTestMocker.js.flow +3 -1
  13. package/ReactRelayTypes.js.flow +1 -0
  14. package/RelayContext.js.flow +1 -0
  15. package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +2 -1
  16. package/__flowtests__/ReactRelayPaginationContainer-flowtest.js.flow +1 -0
  17. package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +1 -0
  18. package/__flowtests__/RelayModern-flowtest.js.flow +1 -0
  19. package/__flowtests__/RelayModernFlowtest_badref.graphql.js.flow +1 -0
  20. package/__flowtests__/RelayModernFlowtest_notref.graphql.js.flow +1 -0
  21. package/__flowtests__/RelayModernFlowtest_user.graphql.js.flow +1 -0
  22. package/__flowtests__/RelayModernFlowtest_users.graphql.js.flow +1 -0
  23. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer.graphql.js.flow +3 -1
  24. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer2.graphql.js.flow +3 -1
  25. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtestQuery.graphql.js.flow +4 -2
  26. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtest_viewer.graphql.js.flow +3 -1
  27. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtestQuery.graphql.js.flow +4 -2
  28. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtest_viewer.graphql.js.flow +3 -1
  29. package/__flowtests__/__generated__/RelayModernFlowtest_badref.graphql.js.flow +4 -2
  30. package/__flowtests__/__generated__/RelayModernFlowtest_notref.graphql.js.flow +4 -2
  31. package/__flowtests__/__generated__/RelayModernFlowtest_user.graphql.js.flow +3 -1
  32. package/__flowtests__/__generated__/RelayModernFlowtest_users.graphql.js.flow +3 -1
  33. package/assertFragmentMap.js.flow +1 -0
  34. package/buildReactRelayContainer.js.flow +7 -5
  35. package/getRootVariablesForFragments.js.flow +1 -1
  36. package/hooks.js +1 -1
  37. package/hooks.js.flow +4 -0
  38. package/index.js +1 -1
  39. package/index.js.flow +4 -0
  40. package/isRelayEnvironment.js.flow +1 -0
  41. package/jest-react/enqueueTask.js.flow +1 -1
  42. package/jest-react/index.js.flow +1 -1
  43. package/jest-react/internalAct.js.flow +1 -1
  44. package/legacy.js +1 -1
  45. package/legacy.js.flow +1 -0
  46. package/lib/ReactRelayContainerUtils.js +2 -2
  47. package/lib/ReactRelayContext.js +3 -3
  48. package/lib/ReactRelayFragmentContainer.js +39 -66
  49. package/lib/ReactRelayFragmentMockRenderer.js +2 -3
  50. package/lib/ReactRelayLocalQueryRenderer.js +18 -30
  51. package/lib/ReactRelayPaginationContainer.js +66 -159
  52. package/lib/ReactRelayQueryFetcher.js +48 -74
  53. package/lib/ReactRelayQueryRenderer.js +62 -82
  54. package/lib/ReactRelayQueryRendererContext.js +2 -1
  55. package/lib/ReactRelayRefetchContainer.js +52 -99
  56. package/lib/ReactRelayTestMocker.js +32 -66
  57. package/lib/ReactRelayTypes.js +2 -0
  58. package/lib/RelayContext.js +4 -6
  59. package/lib/assertFragmentMap.js +3 -4
  60. package/lib/buildReactRelayContainer.js +10 -25
  61. package/lib/getRootVariablesForFragments.js +5 -8
  62. package/lib/hooks.js +5 -17
  63. package/lib/index.js +5 -24
  64. package/lib/isRelayEnvironment.js +5 -3
  65. package/lib/jest-react/enqueueTask.js +5 -9
  66. package/lib/jest-react/index.js +0 -1
  67. package/lib/jest-react/internalAct.js +9 -20
  68. package/lib/legacy.js +2 -7
  69. package/lib/multi-actor/ActorChange.js +2 -5
  70. package/lib/multi-actor/index.js +2 -1
  71. package/lib/multi-actor/useRelayActorEnvironment.js +4 -7
  72. package/lib/relay-hooks/EntryPointContainer.react.js +9 -14
  73. package/lib/relay-hooks/EntryPointTypes.flow.js +5 -2
  74. package/lib/relay-hooks/FragmentResource.js +102 -196
  75. package/lib/relay-hooks/HooksImplementation.js +2 -5
  76. package/lib/relay-hooks/InternalLogger.js +2 -2
  77. package/lib/relay-hooks/LRUCache.js +2 -19
  78. package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +33 -53
  79. package/lib/relay-hooks/MatchContainer.js +14 -22
  80. package/lib/relay-hooks/ProfilerContext.js +3 -2
  81. package/lib/relay-hooks/QueryResource.js +30 -99
  82. package/lib/relay-hooks/RelayEnvironmentProvider.js +5 -8
  83. package/lib/relay-hooks/SuspenseResource.js +8 -31
  84. package/lib/relay-hooks/loadEntryPoint.js +19 -31
  85. package/lib/relay-hooks/loadQuery.js +41 -77
  86. package/lib/relay-hooks/preloadQuery_DEPRECATED.js +10 -35
  87. package/lib/relay-hooks/prepareEntryPoint_DEPRECATED.js +9 -14
  88. package/lib/relay-hooks/react-cache/RelayReactCache.js +7 -11
  89. package/lib/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js +24 -78
  90. package/lib/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js +23 -56
  91. package/lib/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js +65 -143
  92. package/lib/relay-hooks/react-cache/useFragment_REACT_CACHE.js +5 -14
  93. package/lib/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js +17 -23
  94. package/lib/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js +73 -74
  95. package/lib/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js +24 -38
  96. package/lib/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js +60 -102
  97. package/lib/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js +7 -15
  98. package/lib/relay-hooks/useBlockingPaginationFragment.js +71 -92
  99. package/lib/relay-hooks/useClientQuery.js +3 -6
  100. package/lib/relay-hooks/useEntryPointLoader.js +17 -36
  101. package/lib/relay-hooks/useFetchTrackingRef.js +10 -11
  102. package/lib/relay-hooks/useFragment.js +8 -18
  103. package/lib/relay-hooks/useFragmentNode.js +20 -31
  104. package/lib/relay-hooks/useIsMountedRef.js +4 -5
  105. package/lib/relay-hooks/useIsOperationNodeActive.js +8 -20
  106. package/lib/relay-hooks/useIsParentQueryActive.js +3 -6
  107. package/lib/relay-hooks/useLazyLoadQuery.js +6 -9
  108. package/lib/relay-hooks/useLazyLoadQueryNode.js +23 -33
  109. package/lib/relay-hooks/useLoadMoreFunction.js +45 -76
  110. package/lib/relay-hooks/useMemoOperationDescriptor.js +6 -14
  111. package/lib/relay-hooks/useMemoVariables.js +15 -33
  112. package/lib/relay-hooks/useMutation.js +8 -25
  113. package/lib/relay-hooks/usePaginationFragment.js +61 -76
  114. package/lib/relay-hooks/usePreloadedQuery.js +12 -29
  115. package/lib/relay-hooks/useQueryLoader.js +23 -47
  116. package/lib/relay-hooks/useRefetchableFragment.js +8 -18
  117. package/lib/relay-hooks/useRefetchableFragmentNode.js +64 -107
  118. package/lib/relay-hooks/useRelayEnvironment.js +4 -7
  119. package/lib/relay-hooks/useStaticFragmentNodeWarning.js +4 -7
  120. package/lib/relay-hooks/useSubscribeToInvalidationState.js +8 -8
  121. package/lib/relay-hooks/useSubscription.js +5 -9
  122. package/lib/relay-hooks/useUnsafeRef_DEPRECATED.js +29 -0
  123. package/multi-actor/ActorChange.js.flow +1 -1
  124. package/multi-actor/index.js.flow +1 -1
  125. package/multi-actor/useRelayActorEnvironment.js.flow +2 -2
  126. package/package.json +2 -2
  127. package/react-relay-hooks.js +2 -2
  128. package/react-relay-hooks.min.js +2 -2
  129. package/react-relay-legacy.js +2 -2
  130. package/react-relay-legacy.min.js +2 -2
  131. package/react-relay.js +2 -2
  132. package/react-relay.min.js +2 -2
  133. package/relay-hooks/EntryPointContainer.react.js.flow +1 -1
  134. package/relay-hooks/EntryPointTypes.flow.js.flow +7 -5
  135. package/relay-hooks/FragmentResource.js.flow +34 -8
  136. package/relay-hooks/HooksImplementation.js.flow +1 -1
  137. package/relay-hooks/InternalLogger.js.flow +1 -1
  138. package/relay-hooks/LRUCache.js.flow +1 -1
  139. package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +15 -8
  140. package/relay-hooks/MatchContainer.js.flow +1 -1
  141. package/relay-hooks/ProfilerContext.js.flow +1 -1
  142. package/relay-hooks/QueryResource.js.flow +25 -5
  143. package/relay-hooks/RelayEnvironmentProvider.js.flow +2 -2
  144. package/relay-hooks/SuspenseResource.js.flow +1 -1
  145. package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +3 -1
  146. package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +2 -2
  147. package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_user.graphql.js.flow +3 -1
  148. package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_users.graphql.js.flow +3 -1
  149. package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +35 -33
  150. package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +1 -1
  151. package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +33 -32
  152. package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +18 -18
  153. package/relay-hooks/__flowtests__/utils.js.flow +13 -2
  154. package/relay-hooks/loadEntryPoint.js.flow +11 -6
  155. package/relay-hooks/loadQuery.js.flow +11 -7
  156. package/relay-hooks/preloadQuery_DEPRECATED.js.flow +5 -6
  157. package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +13 -8
  158. package/relay-hooks/react-cache/RelayReactCache.js.flow +1 -1
  159. package/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js.flow +4 -4
  160. package/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js.flow +3 -3
  161. package/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js.flow +4 -4
  162. package/relay-hooks/react-cache/useFragment_REACT_CACHE.js.flow +1 -1
  163. package/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js.flow +1 -1
  164. package/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js.flow +41 -22
  165. package/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js.flow +1 -2
  166. package/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js.flow +11 -5
  167. package/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js.flow +2 -2
  168. package/relay-hooks/useBlockingPaginationFragment.js.flow +85 -56
  169. package/relay-hooks/useClientQuery.js.flow +1 -1
  170. package/relay-hooks/useEntryPointLoader.js.flow +10 -6
  171. package/relay-hooks/useFetchTrackingRef.js.flow +5 -4
  172. package/relay-hooks/useFragment.js.flow +2 -2
  173. package/relay-hooks/useFragmentNode.js.flow +5 -4
  174. package/relay-hooks/useIsMountedRef.js.flow +1 -1
  175. package/relay-hooks/useIsOperationNodeActive.js.flow +1 -1
  176. package/relay-hooks/useIsParentQueryActive.js.flow +1 -1
  177. package/relay-hooks/useLazyLoadQuery.js.flow +2 -2
  178. package/relay-hooks/useLazyLoadQueryNode.js.flow +2 -2
  179. package/relay-hooks/useLoadMoreFunction.js.flow +14 -9
  180. package/relay-hooks/useMemoOperationDescriptor.js.flow +3 -3
  181. package/relay-hooks/useMemoVariables.js.flow +13 -29
  182. package/relay-hooks/useMutation.js.flow +4 -4
  183. package/relay-hooks/usePaginationFragment.js.flow +53 -46
  184. package/relay-hooks/usePreloadedQuery.js.flow +47 -22
  185. package/relay-hooks/useQueryLoader.js.flow +85 -22
  186. package/relay-hooks/useRefetchableFragment.js.flow +64 -33
  187. package/relay-hooks/useRefetchableFragmentNode.js.flow +10 -4
  188. package/relay-hooks/useRelayEnvironment.js.flow +2 -2
  189. package/relay-hooks/useStaticFragmentNodeWarning.js.flow +3 -3
  190. package/relay-hooks/useSubscribeToInvalidationState.js.flow +2 -2
  191. package/relay-hooks/useSubscription.js.flow +1 -1
  192. package/relay-hooks/useUnsafeRef_DEPRECATED.js.flow +25 -0
  193. package/lib/readContext.js +0 -27
  194. 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 = maybeFetchPolicy ?? DEFAULT_FETCH_POLICY;
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 = maybeFetchPolicy ?? DEFAULT_FETCH_POLICY;
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
 
@@ -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';
@@ -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
- * @generated SignedSource<<8a8e68a3fde4da3f77546ac4952f2635>>
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
- * @generated SignedSource<<0b4a6e76a104111de9ddd4dd9abe667c>>
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, OperationType} from 'relay-runtime';
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
- TQuery: OperationType,
35
- TQueryVariables,
33
+ TRefetchVariables: Variables,
34
+ TLoadMoreVariables: Variables,
36
35
  TFragmentData,
37
36
  > = {
38
37
  data: TFragmentData,
39
- loadNext: LoadMoreFn<TQuery>,
40
- loadPrevious: LoadMoreFn<TQuery>,
38
+ loadNext: LoadMoreFn<TLoadMoreVariables>,
39
+ loadPrevious: LoadMoreFn<TLoadMoreVariables>,
41
40
  hasNext: boolean,
42
41
  hasPrevious: boolean,
43
- refetch: FetchFn<TQueryVariables>,
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<QueryOperation, _>(
50
- fragmentInput,
48
+ (useBlockingPaginationFragment(
49
+ refetchableFragmentInput,
51
50
  keyNonNullable,
52
- ): ExpectedReturnType<QueryOperation, QueryVariablesSubset, NonNullableData>);
51
+ ): ExpectedReturnType<QueryVariablesSubset, QueryVariables, NonNullableData>);
53
52
 
54
- (useBlockingPaginationFragment<QueryOperation, _>(
55
- fragmentInput,
53
+ (useBlockingPaginationFragment(
54
+ refetchableFragmentInput,
56
55
  keyNullable,
57
- ): ExpectedReturnType<QueryOperation, QueryVariables, NullableData>);
56
+ ): ExpectedReturnType<QueryVariables, QueryVariables, NullableData>);
58
57
 
59
58
  // $FlowExpectedError: can't cast nullable to non-nullable
60
- (useBlockingPaginationFragment<QueryOperation, _>(
61
- fragmentInput,
59
+ (useBlockingPaginationFragment(
60
+ refetchableFragmentInput,
62
61
  keyNullable,
63
- ): ExpectedReturnType<QueryOperation, QueryVariables, NonNullableData>);
62
+ ): ExpectedReturnType<QueryVariables, QueryVariables, NonNullableData>);
64
63
 
65
64
  // $FlowExpectedError: actual type of returned data is correct
66
- (useBlockingPaginationFragment<QueryOperation, _>(
67
- fragmentInput,
65
+ (useBlockingPaginationFragment(
66
+ refetchableFragmentInput,
67
+ // $FlowExpectedError[incompatible-call]
68
68
  keyAnotherNonNullable,
69
- ): ExpectedReturnType<QueryOperation, QueryVariablesSubset, NonNullableData>);
70
- // $FlowExpectedError
71
- (useBlockingPaginationFragment<QueryOperation, _>(
72
- fragmentInput,
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<QueryOperation, QueryVariables, NullableData>);
76
+ ): ExpectedReturnType<QueryVariables, QueryVariables, NullableData>);
75
77
 
76
78
  // $FlowExpectedError: Key should not be a user provided object
77
- useBlockingPaginationFragment<QueryOperation, _>(fragmentInput, {abc: 123});
79
+ useBlockingPaginationFragment(fragmentInput, {abc: 123});
78
80
 
79
81
  // $FlowExpectedError: Key should not be an empty object
80
- useBlockingPaginationFragment<QueryOperation, _>(fragmentInput, {});
82
+ useBlockingPaginationFragment(fragmentInput, {});
81
83
 
82
84
  // $FlowExpectedError: Key should be the `<name>$key` type from generated flow
83
- useBlockingPaginationFragment<QueryOperation, _>(fragmentInput, fragmentData);
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<QueryOperation, _>(
90
- fragmentInput,
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<QueryOperation, _>(
108
- fragmentInput,
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 {
@@ -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, OperationType} from 'relay-runtime';
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
- TQuery: OperationType,
35
- TQueryVariables,
33
+ TRefetchVariables: Variables,
34
+ TLoadMoreVariables: Variables,
36
35
  TFragmentData,
37
36
  > = {
38
37
  data: TFragmentData,
39
- loadNext: LoadMoreFn<TQuery>,
40
- loadPrevious: LoadMoreFn<TQuery>,
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<TQueryVariables>,
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<QueryOperation, _>(
52
- fragmentInput,
50
+ (usePaginationFragment(
51
+ refetchableFragmentInput,
53
52
  keyNonNullable,
54
- ): ExpectedReturnType<QueryOperation, QueryVariablesSubset, NonNullableData>);
53
+ ): ExpectedReturnType<QueryVariablesSubset, QueryVariables, NonNullableData>);
55
54
 
56
- (usePaginationFragment<QueryOperation, _>(
57
- fragmentInput,
55
+ (usePaginationFragment(
56
+ refetchableFragmentInput,
58
57
  keyNullable,
59
- ): ExpectedReturnType<QueryOperation, QueryVariables, NullableData>);
58
+ ): ExpectedReturnType<QueryVariables, QueryVariables, NullableData>);
60
59
 
61
60
  // $FlowExpectedError: can't cast nullable to non-nullable
62
- (usePaginationFragment<QueryOperation, _>(
63
- fragmentInput,
61
+ (usePaginationFragment(
62
+ refetchableFragmentInput,
64
63
  keyNullable,
65
- ): ExpectedReturnType<QueryOperation, QueryVariables, NonNullableData>);
64
+ ): ExpectedReturnType<QueryVariables, QueryVariables, NonNullableData>);
66
65
 
67
66
  // $FlowExpectedError: actual type of returned data is correct
68
- (usePaginationFragment<QueryOperation, _>(
69
- fragmentInput,
67
+ (usePaginationFragment(
68
+ refetchableFragmentInput,
69
+ // $FlowFixMe[incompatible-call]
70
70
  keyAnotherNonNullable,
71
- ): ExpectedReturnType<QueryOperation, QueryVariablesSubset, NonNullableData>);
71
+ ): ExpectedReturnType<QueryVariables, QueryVariablesSubset, NonNullableData>);
72
72
  // $FlowExpectedError
73
- (usePaginationFragment<QueryOperation, _>(
74
- fragmentInput,
73
+ (usePaginationFragment(
74
+ refetchableFragmentInput,
75
+ // $FlowFixMe[incompatible-call]
75
76
  keyAnotherNullable,
76
- ): ExpectedReturnType<QueryOperation, QueryVariables, NullableData>);
77
+ ): ExpectedReturnType<QueryVariables, QueryVariables, NonNullableData>);
77
78
 
78
79
  // $FlowExpectedError: Key should not be a user provided object
79
- usePaginationFragment<QueryOperation, _>(fragmentInput, {abc: 123});
80
+ usePaginationFragment(refetchableFragmentInput, {abc: 123});
80
81
 
81
82
  // $FlowExpectedError: Key should not be an empty object
82
- usePaginationFragment<QueryOperation, _>(fragmentInput, {});
83
+ usePaginationFragment(refetchableFragmentInput, {});
83
84
 
84
85
  // $FlowExpectedError: Key should be the `<name>$key` type from generated flow
85
- usePaginationFragment<QueryOperation, _>(fragmentInput, fragmentData);
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<QueryOperation, _>(
92
- fragmentInput,
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<QueryOperation, _>(
110
- fragmentInput,
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<QueryOperation, _>(fragmentInput, keyNonNullable): [
34
+ (useRefetchableFragment(refetchableFragmentInput, keyNonNullable): [
36
35
  NonNullableData,
37
36
  FetchFn<QueryVariablesSubset>,
38
37
  ]);
39
38
 
40
- (useRefetchableFragment<QueryOperation, _>(fragmentInput, keyNullable): [
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<QueryOperation, _>(fragmentInput, keyNullable): [
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<QueryOperation, _>(fragmentInput, keyNullable): [
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<QueryOperation, _>(
59
- fragmentInput,
60
- keyAnotherNonNullable,
61
- ): [NonNullableData, FetchFn<QueryVariablesSubset>]);
62
- // $FlowExpectedError
63
- (useRefetchableFragment<QueryOperation, _>(fragmentInput, keyAnotherNullable): [
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<QueryOperation, _>(fragmentInput, {abc: 123});
69
+ useRefetchableFragment(refetchableFragmentInput, {abc: 123});
70
70
 
71
71
  // $FlowExpectedError: Key should not be an empty object
72
- useRefetchableFragment<QueryOperation, _>(fragmentInput, {});
72
+ useRefetchableFragment(refetchableFragmentInput, {});
73
73
 
74
74
  // $FlowExpectedError: Key should be the `<name>$key` type from generated flow
75
- useRefetchableFragment<QueryOperation, _>(fragmentInput, fragmentData);
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 [_, refetch] = useRefetchableFragment<QueryOperation, _>(
82
- fragmentInput,
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 {Disposable, Fragment, FragmentType} from 'relay-runtime';
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
- * @emails oncall+relay
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
- environmentProvider,
86
- nestedEntryPoint,
87
- nestedParams,
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