react-relay 14.1.0 → 16.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) 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 +20 -10
  9. package/ReactRelayQueryRenderer.js.flow +15 -11
  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 +2 -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 +10 -6
  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 +0 -11
  47. package/lib/ReactRelayContext.js +1 -12
  48. package/lib/ReactRelayFragmentContainer.js +23 -122
  49. package/lib/ReactRelayFragmentMockRenderer.js +0 -12
  50. package/lib/ReactRelayLocalQueryRenderer.js +12 -41
  51. package/lib/ReactRelayPaginationContainer.js +45 -341
  52. package/lib/ReactRelayQueryFetcher.js +36 -111
  53. package/lib/ReactRelayQueryRenderer.js +29 -137
  54. package/lib/ReactRelayQueryRendererContext.js +0 -10
  55. package/lib/ReactRelayRefetchContainer.js +33 -166
  56. package/lib/ReactRelayTestMocker.js +18 -128
  57. package/lib/ReactRelayTypes.js +0 -9
  58. package/lib/RelayContext.js +0 -23
  59. package/lib/assertFragmentMap.js +0 -16
  60. package/lib/buildReactRelayContainer.js +7 -41
  61. package/lib/getRootVariablesForFragments.js +2 -19
  62. package/lib/hooks.js +3 -30
  63. package/lib/index.js +3 -39
  64. package/lib/isRelayEnvironment.js +1 -16
  65. package/lib/jest-react/enqueueTask.js +1 -25
  66. package/lib/jest-react/index.js +0 -1
  67. package/lib/jest-react/internalAct.js +2 -51
  68. package/lib/legacy.js +0 -20
  69. package/lib/multi-actor/ActorChange.js +0 -14
  70. package/lib/multi-actor/index.js +0 -10
  71. package/lib/multi-actor/useRelayActorEnvironment.js +2 -16
  72. package/lib/relay-hooks/EntryPointContainer.react.js +7 -23
  73. package/lib/relay-hooks/EntryPointTypes.flow.js +0 -10
  74. package/lib/relay-hooks/FragmentResource.js +130 -280
  75. package/lib/relay-hooks/HooksImplementation.js +0 -14
  76. package/lib/relay-hooks/InternalLogger.js +0 -11
  77. package/lib/relay-hooks/LRUCache.js +0 -39
  78. package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +27 -65
  79. package/lib/relay-hooks/MatchContainer.js +9 -111
  80. package/lib/relay-hooks/NestedRelayEntryPointBuilderUtils.js +9 -0
  81. package/lib/relay-hooks/ProfilerContext.js +0 -14
  82. package/lib/relay-hooks/QueryResource.js +14 -149
  83. package/lib/relay-hooks/RelayEnvironmentProvider.js +3 -17
  84. package/lib/relay-hooks/SuspenseResource.js +2 -59
  85. package/lib/relay-hooks/loadEntryPoint.js +10 -45
  86. package/lib/relay-hooks/loadQuery.js +29 -169
  87. package/lib/relay-hooks/preloadQuery_DEPRECATED.js +8 -58
  88. package/lib/relay-hooks/prepareEntryPoint_DEPRECATED.js +6 -24
  89. package/lib/relay-hooks/react-cache/RelayReactCache.js +4 -20
  90. package/lib/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js +13 -102
  91. package/lib/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js +18 -75
  92. package/lib/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js +79 -222
  93. package/lib/relay-hooks/react-cache/useFragment_REACT_CACHE.js +3 -27
  94. package/lib/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js +11 -33
  95. package/lib/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js +62 -85
  96. package/lib/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js +20 -63
  97. package/lib/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js +53 -179
  98. package/lib/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js +5 -27
  99. package/lib/relay-hooks/useBlockingPaginationFragment.js +58 -121
  100. package/lib/relay-hooks/useClientQuery.js +0 -21
  101. package/lib/relay-hooks/useEntryPointLoader.js +12 -100
  102. package/lib/relay-hooks/useFetchTrackingRef.js +6 -33
  103. package/lib/relay-hooks/useFragment.js +5 -32
  104. package/lib/relay-hooks/useFragmentNode.js +14 -55
  105. package/lib/relay-hooks/useIsMountedRef.js +2 -14
  106. package/lib/relay-hooks/useIsOperationNodeActive.js +6 -29
  107. package/lib/relay-hooks/useIsParentQueryActive.js +1 -15
  108. package/lib/relay-hooks/useLazyLoadQuery.js +2 -23
  109. package/lib/relay-hooks/useLazyLoadQueryNode.js +18 -63
  110. package/lib/relay-hooks/useLoadMoreFunction.js +44 -100
  111. package/lib/relay-hooks/useMemoOperationDescriptor.js +4 -23
  112. package/lib/relay-hooks/useMemoVariables.js +8 -43
  113. package/lib/relay-hooks/useMutation.js +6 -34
  114. package/lib/relay-hooks/usePaginationFragment.js +49 -89
  115. package/lib/relay-hooks/usePreloadedQuery.js +10 -54
  116. package/lib/relay-hooks/useQueryLoader.js +18 -116
  117. package/lib/relay-hooks/useRefetchableFragment.js +4 -30
  118. package/lib/relay-hooks/useRefetchableFragmentNode.js +58 -184
  119. package/lib/relay-hooks/useRelayEnvironment.js +2 -16
  120. package/lib/relay-hooks/useStaticFragmentNodeWarning.js +2 -20
  121. package/lib/relay-hooks/useSubscribeToInvalidationState.js +3 -28
  122. package/lib/relay-hooks/useSubscription.js +3 -22
  123. package/lib/relay-hooks/useUnsafeRef_DEPRECATED.js +12 -0
  124. package/multi-actor/ActorChange.js.flow +1 -1
  125. package/multi-actor/index.js.flow +1 -1
  126. package/multi-actor/useRelayActorEnvironment.js.flow +2 -2
  127. package/package.json +2 -2
  128. package/react-relay-hooks.js +2 -2
  129. package/react-relay-hooks.min.js +2 -2
  130. package/react-relay-legacy.js +2 -2
  131. package/react-relay-legacy.min.js +2 -2
  132. package/react-relay.js +2 -2
  133. package/react-relay.min.js +2 -2
  134. package/relay-hooks/EntryPointContainer.react.js.flow +6 -1
  135. package/relay-hooks/EntryPointTypes.flow.js.flow +23 -20
  136. package/relay-hooks/FragmentResource.js.flow +148 -34
  137. package/relay-hooks/HooksImplementation.js.flow +1 -1
  138. package/relay-hooks/InternalLogger.js.flow +1 -1
  139. package/relay-hooks/LRUCache.js.flow +1 -1
  140. package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +19 -10
  141. package/relay-hooks/MatchContainer.js.flow +1 -1
  142. package/relay-hooks/NestedRelayEntryPointBuilderUtils.js.flow +51 -0
  143. package/relay-hooks/ProfilerContext.js.flow +1 -1
  144. package/relay-hooks/QueryResource.js.flow +25 -5
  145. package/relay-hooks/RelayEnvironmentProvider.js.flow +2 -2
  146. package/relay-hooks/SuspenseResource.js.flow +1 -1
  147. package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +3 -1
  148. package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +9 -7
  149. package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_user.graphql.js.flow +3 -1
  150. package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_users.graphql.js.flow +3 -1
  151. package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +40 -33
  152. package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +1 -1
  153. package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +38 -32
  154. package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +20 -18
  155. package/relay-hooks/__flowtests__/utils.js.flow +13 -2
  156. package/relay-hooks/loadEntryPoint.js.flow +15 -8
  157. package/relay-hooks/loadQuery.js.flow +32 -8
  158. package/relay-hooks/preloadQuery_DEPRECATED.js.flow +5 -6
  159. package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +17 -10
  160. package/relay-hooks/react-cache/RelayReactCache.js.flow +1 -1
  161. package/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js.flow +4 -4
  162. package/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js.flow +5 -4
  163. package/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js.flow +32 -14
  164. package/relay-hooks/react-cache/useFragment_REACT_CACHE.js.flow +4 -10
  165. package/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js.flow +1 -1
  166. package/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js.flow +39 -49
  167. package/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js.flow +1 -2
  168. package/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js.flow +29 -16
  169. package/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js.flow +17 -33
  170. package/relay-hooks/useBlockingPaginationFragment.js.flow +85 -58
  171. package/relay-hooks/useClientQuery.js.flow +3 -3
  172. package/relay-hooks/useEntryPointLoader.js.flow +10 -6
  173. package/relay-hooks/useFetchTrackingRef.js.flow +5 -4
  174. package/relay-hooks/useFragment.js.flow +2 -2
  175. package/relay-hooks/useFragmentNode.js.flow +7 -6
  176. package/relay-hooks/useIsMountedRef.js.flow +1 -1
  177. package/relay-hooks/useIsOperationNodeActive.js.flow +1 -1
  178. package/relay-hooks/useIsParentQueryActive.js.flow +1 -1
  179. package/relay-hooks/useLazyLoadQuery.js.flow +2 -2
  180. package/relay-hooks/useLazyLoadQueryNode.js.flow +2 -2
  181. package/relay-hooks/useLoadMoreFunction.js.flow +27 -16
  182. package/relay-hooks/useMemoOperationDescriptor.js.flow +3 -3
  183. package/relay-hooks/useMemoVariables.js.flow +13 -29
  184. package/relay-hooks/useMutation.js.flow +30 -13
  185. package/relay-hooks/usePaginationFragment.js.flow +55 -54
  186. package/relay-hooks/usePreloadedQuery.js.flow +47 -22
  187. package/relay-hooks/useQueryLoader.js.flow +78 -21
  188. package/relay-hooks/useRefetchableFragment.js.flow +65 -33
  189. package/relay-hooks/useRefetchableFragmentNode.js.flow +38 -17
  190. package/relay-hooks/useRelayEnvironment.js.flow +2 -2
  191. package/relay-hooks/useStaticFragmentNodeWarning.js.flow +3 -3
  192. package/relay-hooks/useSubscribeToInvalidationState.js.flow +2 -2
  193. package/relay-hooks/useSubscription.js.flow +1 -1
  194. package/relay-hooks/useUnsafeRef_DEPRECATED.js.flow +25 -0
  195. package/lib/readContext.js +0 -27
  196. package/readContext.js.flow +0 -29
