react-relay 13.0.0-rc.0 → 13.0.1

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 +1 -1
  6. package/ReactRelayFragmentContainer.js.flow +1 -1
  7. package/ReactRelayFragmentMockRenderer.js.flow +1 -1
  8. package/ReactRelayLocalQueryRenderer.js.flow +1 -1
  9. package/ReactRelayPaginationContainer.js.flow +1 -1
  10. package/ReactRelayQueryFetcher.js.flow +1 -1
  11. package/ReactRelayQueryRenderer.js.flow +1 -1
  12. package/ReactRelayQueryRendererContext.js.flow +1 -1
  13. package/ReactRelayRefetchContainer.js.flow +1 -1
  14. package/ReactRelayTestMocker.js.flow +1 -1
  15. package/ReactRelayTypes.js.flow +1 -1
  16. package/RelayContext.js.flow +1 -1
  17. package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +1 -1
  18. package/__flowtests__/ReactRelayPaginationContainer-flowtest.js.flow +1 -1
  19. package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +1 -1
  20. package/__flowtests__/RelayModern-flowtest.js.flow +1 -1
  21. package/__flowtests__/RelayModernFlowtest_badref.graphql.js.flow +1 -1
  22. package/__flowtests__/RelayModernFlowtest_notref.graphql.js.flow +1 -1
  23. package/__flowtests__/RelayModernFlowtest_user.graphql.js.flow +1 -1
  24. package/__flowtests__/RelayModernFlowtest_users.graphql.js.flow +1 -1
  25. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer.graphql.js.flow +2 -2
  26. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer2.graphql.js.flow +2 -2
  27. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtestQuery.graphql.js.flow +2 -2
  28. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtest_viewer.graphql.js.flow +2 -2
  29. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtestQuery.graphql.js.flow +2 -2
  30. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtest_viewer.graphql.js.flow +2 -2
  31. package/__flowtests__/__generated__/RelayModernFlowtest_badref.graphql.js.flow +2 -2
  32. package/__flowtests__/__generated__/RelayModernFlowtest_notref.graphql.js.flow +2 -2
  33. package/__flowtests__/__generated__/RelayModernFlowtest_user.graphql.js.flow +2 -2
  34. package/__flowtests__/__generated__/RelayModernFlowtest_users.graphql.js.flow +2 -2
  35. package/assertFragmentMap.js.flow +1 -1
  36. package/buildReactRelayContainer.js.flow +1 -1
  37. package/getRootVariablesForFragments.js.flow +1 -1
  38. package/hooks.js +2 -2
  39. package/hooks.js.flow +1 -1
  40. package/index.js +2 -2
  41. package/index.js.flow +1 -1
  42. package/isRelayEnvironment.js.flow +1 -1
  43. package/jest-react/enqueueTask.js.flow +1 -1
  44. package/jest-react/index.js.flow +1 -1
  45. package/jest-react/internalAct.js.flow +1 -2
  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 +1 -1
  51. package/lib/ReactRelayFragmentMockRenderer.js +1 -1
  52. package/lib/ReactRelayLocalQueryRenderer.js +1 -1
  53. package/lib/ReactRelayPaginationContainer.js +1 -1
  54. package/lib/ReactRelayQueryFetcher.js +1 -1
  55. package/lib/ReactRelayQueryRenderer.js +1 -1
  56. package/lib/ReactRelayQueryRendererContext.js +1 -1
  57. package/lib/ReactRelayRefetchContainer.js +1 -1
  58. package/lib/ReactRelayTestMocker.js +1 -1
  59. package/lib/ReactRelayTypes.js +1 -1
  60. package/lib/RelayContext.js +1 -1
  61. package/lib/assertFragmentMap.js +1 -1
  62. package/lib/buildReactRelayContainer.js +1 -1
  63. package/lib/getRootVariablesForFragments.js +1 -1
  64. package/lib/hooks.js +1 -1
  65. package/lib/index.js +1 -1
  66. package/lib/isRelayEnvironment.js +1 -1
  67. package/lib/jest-react/enqueueTask.js +1 -1
  68. package/lib/jest-react/internalAct.js +1 -2
  69. package/lib/legacy.js +1 -1
  70. package/lib/multi-actor/ActorChange.js +1 -1
  71. package/lib/multi-actor/index.js +1 -1
  72. package/lib/multi-actor/useRelayActorEnvironment.js +1 -1
  73. package/lib/readContext.js +1 -1
  74. package/lib/relay-hooks/EntryPointContainer.react.js +1 -1
  75. package/lib/relay-hooks/EntryPointTypes.flow.js +1 -1
  76. package/lib/relay-hooks/FragmentResource.js +1 -1
  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 +1 -1
  80. package/lib/relay-hooks/MatchContainer.js +1 -1
  81. package/lib/relay-hooks/ProfilerContext.js +1 -1
  82. package/lib/relay-hooks/QueryResource.js +1 -1
  83. package/lib/relay-hooks/RelayEnvironmentProvider.js +1 -1
  84. package/lib/relay-hooks/SuspenseResource.js +1 -1
  85. package/lib/relay-hooks/loadEntryPoint.js +1 -1
  86. package/lib/relay-hooks/loadQuery.js +1 -1
  87. package/lib/relay-hooks/preloadQuery_DEPRECATED.js +1 -1
  88. package/lib/relay-hooks/prepareEntryPoint_DEPRECATED.js +1 -1
  89. package/lib/relay-hooks/useBlockingPaginationFragment.js +1 -1
  90. package/lib/relay-hooks/useEntryPointLoader.js +1 -1
  91. package/lib/relay-hooks/useFetchTrackingRef.js +1 -1
  92. package/lib/relay-hooks/useFragment.js +2 -3
  93. package/lib/relay-hooks/useFragmentNode.js +1 -1
  94. package/lib/relay-hooks/useIsMountedRef.js +1 -1
  95. package/lib/relay-hooks/useIsOperationNodeActive.js +1 -1
  96. package/lib/relay-hooks/useIsParentQueryActive.js +1 -1
  97. package/lib/relay-hooks/useLazyLoadQuery.js +1 -1
  98. package/lib/relay-hooks/useLazyLoadQueryNode.js +1 -1
  99. package/lib/relay-hooks/useLoadMoreFunction.js +1 -1
  100. package/lib/relay-hooks/useMemoOperationDescriptor.js +1 -1
  101. package/lib/relay-hooks/useMemoVariables.js +1 -1
  102. package/lib/relay-hooks/useMutation.js +1 -1
  103. package/lib/relay-hooks/usePaginationFragment.js +1 -1
  104. package/lib/relay-hooks/usePreloadedQuery.js +1 -1
  105. package/lib/relay-hooks/useQueryLoader.js +1 -1
  106. package/lib/relay-hooks/useRefetchableFragment.js +1 -1
  107. package/lib/relay-hooks/useRefetchableFragmentNode.js +1 -1
  108. package/lib/relay-hooks/useRelayEnvironment.js +1 -1
  109. package/lib/relay-hooks/useStaticFragmentNodeWarning.js +1 -1
  110. package/lib/relay-hooks/useSubscribeToInvalidationState.js +1 -1
  111. package/lib/relay-hooks/useSubscription.js +1 -1
  112. package/multi-actor/ActorChange.js.flow +1 -1
  113. package/multi-actor/index.js.flow +1 -1
  114. package/multi-actor/useRelayActorEnvironment.js.flow +1 -1
  115. package/package.json +3 -3
  116. package/react-relay-hooks.js +1 -1
  117. package/react-relay-hooks.min.js +2 -2
  118. package/react-relay-legacy.js +1 -1
  119. package/react-relay-legacy.min.js +2 -2
  120. package/react-relay.js +1 -1
  121. package/react-relay.min.js +2 -2
  122. package/readContext.js.flow +1 -1
  123. package/relay-hooks/EntryPointContainer.react.js.flow +1 -1
  124. package/relay-hooks/EntryPointTypes.flow.js.flow +1 -1
  125. package/relay-hooks/FragmentResource.js.flow +1 -1
  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 +1 -1
  129. package/relay-hooks/MatchContainer.js.flow +1 -1
  130. package/relay-hooks/ProfilerContext.js.flow +1 -1
  131. package/relay-hooks/QueryResource.js.flow +1 -1
  132. package/relay-hooks/RelayEnvironmentProvider.js.flow +1 -1
  133. package/relay-hooks/SuspenseResource.js.flow +1 -1
  134. package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +1 -1
  135. package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +1 -1
  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 +1 -1
  139. package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +53 -31
  140. package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +1 -1
  141. package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +1 -1
  142. package/relay-hooks/__flowtests__/utils.js.flow +18 -25
  143. package/relay-hooks/loadEntryPoint.js.flow +1 -1
  144. package/relay-hooks/loadQuery.js.flow +1 -1
  145. package/relay-hooks/preloadQuery_DEPRECATED.js.flow +1 -1
  146. package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +1 -1
  147. package/relay-hooks/useBlockingPaginationFragment.js.flow +1 -1
  148. package/relay-hooks/useEntryPointLoader.js.flow +1 -1
  149. package/relay-hooks/useFetchTrackingRef.js.flow +1 -1
  150. package/relay-hooks/useFragment.js.flow +23 -34
  151. package/relay-hooks/useFragmentNode.js.flow +1 -1
  152. package/relay-hooks/useIsMountedRef.js.flow +1 -1
  153. package/relay-hooks/useIsOperationNodeActive.js.flow +1 -1
  154. package/relay-hooks/useIsParentQueryActive.js.flow +1 -1
  155. package/relay-hooks/useLazyLoadQuery.js.flow +7 -8
  156. package/relay-hooks/useLazyLoadQueryNode.js.flow +1 -1
  157. package/relay-hooks/useLoadMoreFunction.js.flow +1 -1
  158. package/relay-hooks/useMemoOperationDescriptor.js.flow +1 -1
  159. package/relay-hooks/useMemoVariables.js.flow +1 -1
  160. package/relay-hooks/useMutation.js.flow +1 -1
  161. package/relay-hooks/usePaginationFragment.js.flow +1 -1
  162. package/relay-hooks/usePreloadedQuery.js.flow +1 -1
  163. package/relay-hooks/useQueryLoader.js.flow +1 -1
  164. package/relay-hooks/useRefetchableFragment.js.flow +1 -1
  165. package/relay-hooks/useRefetchableFragmentNode.js.flow +1 -1
  166. package/relay-hooks/useRelayEnvironment.js.flow +1 -1
  167. package/relay-hooks/useStaticFragmentNodeWarning.js.flow +1 -1
  168. package/relay-hooks/useSubscribeToInvalidationState.js.flow +2 -2
  169. package/relay-hooks/useSubscription.js.flow +1 -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.
