react-relay 14.1.0 → 15.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -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,
@@ -54,7 +56,7 @@ function buildReactRelayContainer<TBase: React$ComponentType<any>>(
54
56
  props: any,
55
57
  ref: ((null | any) => mixed) | {current: null | any, ...},
56
58
  ) {
57
- const context = readContext(ReactRelayContext);
59
+ const context = useContext(ReactRelayContext);
58
60
  invariant(
59
61
  context != null,
60
62
  '`%s` tried to render a context that was not valid this means that ' +
@@ -62,7 +64,7 @@ function buildReactRelayContainer<TBase: React$ComponentType<any>>(
62
64
  containerName,
63
65
  containerName,
64
66
  );
65
- const queryRendererContext = readContext(ReactRelayQueryRendererContext);
67
+ const queryRendererContext = useContext(ReactRelayQueryRendererContext);
66
68
 
67
69
  return (
68
70
  <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 v15.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 v15.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 v15.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';
@@ -6,17 +6,17 @@
6
6
  *
7
7
  *
8
8
  * @format
9
+ * @oncall relay
9
10
  */
11
+
10
12
  'use strict';
11
13
 
12
14
  function getComponentName(component) {
13
15
  return component.displayName || component.name || 'Component';
14
16
  }
15
-
16
17
  function getContainerName(Component) {
17
18
  return 'Relay(' + getComponentName(Component) + ')';
18
19
  }
19
-
20
20
  module.exports = {
21
21
  getComponentName: getComponentName,
22
22
  getContainerName: getContainerName
@@ -6,12 +6,12 @@
6
6
  *
7
7
  *
8
8
  * @format
9
+ * @oncall relay
9
10
  */
11
+
10
12
  'use strict';
11
13
 
12
14
  var React = require('react');
13
-
14
15
  var _require = require('relay-runtime'),
15
- createRelayContext = _require.__internal.createRelayContext;
16
-
16
+ createRelayContext = _require.__internal.createRelayContext;
17
17
  module.exports = createRelayContext(React);
@@ -6,40 +6,29 @@
6
6
  *
7
7
  *
8
8
  * @format
9
+ * @oncall relay
9
10
  */
11
+
10
12
  'use strict';
11
13
 
12
14
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
13
-
14
15
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
15
-
16
16
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
17
-
18
17
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
19
-
20
18
  var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
21
-
22
19
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
-
24
20
  var _excluded = ["componentRef", "__relayContext", "__rootIsQueryRenderer"];
25
-
26
21
  var buildReactRelayContainer = require('./buildReactRelayContainer');
27
-
28
22
  var _require = require('./ReactRelayContainerUtils'),
29
- getContainerName = _require.getContainerName;
30
-
23
+ getContainerName = _require.getContainerName;
31
24
  var _require2 = require('./RelayContext'),
32
- assertRelayContext = _require2.assertRelayContext;
33
-
25
+ assertRelayContext = _require2.assertRelayContext;
34
26
  var areEqual = require("fbjs/lib/areEqual");
35
-
36
27
  var React = require('react');
37
-
38
28
  var _require3 = require('relay-runtime'),
39
- createFragmentSpecResolver = _require3.createFragmentSpecResolver,
40
- getDataIDsFromObject = _require3.getDataIDsFromObject,
41
- isScalarAndEqual = _require3.isScalarAndEqual;
42
-
29
+ createFragmentSpecResolver = _require3.createFragmentSpecResolver,
30
+ getDataIDsFromObject = _require3.getDataIDsFromObject,
31
+ isScalarAndEqual = _require3.isScalarAndEqual;
43
32
  /**
44
33
  * Composes a React component class, returning a new class that intercepts
45
34
  * props, resolving them with the provided fragments and subscribing for
@@ -47,20 +36,19 @@ var _require3 = require('relay-runtime'),
47
36
  */
48
37
  function createContainerWithFragments(Component, fragments) {
49
38
  var _class;
50
-
51
39
  var containerName = getContainerName(Component);
52
40
  return _class = /*#__PURE__*/function (_React$Component) {
53
41
  (0, _inheritsLoose2["default"])(_class, _React$Component);
42
+ // $FlowFixMe[missing-local-annot]
54
43
 
55
44
  function _class(props) {
56
45
  var _props$__rootIsQueryR, _this;
57
-
58
46
  _this = _React$Component.call(this, props) || this;
59
47
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_handleFragmentDataUpdate", function () {
60
48
  var resolverFromThisUpdate = _this.state.resolver;
61
-
62
49
  _this.setState(function (updatedState) {
63
- return (// If this event belongs to the current data source, update.
50
+ return (
51
+ // If this event belongs to the current data source, update.
64
52
  // Otherwise we should ignore it.
65
53
  resolverFromThisUpdate === updatedState.resolver ? {
66
54
  data: updatedState.resolver.resolve(),
@@ -70,11 +58,11 @@ function createContainerWithFragments(Component, fragments) {
70
58
  });
71
59
  });
72
60
  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.
61
+ var rootIsQueryRenderer = (_props$__rootIsQueryR = props.__rootIsQueryRenderer) !== null && _props$__rootIsQueryR !== void 0 ? _props$__rootIsQueryR : false;
62
+ // Do not provide a subscription/callback here.
74
63
  // It is possible for this render to be interrupted or aborted,
75
64
  // In which case the subscription would cause a leak.
76
65
  // We will add the subscription in componentDidMount().
77
-
78
66
  var resolver = createFragmentSpecResolver(relayContext, containerName, fragments, props, rootIsQueryRenderer);
79
67
  _this.state = {
80
68
  data: resolver.resolve(),
@@ -85,16 +73,14 @@ function createContainerWithFragments(Component, fragments) {
85
73
  };
86
74
  return _this;
87
75
  }
76
+
88
77
  /**
89
78
  * When new props are received, read data for the new props and subscribe
90
79
  * for updates. Props may be the same in which case previous data and
91
80
  * subscriptions can be reused.
92
81
  */
93
-
94
-
95
82
  _class.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {
96
83
  var _nextProps$__rootIsQu;
97
-
98
84
  // Any props change could impact the query, so we mirror props in state.
99
85
  // This is an unusual pattern, but necessary for this container usecase.
100
86
  var prevProps = prevState.prevProps;
@@ -102,12 +88,13 @@ function createContainerWithFragments(Component, fragments) {
102
88
  var rootIsQueryRenderer = (_nextProps$__rootIsQu = nextProps.__rootIsQueryRenderer) !== null && _nextProps$__rootIsQu !== void 0 ? _nextProps$__rootIsQu : false;
103
89
  var prevIDs = getDataIDsFromObject(fragments, prevProps);
104
90
  var nextIDs = getDataIDsFromObject(fragments, nextProps);
105
- var resolver = prevState.resolver; // If the environment has changed or props point to new records then
91
+ var resolver = prevState.resolver;
92
+
93
+ // If the environment has changed or props point to new records then
106
94
  // previously fetched data and any pending fetches no longer apply:
107
95
  // - Existing references are on the old environment.
108
96
  // - Existing references are based on old variables.
109
97
  // - Pending fetches are for the previous records.
110
-
111
98
  if (prevState.prevPropsContext.environment !== relayContext.environment || !areEqual(prevIDs, nextIDs)) {
112
99
  // Do not provide a subscription/callback here.
113
100
  // It is possible for this render to be interrupted or aborted,
@@ -124,7 +111,6 @@ function createContainerWithFragments(Component, fragments) {
124
111
  } else {
125
112
  resolver.setProps(nextProps);
126
113
  var data = resolver.resolve();
127
-
128
114
  if (data !== prevState.data) {
129
115
  return {
130
116
  data: data,
@@ -134,43 +120,33 @@ function createContainerWithFragments(Component, fragments) {
134
120
  };
135
121
  }
136
122
  }
137
-
138
123
  return null;
139
124
  };
140
-
141
125
  var _proto = _class.prototype;
142
-
143
126
  _proto.componentDidMount = function componentDidMount() {
144
127
  this._subscribeToNewResolverAndRerenderIfStoreHasChanged();
145
128
  };
146
-
147
129
  _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
148
130
  if (this.state.resolver !== prevState.resolver) {
149
131
  prevState.resolver.dispose();
150
-
151
132
  this._subscribeToNewResolverAndRerenderIfStoreHasChanged();
152
133
  } else {
153
134
  this._rerenderIfStoreHasChanged();
154
135
  }
155
136
  };
156
-
157
137
  _proto.componentWillUnmount = function componentWillUnmount() {
158
138
  this.state.resolver.dispose();
159
139
  };
160
-
161
140
  _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
162
141
  // Short-circuit if any Relay-related data has changed
163
142
  if (nextState.data !== this.state.data) {
164
143
  return true;
165
- } // Otherwise, for convenience short-circuit if all non-Relay props
144
+ }
145
+ // Otherwise, for convenience short-circuit if all non-Relay props
166
146
  // are scalar and equal
167
-
168
-
169
147
  var keys = Object.keys(nextProps);
170
-
171
148
  for (var ii = 0; ii < keys.length; ii++) {
172
149
  var key = keys[ii];
173
-
174
150
  if (key === '__relayContext') {
175
151
  if (nextState.prevPropsContext.environment !== this.state.prevPropsContext.environment) {
176
152
  return true;
@@ -181,67 +157,67 @@ function createContainerWithFragments(Component, fragments) {
181
157
  }
182
158
  }
183
159
  }
184
-
185
160
  return false;
186
161
  }
162
+
187
163
  /**
188
164
  * Render new data for the existing props/context.
189
- */
190
- ;
191
-
165
+ */;
192
166
  _proto._rerenderIfStoreHasChanged = function _rerenderIfStoreHasChanged() {
193
167
  var _this$state = this.state,
194
- data = _this$state.data,
195
- resolver = _this$state.resolver; // External values could change between render and commit.
168
+ data = _this$state.data,
169
+ resolver = _this$state.resolver;
170
+ // External values could change between render and commit.
196
171
  // Check for this case, even though it requires an extra store read.
197
-
198
172
  var maybeNewData = resolver.resolve();
199
-
200
173
  if (data !== maybeNewData) {
201
174
  this.setState({
202
175
  data: maybeNewData
203
176
  });
204
177
  }
205
178
  };
206
-
207
179
  _proto._subscribeToNewResolverAndRerenderIfStoreHasChanged = function _subscribeToNewResolverAndRerenderIfStoreHasChanged() {
208
180
  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,
181
+ data = _this$state2.data,
182
+ resolver = _this$state2.resolver;
183
+ var maybeNewData = resolver.resolve();
184
+
185
+ // Event listeners are only safe to add during the commit phase,
212
186
  // So they won't leak if render is interrupted or errors.
187
+ resolver.setCallback(this.props, this._handleFragmentDataUpdate);
213
188
 
214
- resolver.setCallback(this.props, this._handleFragmentDataUpdate); // External values could change between render and commit.
189
+ // External values could change between render and commit.
215
190
  // Check for this case, even though it requires an extra store read.
216
-
217
191
  if (data !== maybeNewData) {
218
192
  this.setState({
219
193
  data: maybeNewData
220
194
  });
221
195
  }
222
- };
196
+ }
223
197
 
198
+ // $FlowFixMe[missing-local-annot]
199
+ ;
224
200
  _proto.render = function render() {
201
+ // eslint-disable-next-line no-unused-vars
225
202
  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);
203
+ componentRef = _this$props.componentRef,
204
+ __relayContext = _this$props.__relayContext,
205
+ __rootIsQueryRenderer = _this$props.__rootIsQueryRenderer,
206
+ props = (0, _objectWithoutPropertiesLoose2["default"])(_this$props, _excluded);
230
207
  return React.createElement(Component, (0, _objectSpread2["default"])((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, props), this.state.data), {}, {
231
208
  ref: componentRef,
232
209
  relay: this.state.relayProp
233
210
  }));
234
211
  };
235
-
236
212
  return _class;
237
213
  }(React.Component), (0, _defineProperty2["default"])(_class, "displayName", containerName), _class;
238
214
  }
239
-
240
215
  function getRelayProp(environment) {
241
216
  return {
242
217
  environment: environment
243
218
  };
244
219
  }
220
+
245
221
  /**
246
222
  * Wrap the basic `createContainer()` function with logic to adapt to the
247
223
  * `context.relay.environment` in which it is rendered. Specifically, the
@@ -249,13 +225,10 @@ function getRelayProp(environment) {
249
225
  * `fragmentSpec` is memoized once per environment, rather than once per
250
226
  * instance of the container constructed/rendered.
251
227
  */
252
-
253
-
254
228
  function createContainer(Component, fragmentSpec) {
255
229
  // $FlowFixMe[incompatible-return]
256
230
  return buildReactRelayContainer(Component, fragmentSpec, createContainerWithFragments);
257
231
  }
258
-
259
232
  module.exports = {
260
233
  createContainer: createContainer
261
234
  };
@@ -6,13 +6,13 @@
6
6
  *
7
7
  *
8
8
  * @format
9
+ * @oncall relay
9
10
  */
11
+
10
12
  'use strict';
11
13
 
12
14
  var ReactRelayContext = require('./ReactRelayContext');
13
-
14
15
  var React = require('react');
15
-
16
16
  function ReactRelayFragmentMockRenderer(props) {
17
17
  return /*#__PURE__*/React.createElement(ReactRelayContext.Provider, {
18
18
  value: {
@@ -20,5 +20,4 @@ function ReactRelayFragmentMockRenderer(props) {
20
20
  }
21
21
  }, props.render());
22
22
  }
23
-
24
23
  module.exports = ReactRelayFragmentMockRenderer;