@@ -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<<6d04d7f7bf097d5869a1fdf0dea1e659>>
7
+ * @oncall relay
8
+ *
9
+ * @generated SignedSource<<6f9cebfabb127ad6db1de1705f8a9764>>
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<<d3c71cb965d8374d40fb30f3c5ae9fd4>>
7
+ * @oncall relay
8
+ *
9
+ * @generated SignedSource<<1d67fc8ab171aeb4c45cb1df2d036371>>
8
10
  * @flow
9
11
  * @lightSyntaxTransform
10
12
  * @nogrep
@@ -16,7 +18,7 @@
16
18
 
17
19
  /*::
18
20
  import type { Fragment, ReaderFragment } from 'relay-runtime';
19
- type RelayModernFlowtest_user$fragmentType = any;
21
+ import type { RelayModernFlowtest_user$fragmentType } from "./RelayModernFlowtest_user.graphql";
20
22
  import type { FragmentType } from "relay-runtime";
21
23
  declare export opaque type RelayModernFlowtest_badref$fragmentType: FragmentType;
22
24
  export type RelayModernFlowtest_badref$data = {|
@@ -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<<bd60df80c19d8248426865abbc23562e>>
7
+ * @oncall relay
8
+ *
9
+ * @generated SignedSource<<43b1e678169a4cde5a3a2312c2dca669>>
8
10
  * @flow
9
11
  * @lightSyntaxTransform
10
12
  * @nogrep
@@ -16,7 +18,7 @@
16
18
 
17
19
  /*::
18
20
  import type { Fragment, ReaderFragment } from 'relay-runtime';
19
- type RelayModernFlowtest_user$fragmentType = any;
21
+ import type { RelayModernFlowtest_user$fragmentType } from "./RelayModernFlowtest_user.graphql";
20
22
  import type { FragmentType } from "relay-runtime";
21
23
  declare export opaque type RelayModernFlowtest_notref$fragmentType: FragmentType;
22
24
  export type RelayModernFlowtest_notref$data = {|
@@ -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<<527809017626cb43378afb92fed67feb>>
7
+ * @oncall relay
8
+ *
9
+ * @generated SignedSource<<9d848fb441343089b23a4a389281bffb>>
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<<8a94ce305c03af7280da9b95a665349f>>
7
+ * @oncall relay
8
+ *
9
+ * @generated SignedSource<<36c03d8fd5d95624c243a32c2b4791e4>>
8
10
  * @flow
9
11
  * @lightSyntaxTransform
10
12
  * @nogrep
@@ -6,6 +6,7 @@
6
6
  *
7
7
  * @flow strict-local
8
8
  * @format
9
+ * @oncall relay
9
10
  */