@@ -12,52 +12,74 @@
12
12
  // flowlint ambiguous-object-type:error
13
13
 
14
14
  import type {
15
- NonNullableData,
16
- NonNullablePluralData,
17
- NullableData,
18
- NullablePluralData,
19
- } from './utils';
15
+ useFragmentFlowtest_user$data,
16
+ useFragmentFlowtest_user$key,
17
+ } from './__generated__/useFragmentFlowtest_user.graphql';
18
+ import typeof useFragmentFlowtest_user$fragment from './__generated__/useFragmentFlowtest_user.graphql';
19
+ import type {
20
+ useFragmentFlowtest_users$data,
21
+ useFragmentFlowtest_users$key,
22
+ } from './__generated__/useFragmentFlowtest_users.graphql';
23
+ import typeof useFragmentFlowtest_users$fragment from './__generated__/useFragmentFlowtest_users.graphql';
20
24
 
21
25
  import useFragment from '../useFragment';
22
- import {
23
- fragmentData,
24
- fragmentInput,
25
- keyAnotherNonNullable,
26
- keyAnotherNullable,
27
- keyNonNullable,
28
- keyNonNullablePlural,
29
- keyNullable,
30
- keyNullablePlural,
31
- } from './utils';
26
+ import {graphql} from 'relay-runtime';
27
+
28
+ declare var Any: $FlowFixMe;
29
+
30
+ const userFragment: useFragmentFlowtest_user$fragment = graphql`
31
+ fragment useFragmentFlowtest_user on User {
32
+ id
33
+ }
34
+ `;
35
+
36
+ const usersFragment: useFragmentFlowtest_users$fragment = graphql`
37
+ fragment useFragmentFlowtest_users on User @relay(plural: true) {
38
+ id
39
+ }
40
+ `;
32
41
 
33
42
  /* eslint-disable react-hooks/rules-of-hooks */
34
43
 
35
44
  // Nullability of returned data type is correct
36
- (useFragment(fragmentInput, keyNonNullable): NonNullableData);
37
- (useFragment(fragmentInput, keyNullable): NullableData);
38
- (useFragment(fragmentInput, keyNonNullablePlural): NonNullablePluralData);
39
- (useFragment(fragmentInput, keyNullablePlural): NullablePluralData);
45
+ (useFragment(
46
+ userFragment,
47
+ (Any: useFragmentFlowtest_user$key),
48
+ ): useFragmentFlowtest_user$data);
49
+ (useFragment(
50
+ userFragment,
51
+ (Any: ?useFragmentFlowtest_user$key),
52
+ ): ?useFragmentFlowtest_user$data);
53
+ (useFragment(
54
+ usersFragment,
55
+ (Any: useFragmentFlowtest_users$key),
56
+ ): useFragmentFlowtest_users$data);
57
+ (useFragment(
58
+ usersFragment,
59
+ (Any: ?useFragmentFlowtest_users$key),
60
+ ): ?useFragmentFlowtest_users$data);
40
61
 
41
62
  // $FlowExpectedError: can't cast nullable to non-nullable
42
- (useFragment(fragmentInput, keyNullable): NonNullableData);
63
+ (useFragment(
64
+ userFragment,
65
+ (Any: ?useFragmentFlowtest_user$key),
66
+ ): useFragmentFlowtest_user$data);
43
67
  // $FlowExpectedError: can't cast nullable plural to non-nullable plural