10
11
 
11
12
  'use strict';
@@ -6,12 +6,13 @@
6
6
  *
7
7
  * @flow
8
8
  * @format
9
+ * @oncall relay
9
10
  */
10
11
 
11
12
  'use strict';
12
- import type {ReaderFragment} from '../relay-runtime/util/ReaderNode';
13
+
13
14
  import type {GeneratedNodeMap} from './ReactRelayTypes';
14
- import type {FragmentMap} from 'relay-runtime';
15
+ import type {FragmentMap, ReaderFragment} from 'relay-runtime';
15
16
 
16
17
  const assertFragmentMap = require('./assertFragmentMap');
17
18
  const {
@@ -20,11 +21,12 @@ const {
20
21
  } = require('./ReactRelayContainerUtils');
21
22
  const ReactRelayContext = require('./ReactRelayContext');
22
23
  const ReactRelayQueryRendererContext = require('./ReactRelayQueryRendererContext');
23
- const readContext = require('./readContext');
24
24
  const invariant = require('invariant');
25
25
  const React = require('react');
26
26
  const {getFragment} = require('relay-runtime');
27
27
 
28
+ const {useContext} = React;
29
+
28
30
  type ContainerCreator = (
29
31
  Component: React$ComponentType<any>,
30
32
  fragments: FragmentMap,
@@ -52,9 +54,11 @@ function buildReactRelayContainer<TBase: React$ComponentType<any>>(
52
54
 
53
55
  function forwardRef(
54
56
  props: any,
55
- ref: ((null | any) => mixed) | {current: null | any, ...},
57
+ ref:
58
+ | ((null | React$ElementRef<TBase>) => mixed)
59
+ | {-current: null | React$ElementRef<TBase>, ...},
56
60
  ) {
57
- const context = readContext(ReactRelayContext);
61
+ const context = useContext(ReactRelayContext);
58
62
  invariant(
59
63
  context != null,
60
64
  '`%s` tried to render a context that was not valid this means that ' +
@@ -62,7 +66,7 @@ function buildReactRelayContainer<TBase: React$ComponentType<any>>(
62
66
  containerName,
63
67
  containerName,
64
68
  );
65
- const queryRendererContext = readContext(ReactRelayQueryRendererContext);
69
+ const queryRendererContext = useContext(ReactRelayQueryRendererContext);
66
70
 
67
71
  return (
68
72
  <Container
@@ -6,6 +6,7 @@
6
6
  *
7
7
  * @flow
8
8
  * @format
9
+ * @oncall relay
9
10
  */
10
11
 
11
12
  'use strict';
@@ -31,7 +32,6 @@ function getRootVariablesForFragments<TProps: {...}>(
31
32
  ? selector.selectors[0]?.owner.variables ?? {}
32
33
  : selector?.owner.variables ?? {};
33
34
  rootVariables = {
34
- // $FlowFixMe[exponential-spread]
35
35
  ...rootVariables,
36
36
  ...fragmentOwnerVariables,
37
37
  };
package/hooks.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v14.1.0
2
+ * Relay v16.0.0
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
package/hooks.js.flow CHANGED
@@ -6,6 +6,7 @@
6
6
  *
7
7
  * @flow strict-local
8
8
  * @format
9
+ * @oncall relay
9
10
  */
10
11
 
11
12
  'use strict';
@@ -13,6 +14,7 @@
13
14
  const EntryPointContainer = require('./relay-hooks/EntryPointContainer.react');
14
15
  const loadEntryPoint = require('./relay-hooks/loadEntryPoint');
15
16
  const {loadQuery} = require('./relay-hooks/loadQuery');
17
+ const ProfilerContext = require('./relay-hooks/ProfilerContext');
16
18
  const RelayEnvironmentProvider = require('./relay-hooks/RelayEnvironmentProvider');
17
19
  const useEntryPointLoader = require('./relay-hooks/useEntryPointLoader');
18
20
  const useFragment = require('./relay-hooks/useFragment');
@@ -77,6 +79,8 @@ module.exports = {
77
79
  EntryPointContainer: EntryPointContainer,
78
80
  RelayEnvironmentProvider: RelayEnvironmentProvider,
79
81
 
82
+ ProfilerContext: ProfilerContext,
83
+
80
84
  fetchQuery: RelayRuntime.fetchQuery,
81
85
 
82
86
  loadQuery: loadQuery,
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v14.1.0
2
+ * Relay v16.0.0
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
package/index.js.flow CHANGED
@@ -6,6 +6,7 @@
6
6
  *
7
7
  * @flow strict-local
8
8
  * @format
9
+ * @oncall relay
9
10
  */
10
11
 
11
12
  'use strict';
@@ -19,6 +20,7 @@ const ReactRelayRefetchContainer = require('./ReactRelayRefetchContainer');
19
20
  const EntryPointContainer = require('./relay-hooks/EntryPointContainer.react');
20
21
  const loadEntryPoint = require('./relay-hooks/loadEntryPoint');
21
22
  const {loadQuery} = require('./relay-hooks/loadQuery');
23
+ const ProfilerContext = require('./relay-hooks/ProfilerContext');
22
24
  const RelayEnvironmentProvider = require('./relay-hooks/RelayEnvironmentProvider');
23
25
  const useClientQuery = require('./relay-hooks/useClientQuery');
24
26
  const useEntryPointLoader = require('./relay-hooks/useEntryPointLoader');
@@ -107,6 +109,8 @@ module.exports = {
107
109
  EntryPointContainer: EntryPointContainer,
108
110
  RelayEnvironmentProvider: RelayEnvironmentProvider,
109
111
 
112
+ ProfilerContext: ProfilerContext,
113
+
110
114
  fetchQuery: RelayRuntime.fetchQuery,
111
115
 
112
116
  loadQuery: loadQuery,
@@ -6,6 +6,7 @@
6
6
  *
7
7
  * @flow strict
8
8
  * @format
9
+ * @oncall relay
9
10
  */
10
11
 
11
12
  'use strict';
@@ -4,8 +4,8 @@
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
  * @format
8
+ * @oncall relay
9
9
  */
10
10
 
11
11
  // This file is sync'd from https://github.com/facebook/react/tree/main/packages/jest-react
@@ -4,8 +4,8 @@
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
  * @format
8
+ * @oncall relay
9
9
  */
10
10
 
11
11
  // This file is sync'd from https://github.com/facebook/react/tree/main/packages/jest-react
@@ -4,8 +4,8 @@
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
  * @format
8
+ * @oncall relay
9
9
  */
10
10
 
11
11
  /* global jest */
package/legacy.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v14.1.0
2
+ * Relay v16.0.0
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
package/legacy.js.flow CHANGED
@@ -6,6 +6,7 @@
6
6
  *
7
7
  * @flow strict-local
8
8
  * @format
9
+ * @oncall relay
9
10
  */
10
11
 
11
12
  'use strict';
@@ -1,22 +1,11 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- */
10
1
  'use strict';
11
2
 
12
3
  function getComponentName(component) {
13
4
  return component.displayName || component.name || 'Component';
14
5
  }
15
-
16
6
  function getContainerName(Component) {
17
7
  return 'Relay(' + getComponentName(Component) + ')';
18
8
  }
19
-
20
9
  module.exports = {
21
10
  getComponentName: getComponentName,
22
11
  getContainerName: getContainerName
@@ -1,17 +1,6 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- */
10
1
  'use strict';
11
2
 
12
3
  var React = require('react');
13
-
14
4
  var _require = require('relay-runtime'),
15
- createRelayContext = _require.__internal.createRelayContext;
16
-
5
+ createRelayContext = _require.__internal.createRelayContext;
17
6
  module.exports = createRelayContext(React);
@@ -1,80 +1,42 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- */
10
1
  'use strict';
11
2
 
12
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
13
-
14
4
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
15
-
16
5
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
17
-
18
6
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
19
-
20
7
  var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
21
-
22
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
-
24
9
  var _excluded = ["componentRef", "__relayContext", "__rootIsQueryRenderer"];
25
-
26
10
  var buildReactRelayContainer = require('./buildReactRelayContainer');
27
-
28
11
  var _require = require('./ReactRelayContainerUtils'),
29
- getContainerName = _require.getContainerName;
30
-
12
+ getContainerName = _require.getContainerName;
31
13
  var _require2 = require('./RelayContext'),
32
- assertRelayContext = _require2.assertRelayContext;
33
-
14
+ assertRelayContext = _require2.assertRelayContext;
34
15
  var areEqual = require("fbjs/lib/areEqual");
35
-
36
16
  var React = require('react');
37
-
38
17
  var _require3 = require('relay-runtime'),
39
- createFragmentSpecResolver = _require3.createFragmentSpecResolver,
40
- getDataIDsFromObject = _require3.getDataIDsFromObject,
41
- isScalarAndEqual = _require3.isScalarAndEqual;
42
-
43
- /**
44
- * Composes a React component class, returning a new class that intercepts
45
- * props, resolving them with the provided fragments and subscribing for
46
- * updates.
47
- */
18
+ createFragmentSpecResolver = _require3.createFragmentSpecResolver,
19
+ getDataIDsFromObject = _require3.getDataIDsFromObject,
20
+ isScalarAndEqual = _require3.isScalarAndEqual;
48
21
  function createContainerWithFragments(Component, fragments) {
49
22
  var _class;
50
-
51
23
  var containerName = getContainerName(Component);
52
24
  return _class = /*#__PURE__*/function (_React$Component) {
53
25
  (0, _inheritsLoose2["default"])(_class, _React$Component);
54
-
55
26
  function _class(props) {
56
27
  var _props$__rootIsQueryR, _this;
57
-
58
28
  _this = _React$Component.call(this, props) || this;
59
29
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_handleFragmentDataUpdate", function () {
60
30
  var resolverFromThisUpdate = _this.state.resolver;
61
-
62
31
  _this.setState(function (updatedState) {
63
- return (// If this event belongs to the current data source, update.
64
- // Otherwise we should ignore it.
65
- resolverFromThisUpdate === updatedState.resolver ? {
66
- data: updatedState.resolver.resolve(),
67
- relayProp: getRelayProp(updatedState.relayProp.environment)
68
- } : null
69
- );
32
+ return resolverFromThisUpdate === updatedState.resolver ? {
33
+ data: updatedState.resolver.resolve(),
34
+ relayProp: getRelayProp(updatedState.relayProp.environment)
35
+ } : null;
70
36
  });
71
37
  });
72
38
  var relayContext = assertRelayContext(props.__relayContext);
73
- var rootIsQueryRenderer = (_props$__rootIsQueryR = props.__rootIsQueryRenderer) !== null && _props$__rootIsQueryR !== void 0 ? _props$__rootIsQueryR : false; // Do not provide a subscription/callback here.
74
- // It is possible for this render to be interrupted or aborted,
75
- // In which case the subscription would cause a leak.
76
- // We will add the subscription in componentDidMount().
77
-
39
+ var rootIsQueryRenderer = (_props$__rootIsQueryR = props.__rootIsQueryRenderer) !== null && _props$__rootIsQueryR !== void 0 ? _props$__rootIsQueryR : false;
78
40
  var resolver = createFragmentSpecResolver(relayContext, containerName, fragments, props, rootIsQueryRenderer);
79
41
  _this.state = {
80
42
  data: resolver.resolve(),
@@ -85,34 +47,15 @@ function createContainerWithFragments(Component, fragments) {
85
47
  };
86
48
  return _this;
87
49
  }
88
- /**
89
- * When new props are received, read data for the new props and subscribe
90
- * for updates. Props may be the same in which case previous data and
91
- * subscriptions can be reused.
92
- */
93
-
94
-
95
50
  _class.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {
96
51
  var _nextProps$__rootIsQu;
97
-
98
- // Any props change could impact the query, so we mirror props in state.
99
- // This is an unusual pattern, but necessary for this container usecase.
100
52
  var prevProps = prevState.prevProps;
101
53
  var relayContext = assertRelayContext(nextProps.__relayContext);
102
54
  var rootIsQueryRenderer = (_nextProps$__rootIsQu = nextProps.__rootIsQueryRenderer) !== null && _nextProps$__rootIsQu !== void 0 ? _nextProps$__rootIsQu : false;
103
55
  var prevIDs = getDataIDsFromObject(fragments, prevProps);
104
56
  var nextIDs = getDataIDsFromObject(fragments, nextProps);
105
- var resolver = prevState.resolver; // If the environment has changed or props point to new records then
106
- // previously fetched data and any pending fetches no longer apply:
107
- // - Existing references are on the old environment.
108
- // - Existing references are based on old variables.
109
- // - Pending fetches are for the previous records.
110
-
57
+ var resolver = prevState.resolver;
111
58
  if (prevState.prevPropsContext.environment !== relayContext.environment || !areEqual(prevIDs, nextIDs)) {
112
- // Do not provide a subscription/callback here.
113
- // It is possible for this render to be interrupted or aborted,
114
- // In which case the subscription would cause a leak.
115
- // We will add the subscription in componentDidUpdate().
116
59
  resolver = createFragmentSpecResolver(relayContext, containerName, fragments, nextProps, rootIsQueryRenderer);
117
60
  return {
118
61
  data: resolver.resolve(),
@@ -124,7 +67,6 @@ function createContainerWithFragments(Component, fragments) {
124
67
  } else {
125
68
  resolver.setProps(nextProps);
126
69
  var data = resolver.resolve();
127
-
128
70
  if (data !== prevState.data) {
129
71
  return {
130
72
  data: data,
@@ -134,43 +76,30 @@ function createContainerWithFragments(Component, fragments) {
134
76
  };
135
77
  }
136
78
  }
137
-
138
79
  return null;
139
80
  };
140
-
141
81
  var _proto = _class.prototype;
142
-
143
82
  _proto.componentDidMount = function componentDidMount() {
144
83
  this._subscribeToNewResolverAndRerenderIfStoreHasChanged();
145
84
  };
146
-
147
85
  _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
148
86
  if (this.state.resolver !== prevState.resolver) {
149
87
  prevState.resolver.dispose();
150
-
151
88
  this._subscribeToNewResolverAndRerenderIfStoreHasChanged();
152
89
  } else {
153
90
  this._rerenderIfStoreHasChanged();
154
91
  }
155
92
  };
156
-
157
93
  _proto.componentWillUnmount = function componentWillUnmount() {
158
94
  this.state.resolver.dispose();
159
95
  };
160
-
161
96
  _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
162
- // Short-circuit if any Relay-related data has changed
163
97
  if (nextState.data !== this.state.data) {
164
98
  return true;
165
- } // Otherwise, for convenience short-circuit if all non-Relay props
166
- // are scalar and equal
167
-
168
-
99
+ }
169
100
  var keys = Object.keys(nextProps);
170
-
171
101
  for (var ii = 0; ii < keys.length; ii++) {
172
102
  var key = keys[ii];
173
-
174
103
  if (key === '__relayContext') {
175
104
  if (nextState.prevPropsContext.environment !== this.state.prevPropsContext.environment) {
176
105
  return true;
@@ -181,81 +110,53 @@ function createContainerWithFragments(Component, fragments) {
181
110
  }
182
111
  }
183
112
  }
184
-
185
113
  return false;
186
- }
187
- /**
188
- * Render new data for the existing props/context.
189
- */
190
- ;
191
-
114
+ };
192
115
  _proto._rerenderIfStoreHasChanged = function _rerenderIfStoreHasChanged() {
193
116
  var _this$state = this.state,
194
- data = _this$state.data,
195
- resolver = _this$state.resolver; // External values could change between render and commit.
196
- // Check for this case, even though it requires an extra store read.
197
-
117
+ data = _this$state.data,
118
+ resolver = _this$state.resolver;
198
119
  var maybeNewData = resolver.resolve();
199
-
200
120
  if (data !== maybeNewData) {
201
121
  this.setState({
202
122
  data: maybeNewData
203
123
  });
204
124
  }
205
125
  };
206
-
207
126
  _proto._subscribeToNewResolverAndRerenderIfStoreHasChanged = function _subscribeToNewResolverAndRerenderIfStoreHasChanged() {
208
127
  var _this$state2 = this.state,
209
- data = _this$state2.data,
210
- resolver = _this$state2.resolver;
211
- var maybeNewData = resolver.resolve(); // Event listeners are only safe to add during the commit phase,
212
- // So they won't leak if render is interrupted or errors.
213
-
214
- resolver.setCallback(this.props, this._handleFragmentDataUpdate); // External values could change between render and commit.
215
- // Check for this case, even though it requires an extra store read.
216
-
128
+ data = _this$state2.data,
129
+ resolver = _this$state2.resolver;
130
+ var maybeNewData = resolver.resolve();
131
+ resolver.setCallback(this.props, this._handleFragmentDataUpdate);
217
132
  if (data !== maybeNewData) {
218
133
  this.setState({
219
134
  data: maybeNewData
220
135
  });
221
136
  }
222
137
  };
223
-
224
138
  _proto.render = function render() {
225
139
  var _this$props = this.props,
226
- componentRef = _this$props.componentRef,
227
- __relayContext = _this$props.__relayContext,
228
- __rootIsQueryRenderer = _this$props.__rootIsQueryRenderer,
229
- props = (0, _objectWithoutPropertiesLoose2["default"])(_this$props, _excluded);
140
+ componentRef = _this$props.componentRef,
141
+ __relayContext = _this$props.__relayContext,
142
+ __rootIsQueryRenderer = _this$props.__rootIsQueryRenderer,
143
+ props = (0, _objectWithoutPropertiesLoose2["default"])(_this$props, _excluded);
230
144
  return React.createElement(Component, (0, _objectSpread2["default"])((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, props), this.state.data), {}, {
231
145
  ref: componentRef,
232
146
  relay: this.state.relayProp
233
147
  }));
234
148
  };
235
-
236
149
  return _class;
237
150
  }(React.Component), (0, _defineProperty2["default"])(_class, "displayName", containerName), _class;
238
151
  }
239
-
240
152
  function getRelayProp(environment) {
241
153
  return {
242
154
  environment: environment
243
155
  };
244
156
  }
245
- /**
246
- * Wrap the basic `createContainer()` function with logic to adapt to the
247
- * `context.relay.environment` in which it is rendered. Specifically, the
248
- * extraction of the environment-specific version of fragments in the
249
- * `fragmentSpec` is memoized once per environment, rather than once per
250
- * instance of the container constructed/rendered.
251
- */
252
-
253
-
254
157
  function createContainer(Component, fragmentSpec) {
255
- // $FlowFixMe[incompatible-return]
256
158
  return buildReactRelayContainer(Component, fragmentSpec, createContainerWithFragments);
257
159
  }
258
-
259
160
  module.exports = {
260
161
  createContainer: createContainer
261
162
  };
@@ -1,18 +1,7 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- */
10
1
  'use strict';
11
2
 
12
3
  var ReactRelayContext = require('./ReactRelayContext');
13
-
14
4
  var React = require('react');
15
-
16
5
  function ReactRelayFragmentMockRenderer(props) {
17
6
  return /*#__PURE__*/React.createElement(ReactRelayContext.Provider, {
18
7
  value: {
@@ -20,5 +9,4 @@ function ReactRelayFragmentMockRenderer(props) {
20
9
  }
21
10
  }, props.render());
22
11
  }
23
-
24
12
  module.exports = ReactRelayFragmentMockRenderer;