44
- (useFragment(fragmentInput, keyNullablePlural): NonNullablePluralData);
45
-
46
- // $FlowExpectedError: actual type of returned data is correct
47
- (useFragment(fragmentInput, keyAnotherNonNullable): NonNullableData);
48
- // $FlowExpectedError
49
- (useFragment(fragmentInput, keyAnotherNullable): NullableData);
68
+ (useFragment(
69
+ usersFragment,
70
+ (Any: ?useFragmentFlowtest_users$key),
71
+ ): useFragmentFlowtest_users$data);
50
72
 
51
73
  // $FlowExpectedError: Key should be one of the generated types
52
- (useFragment(fragmentInput, 'INVALID_KEY'): NullableData);
74
+ useFragment(userFragment, 'INVALID_KEY');
53
75
 
54
76
  // $FlowExpectedError: Key should not be a user provided object
55
- useFragment(fragmentInput, {a: 123});
77
+ useFragment(userFragment, {a: 123});
56
78
 
57
79
  // $FlowExpectedError: Key should not be an empty object
58
- useFragment(fragmentInput, {});
80
+ useFragment(userFragment, {});
59
81
 
60
82
  // $FlowExpectedError: Key should be the `<name>$key` type from generated flow
61
- useFragment(fragmentInput, fragmentData);
83
+ useFragment(userFragment, (Any: useFragmentFlowtest_user$data));
62
84
 
63
85
  /* eslint-enable react-hooks/rules-of-hooks */
@@ -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.
@@ -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.
@@ -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,26 @@
13
13
 
14
14
  'use strict';
15
15
 
16
- import type {Disposable, FragmentType, GraphQLTaggedNode} from 'relay-runtime';
16
+ import type {Disposable, Fragment, FragmentType} from 'relay-runtime';
17
17
 
18
- declare export var fragmentInput: GraphQLTaggedNode;
18
+ declare export var fragmentInput: Fragment<
19
+ Example_user$fragmentType,
20
+ Example_user$data,
21
+ >;
22
+
23
+ declare export opaque type Example_user$fragmentType: FragmentType;
24
+ export type Example_user$data = NonNullableData;
25
+ export type Example_user$key = {
26
+ +$data?: Example_user$data,
27
+ +$fragmentSpreads: Example_user$fragmentType,
28
+ ...
29
+ };
19
30
 
20
31
  export type NonNullableData = {|
21
32
  +id: string,
22
33
  +count: number,
23
34
  |};
24
-
25
35
  export type NullableData = ?NonNullableData;
26
-
27
36
  export type NonNullablePluralData = $ReadOnlyArray<NonNullableData>;
28
37
  export type NullablePluralData = ?$ReadOnlyArray<NonNullableData>;
29
38
 
@@ -32,29 +41,13 @@ export type AnotherNonNullableData = {|
32
41
  +friends: ?number,
33
42
  |};
34
43
 
35
- declare export var keyNonNullable: {
36
- +$data?: NonNullableData,
37
- +$fragmentSpreads: FragmentType,
38
- ...
39
- };
44
+ declare export var keyNonNullable: Example_user$key;
40
45
 
41
- declare export var keyNonNullablePlural: $ReadOnlyArray<{
42
- +$data?: NonNullablePluralData,
43
- +$fragmentSpreads: FragmentType,
44
- ...
45
- }>;
46
+ declare export var keyNonNullablePlural: $ReadOnlyArray<Example_user$key>;
46
47
 
47
- declare export var keyNullablePlural: ?$ReadOnlyArray<{
48
- +$data?: NonNullablePluralData,
49
- +$fragmentSpreads: FragmentType,
50
- ...
51
- }>;
48
+ declare export var keyNullablePlural: ?$ReadOnlyArray<Example_user$key>;
52
49
 
53
- declare export var keyNullable: ?{
54
- +$data?: NonNullableData,
55
- +$fragmentSpreads: FragmentType,
56
- ...
57
- };
50
+ declare export var keyNullable: ?Example_user$key;
58
51
 
59
52
  declare export var keyAnotherNonNullable: {
60
53
  +$data: AnotherNonNullableData,
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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,7 +13,7 @@
13
13
 
14
14
  'use strict';
15
15
 
16
- import type {FragmentType, GraphQLTaggedNode} from 'relay-runtime';
16
+ import type {Fragment, FragmentType, GraphQLTaggedNode} from 'relay-runtime';
17
17
 
18
18
  const {useTrackLoadQueryInRender} = require('./loadQuery');
19
19
  const useFragmentNode = require('./useFragmentNode');
@@ -21,45 +21,34 @@ const useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
21
21
  const {useDebugValue} = require('react');
22
22
  const {getFragment} = require('relay-runtime');
23
23
 
24
+ type HasSpread<TFragmentType> = {
25
+ +$fragmentSpreads: TFragmentType,
26
+ ...
27
+ };
28
+
24
29
  // if the key is non-nullable, return non-nullable value
25
- declare function useFragment<
26
- TKey: {+$data?: mixed, +$fragmentSpreads: FragmentType, ...},
27
- >(
28
- fragment: GraphQLTaggedNode,
29
- key: TKey,
30
- ): $Call<<TData>({+$data?: TData, ...}) => TData, TKey>;
30
+ declare function useFragment<TFragmentType: FragmentType, TData>(
31
+ fragment: Fragment<TFragmentType, TData>,
32
+ key: HasSpread<TFragmentType>,
33
+ ): TData;
31
34
 
32
35
  // if the key is nullable, return nullable value
33
- declare function useFragment<
34
- TKey: ?{+$data?: mixed, +$fragmentSpreads: FragmentType, ...},
35
- >(
36
- fragment: GraphQLTaggedNode,
37
- key: TKey,
38
- ): $Call<<TData>(?{+$data?: TData, ...}) => ?TData, TKey>;
36
+ declare function useFragment<TFragmentType: FragmentType, TData>(
37
+ fragment: Fragment<TFragmentType, TData>,
38
+ key: ?HasSpread<TFragmentType>,
39
+ ): ?TData;
39
40
 
40
41
  // if the key is a non-nullable array of keys, return non-nullable array
41
- declare function useFragment<
42
- TKey: $ReadOnlyArray<{
43
- +$data?: mixed,
44
- +$fragmentSpreads: FragmentType,
45
- ...
46
- }>,
47
- >(
48
- fragment: GraphQLTaggedNode,
49
- key: TKey,
50
- ): $Call<<TData>($ReadOnlyArray<{+$data?: TData, ...}>) => TData, TKey>;
42
+ declare function useFragment<TFragmentType: FragmentType, TData>(
43
+ fragment: Fragment<TFragmentType, TData>,
44
+ key: $ReadOnlyArray<HasSpread<TFragmentType>>,
45
+ ): TData;
51
46
 
52
47
  // if the key is a nullable array of keys, return nullable array
53
- declare function useFragment<
54
- TKey: ?$ReadOnlyArray<{
55
- +$data?: mixed,
56
- +$fragmentSpreads: FragmentType,
57
- ...
58
- }>,
59
- >(
60
- fragment: GraphQLTaggedNode,
61
- key: TKey,
62
- ): $Call<<TData>(?$ReadOnlyArray<{+$data?: TData, ...}>) => ?TData, TKey>;
48
+ declare function useFragment<TFragmentType: FragmentType, TData>(
49
+ fragment: Fragment<TFragmentType, TData>,
50
+ key: ?$ReadOnlyArray<HasSpread<TFragmentType>>,
51
+ ): ?TData;
63
52
 
64
53
  function useFragment(fragment: GraphQLTaggedNode, key: mixed): mixed {
65
54
  // We need to use this hook in order to be able to track if
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -16,10 +16,9 @@
16
16
  import type {
17
17
  CacheConfig,
18
18
  FetchPolicy,
19
- GraphQLTaggedNode,
20
- OperationType,
19
+ Query,
21
20
  RenderPolicy,
22
- VariablesOf,
21
+ Variables,
23
22
  } from 'relay-runtime';
24
23
 
25
24
  const {useTrackLoadQueryInRender} = require('./loadQuery');
@@ -30,16 +29,16 @@ const {
30
29
  __internal: {fetchQuery},
31
30
  } = require('relay-runtime');
32
31
 
33
- function useLazyLoadQuery<TQuery: OperationType>(
34
- gqlQuery: GraphQLTaggedNode,
35
- variables: VariablesOf<TQuery>,
32
+ function useLazyLoadQuery<TVariables: Variables, TData>(
33
+ gqlQuery: Query<TVariables, TData>,
34
+ variables: TVariables,
36
35
  options?: {|
37
36
  fetchKey?: string | number,
38
37
  fetchPolicy?: FetchPolicy,
39
38
  networkCacheConfig?: CacheConfig,
40
39
  UNSTABLE_renderPolicy?: RenderPolicy,
41
40
  |},
42
- ): TQuery['response'] {
41
+ ): TData {
43
42
  // We need to use this hook in order to be able to track if
44
43
  // loadQuery was called during render
45
44
  useTrackLoadQueryInRender();
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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,7 +13,7 @@
13
13
 
14
14
  'use strict';
15
15
 
16
- import type {DataID, Disposable, InvalidationState} from 'relay-runtime';
16
+ import type {DataID, Disposable} from 'relay-runtime';
17
17
 
18
18
  const useRelayEnvironment = require('./useRelayEnvironment');
19
19
  const {useEffect, useRef} = require('react');
@@ -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.