react-relay 12.0.0 → 13.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +47 -0
  3. package/ReactRelayContainerUtils.js.flow +1 -1
  4. package/ReactRelayContext.js +2 -2
  5. package/ReactRelayContext.js.flow +3 -4
  6. package/ReactRelayFragmentContainer.js.flow +11 -17
  7. package/ReactRelayFragmentMockRenderer.js.flow +2 -2
  8. package/ReactRelayLocalQueryRenderer.js.flow +7 -8
  9. package/ReactRelayPaginationContainer.js.flow +30 -40
  10. package/ReactRelayQueryFetcher.js.flow +10 -11
  11. package/ReactRelayQueryRenderer.js.flow +16 -16
  12. package/ReactRelayQueryRendererContext.js.flow +1 -1
  13. package/ReactRelayRefetchContainer.js.flow +25 -33
  14. package/ReactRelayTestMocker.js.flow +17 -15
  15. package/ReactRelayTypes.js.flow +11 -11
  16. package/RelayContext.js.flow +4 -4
  17. package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +2 -3
  18. package/__flowtests__/ReactRelayPaginationContainer-flowtest.js.flow +2 -3
  19. package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +2 -3
  20. package/__flowtests__/RelayModern-flowtest.js.flow +79 -47
  21. package/__flowtests__/RelayModernFlowtest_badref.graphql.js.flow +6 -5
  22. package/__flowtests__/RelayModernFlowtest_notref.graphql.js.flow +6 -5
  23. package/__flowtests__/RelayModernFlowtest_user.graphql.js.flow +5 -4
  24. package/__flowtests__/RelayModernFlowtest_users.graphql.js.flow +5 -4
  25. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer.graphql.js.flow +14 -11
  26. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer2.graphql.js.flow +14 -11
  27. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtestQuery.graphql.js.flow +14 -9
  28. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtest_viewer.graphql.js.flow +14 -11
  29. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtestQuery.graphql.js.flow +14 -9
  30. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtest_viewer.graphql.js.flow +14 -11
  31. package/__flowtests__/__generated__/RelayModernFlowtest_badref.graphql.js.flow +16 -13
  32. package/__flowtests__/__generated__/RelayModernFlowtest_notref.graphql.js.flow +16 -13
  33. package/__flowtests__/__generated__/RelayModernFlowtest_user.graphql.js.flow +14 -11
  34. package/__flowtests__/__generated__/RelayModernFlowtest_users.graphql.js.flow +14 -11
  35. package/assertFragmentMap.js.flow +3 -3
  36. package/buildReactRelayContainer.js.flow +12 -11
  37. package/getRootVariablesForFragments.js.flow +3 -5
  38. package/hooks.js +2 -2
  39. package/hooks.js.flow +4 -6
  40. package/index.js +2 -2
  41. package/index.js.flow +5 -7
  42. package/isRelayEnvironment.js.flow +1 -1
  43. package/jest-react/enqueueTask.js.flow +2 -2
  44. package/jest-react/index.js.flow +1 -1
  45. package/jest-react/internalAct.js.flow +2 -4
  46. package/legacy.js +2 -2
  47. package/legacy.js.flow +1 -1
  48. package/lib/ReactRelayContainerUtils.js +1 -1
  49. package/lib/ReactRelayContext.js +1 -1
  50. package/lib/ReactRelayFragmentContainer.js +5 -5
  51. package/lib/ReactRelayFragmentMockRenderer.js +3 -3
  52. package/lib/ReactRelayLocalQueryRenderer.js +8 -9
  53. package/lib/ReactRelayPaginationContainer.js +19 -23
  54. package/lib/ReactRelayQueryFetcher.js +3 -3
  55. package/lib/ReactRelayQueryRenderer.js +5 -5
  56. package/lib/ReactRelayQueryRendererContext.js +1 -1
  57. package/lib/ReactRelayRefetchContainer.js +13 -15
  58. package/lib/ReactRelayTestMocker.js +8 -9
  59. package/lib/ReactRelayTypes.js +1 -1
  60. package/lib/RelayContext.js +4 -3
  61. package/lib/assertFragmentMap.js +3 -2
  62. package/lib/buildReactRelayContainer.js +8 -8
  63. package/lib/getRootVariablesForFragments.js +2 -3
  64. package/lib/hooks.js +6 -6
  65. package/lib/index.js +8 -8
  66. package/lib/isRelayEnvironment.js +1 -1
  67. package/lib/jest-react/enqueueTask.js +1 -1
  68. package/lib/jest-react/internalAct.js +3 -4
  69. package/lib/legacy.js +1 -1
  70. package/lib/multi-actor/ActorChange.js +3 -3
  71. package/lib/multi-actor/index.js +1 -1
  72. package/lib/multi-actor/useRelayActorEnvironment.js +3 -3
  73. package/lib/readContext.js +1 -1
  74. package/lib/relay-hooks/EntryPointContainer.react.js +4 -4
  75. package/lib/relay-hooks/EntryPointTypes.flow.js +1 -1
  76. package/lib/relay-hooks/FragmentResource.js +242 -46
  77. package/lib/relay-hooks/InternalLogger.js +1 -1
  78. package/lib/relay-hooks/LRUCache.js +1 -1
  79. package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +5 -5
  80. package/lib/relay-hooks/MatchContainer.js +2 -2
  81. package/lib/relay-hooks/ProfilerContext.js +1 -1
  82. package/lib/relay-hooks/QueryResource.js +84 -5
  83. package/lib/relay-hooks/RelayEnvironmentProvider.js +1 -1
  84. package/lib/relay-hooks/SuspenseResource.js +130 -0
  85. package/lib/relay-hooks/loadEntryPoint.js +1 -1
  86. package/lib/relay-hooks/loadQuery.js +9 -10
  87. package/lib/relay-hooks/preloadQuery_DEPRECATED.js +25 -11
  88. package/lib/relay-hooks/prepareEntryPoint_DEPRECATED.js +1 -1
  89. package/lib/relay-hooks/useBlockingPaginationFragment.js +3 -3
  90. package/lib/relay-hooks/useEntryPointLoader.js +3 -3
  91. package/lib/relay-hooks/useFetchTrackingRef.js +3 -2
  92. package/lib/relay-hooks/useFragment.js +7 -7
  93. package/lib/relay-hooks/useFragmentNode.js +5 -5
  94. package/lib/relay-hooks/useIsMountedRef.js +1 -1
  95. package/lib/relay-hooks/useIsOperationNodeActive.js +3 -3
  96. package/lib/relay-hooks/useIsParentQueryActive.js +1 -1
  97. package/lib/relay-hooks/useLazyLoadQuery.js +4 -4
  98. package/lib/relay-hooks/useLazyLoadQueryNode.js +5 -5
  99. package/lib/relay-hooks/useLoadMoreFunction.js +8 -10
  100. package/lib/relay-hooks/useMemoOperationDescriptor.js +3 -3
  101. package/lib/relay-hooks/useMemoVariables.js +3 -3
  102. package/lib/relay-hooks/useMutation.js +18 -7
  103. package/lib/relay-hooks/usePaginationFragment.js +1 -1
  104. package/lib/relay-hooks/usePreloadedQuery.js +6 -6
  105. package/lib/relay-hooks/useQueryLoader.js +5 -5
  106. package/lib/relay-hooks/useRefetchableFragment.js +1 -1
  107. package/lib/relay-hooks/useRefetchableFragmentNode.js +11 -13
  108. package/lib/relay-hooks/useRelayEnvironment.js +3 -3
  109. package/lib/relay-hooks/useStaticFragmentNodeWarning.js +3 -3
  110. package/lib/relay-hooks/useSubscribeToInvalidationState.js +3 -2
  111. package/lib/relay-hooks/useSubscription.js +1 -1
  112. package/multi-actor/ActorChange.js.flow +4 -5
  113. package/multi-actor/index.js.flow +1 -1
  114. package/multi-actor/useRelayActorEnvironment.js.flow +6 -8
  115. package/package.json +3 -3
  116. package/react-relay-hooks.js +2 -2
  117. package/react-relay-hooks.min.js +3 -3
  118. package/react-relay-legacy.js +2 -2
  119. package/react-relay-legacy.min.js +3 -3
  120. package/react-relay.js +2 -2
  121. package/react-relay.min.js +3 -3
  122. package/readContext.js.flow +1 -1
  123. package/relay-hooks/EntryPointContainer.react.js.flow +9 -16
  124. package/relay-hooks/EntryPointTypes.flow.js.flow +19 -25
  125. package/relay-hooks/FragmentResource.js.flow +221 -35
  126. package/relay-hooks/InternalLogger.js.flow +1 -1
  127. package/relay-hooks/LRUCache.js.flow +1 -1
  128. package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +33 -47
  129. package/relay-hooks/MatchContainer.js.flow +4 -3
  130. package/relay-hooks/ProfilerContext.js.flow +1 -1
  131. package/relay-hooks/QueryResource.js.flow +120 -18
  132. package/relay-hooks/RelayEnvironmentProvider.js.flow +10 -10
  133. package/relay-hooks/SuspenseResource.js.flow +115 -0
  134. package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +5 -4
  135. package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +2 -2
  136. package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_user.graphql.js.flow +59 -0
  137. package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_users.graphql.js.flow +61 -0
  138. package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +11 -10
  139. package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +55 -32
  140. package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +11 -10
  141. package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +11 -10
  142. package/relay-hooks/__flowtests__/utils.js.flow +21 -32
  143. package/relay-hooks/loadEntryPoint.js.flow +7 -13
  144. package/relay-hooks/loadQuery.js.flow +23 -24
  145. package/relay-hooks/preloadQuery_DEPRECATED.js.flow +30 -14
  146. package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +7 -13
  147. package/relay-hooks/useBlockingPaginationFragment.js.flow +13 -14
  148. package/relay-hooks/useEntryPointLoader.js.flow +8 -11
  149. package/relay-hooks/useFetchTrackingRef.js.flow +3 -3
  150. package/relay-hooks/useFragment.js.flow +31 -62
  151. package/relay-hooks/useFragmentNode.js.flow +6 -8
  152. package/relay-hooks/useIsMountedRef.js.flow +1 -1
  153. package/relay-hooks/useIsOperationNodeActive.js.flow +4 -6
  154. package/relay-hooks/useIsParentQueryActive.js.flow +4 -5
  155. package/relay-hooks/useLazyLoadQuery.js.flow +14 -16
  156. package/relay-hooks/useLazyLoadQueryNode.js.flow +12 -14
  157. package/relay-hooks/useLoadMoreFunction.js.flow +20 -28
  158. package/relay-hooks/useMemoOperationDescriptor.js.flow +6 -8
  159. package/relay-hooks/useMemoVariables.js.flow +7 -7
  160. package/relay-hooks/useMutation.js.flow +27 -27
  161. package/relay-hooks/usePaginationFragment.js.flow +38 -47
  162. package/relay-hooks/usePreloadedQuery.js.flow +14 -20
  163. package/relay-hooks/useQueryLoader.js.flow +14 -17
  164. package/relay-hooks/useRefetchableFragment.js.flow +8 -9
  165. package/relay-hooks/useRefetchableFragmentNode.js.flow +23 -31
  166. package/relay-hooks/useRelayEnvironment.js.flow +3 -5
  167. package/relay-hooks/useStaticFragmentNodeWarning.js.flow +3 -4
  168. package/relay-hooks/useSubscribeToInvalidationState.js.flow +4 -7
  169. package/relay-hooks/useSubscription.js.flow +7 -8
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) Facebook, Inc. and its affiliates.
3
+ Copyright (c) Meta Platforms, Inc. and affiliates.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ React APIs for Relay
2
+ ---
3
+
4
+ This package contains a collection of React APIs: Hooks and Components that are integrated with Relay runtime.
5
+
6
+ Example:
7
+
8
+ ```js
9
+
10
+ // @flow
11
+
12
+ import type {UserComponent_user$key} from 'UserComponent_user.graphql';
13
+
14
+ const React = require('react');
15
+
16
+ const {graphql, useFragment} = require('react-relay');
17
+
18
+ type Props = {
19
+ user: UserComponent_user$key,
20
+ };
21
+
22
+ function UserComponent(props: Props) {
23
+ const data = useFragment(
24
+ graphql`
25
+ fragment UserComponent_user on User {
26
+ name
27
+ profile_picture(scale: 2) {
28
+ uri
29
+ }
30
+ }
31
+ `,
32
+ props.user,
33
+ );
34
+
35
+ return (
36
+ <>
37
+ <h1>{data.name}</h1>
38
+ <div>
39
+ <img src={data.profile_picture?.uri} />
40
+ </div>
41
+ </>
42
+ );
43
+ }
44
+
45
+ ```
46
+
47
+ For complete API reference, visit https://relay.dev/.
@@ -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,7 +1,7 @@
1
1
  /**
2
- * Relay v12.0.0
2
+ * Relay v13.0.0
3
3
  *
4
- * Copyright (c) Facebook, Inc. and its affiliates.
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
6
6
  * This source code is licensed under the MIT license found in the
7
7
  * 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.
@@ -11,14 +11,13 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
 
13
13
  'use strict';
14
- const React = require('react');
14
+ import type {RelayContext} from 'relay-runtime/store/RelayStoreTypes';
15
15
 
16
+ const React = require('react');
16
17
  const {
17
18
  __internal: {createRelayContext},
18
19
  } = require('relay-runtime');
19
20
 
20
- import type {RelayContext} from 'relay-runtime/store/RelayStoreTypes';
21
-
22
21
  module.exports = (createRelayContext(
23
22
  React,
24
23
  ): React$Context<RelayContext | null>);
@@ -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,26 +12,24 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const React = require('react');
15
+ import type {GeneratedNodeMap, RelayProp, $RelayProps} from './ReactRelayTypes';
16
+ import type {
17
+ FragmentMap,
18
+ FragmentSpecResolver,
19
+ RelayContext,
20
+ } from 'relay-runtime';
16
21
 
17
- const areEqual = require('areEqual');
18
22
  const buildReactRelayContainer = require('./buildReactRelayContainer');
19
-
20
23
  const {getContainerName} = require('./ReactRelayContainerUtils');
21
24
  const {assertRelayContext} = require('./RelayContext');
25
+ const areEqual = require('areEqual');
26
+ const React = require('react');
22
27
  const {
23
28
  createFragmentSpecResolver,
24
29
  getDataIDsFromObject,
25
30
  isScalarAndEqual,
26
31
  } = require('relay-runtime');
27
32
 
28
- import type {$RelayProps, GeneratedNodeMap, RelayProp} from './ReactRelayTypes';
29
- import type {
30
- FragmentMap,
31
- FragmentSpecResolver,
32
- RelayContext,
33
- } from 'relay-runtime';
34
-
35
33
  type ContainerProps = $FlowFixMeProps;
36
34
  type ContainerState = {
37
35
  data: {[key: string]: mixed, ...},
@@ -237,12 +235,8 @@ function createContainerWithFragments<
237
235
  }
238
236
 
239
237
  render() {
240
- const {
241
- componentRef,
242
- __relayContext,
243
- __rootIsQueryRenderer,
244
- ...props
245
- } = this.props;
238
+ const {componentRef, __relayContext, __rootIsQueryRenderer, ...props} =
239
+ this.props;
246
240
  return React.createElement(Component, {
247
241
  ...props,
248
242
  ...this.state.data,
@@ -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,8 +12,8 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const React = require('react');
16
15
  const ReactRelayContext = require('./ReactRelayContext');
16
+ const React = require('react');
17
17
 
18
18
  function ReactRelayFragmentMockRenderer(props: Object): React.Node {
19
19
  return (
@@ -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,21 +12,20 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const React = require('react');
15
+ import type {ReactRelayQueryRendererContext as ReactRelayQueryRendererContextType} from './ReactRelayQueryRendererContext';
16
+ import type {GraphQLTaggedNode, IEnvironment, Variables} from 'relay-runtime';
17
+
16
18
  const ReactRelayContext = require('./ReactRelayContext');
17
19
  const ReactRelayQueryRendererContext = require('./ReactRelayQueryRendererContext');
18
-
19
- const {useLayoutEffect, useState, useRef, useMemo} = React;
20
+ const areEqual = require('areEqual');
21
+ const React = require('react');
20
22
  const {
21
23
  createOperationDescriptor,
22
24
  deepFreeze,
23
25
  getRequest,
24
26
  } = require('relay-runtime');
25
27
 
26
- const areEqual = require('areEqual');
27
-
28
- import type {ReactRelayQueryRendererContext as ReactRelayQueryRendererContextType} from './ReactRelayQueryRendererContext';
29
- import type {GraphQLTaggedNode, IEnvironment, Variables} from 'relay-runtime';
28
+ const {useLayoutEffect, useState, useRef, useMemo} = React;
30
29
 
31
30
  type Props = {
32
31
  environment: IEnvironment,
@@ -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,39 +12,12 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const React = require('react');
16
- const ReactRelayContext = require('./ReactRelayContext');
17
- const ReactRelayQueryFetcher = require('./ReactRelayQueryFetcher');
18
-
19
- const areEqual = require('areEqual');
20
- const buildReactRelayContainer = require('./buildReactRelayContainer');
21
- const getRootVariablesForFragments = require('./getRootVariablesForFragments');
22
- const invariant = require('invariant');
23
- const warning = require('warning');
24
-
25
- const {
26
- getComponentName,
27
- getContainerName,
28
- } = require('./ReactRelayContainerUtils');
29
- const {assertRelayContext} = require('./RelayContext');
30
- const {
31
- ConnectionInterface,
32
- Observable,
33
- createFragmentSpecResolver,
34
- createOperationDescriptor,
35
- getDataIDsFromObject,
36
- getRequest,
37
- getVariablesFromObject,
38
- isScalarAndEqual,
39
- RelayFeatureFlags,
40
- } = require('relay-runtime');
41
-
42
15
  import type {
43
- $RelayProps,
44
- ObserverOrCallback,
45
16
  GeneratedNodeMap,
17
+ ObserverOrCallback,
46
18
  RefetchOptions,
47
19
  RelayPaginationProp,
20
+ $RelayProps,
48
21
  } from './ReactRelayTypes';
49
22
  import type {
50
23
  CacheConfig,
@@ -60,6 +33,31 @@ import type {
60
33
  Variables,
61
34
  } from 'relay-runtime';
62
35
 
36
+ const buildReactRelayContainer = require('./buildReactRelayContainer');
37
+ const getRootVariablesForFragments = require('./getRootVariablesForFragments');
38
+ const {
39
+ getComponentName,
40
+ getContainerName,
41
+ } = require('./ReactRelayContainerUtils');
42
+ const ReactRelayContext = require('./ReactRelayContext');
43
+ const ReactRelayQueryFetcher = require('./ReactRelayQueryFetcher');
44
+ const {assertRelayContext} = require('./RelayContext');
45
+ const areEqual = require('areEqual');
46
+ const invariant = require('invariant');
47
+ const React = require('react');
48
+ const {
49
+ ConnectionInterface,
50
+ Observable,
51
+ RelayFeatureFlags,
52
+ createFragmentSpecResolver,
53
+ createOperationDescriptor,
54
+ getDataIDsFromObject,
55
+ getRequest,
56
+ getVariablesFromObject,
57
+ isScalarAndEqual,
58
+ } = require('relay-runtime');
59
+ const warning = require('warning');
60
+
63
61
  type ContainerState = {
64
62
  data: {[key: string]: mixed, ...},
65
63
  relayProp: RelayPaginationProp,
@@ -258,7 +256,6 @@ function createGetFragmentVariables(
258
256
  'ReactRelayPaginationContainer: Unable to synthesize a ' +
259
257
  'getFragmentVariables function.',
260
258
  );
261
- // $FlowFixMe[cannot-spread-interface]
262
259
  return (prevVars: Variables, totalCount: number) => ({
263
260
  ...prevVars,
264
261
  [countVariable]: totalCount,
@@ -766,9 +763,7 @@ function createContainerWithFragments<
766
763
  };
767
764
  let fragmentVariables;
768
765
  const rootVariables = getRootVariablesForFragments(fragments, restProps);
769
- // $FlowFixMe[cannot-spread-interface]
770
766
  fragmentVariables = getVariablesFromObject(fragments, restProps);
771
- // $FlowFixMe[cannot-spread-interface]
772
767
  fragmentVariables = {
773
768
  ...rootVariables,
774
769
  ...fragmentVariables,
@@ -789,7 +784,6 @@ function createContainerWithFragments<
789
784
  fetchVariables,
790
785
  componentName,
791
786
  );
792
- // $FlowFixMe[cannot-spread-interface]
793
787
  fetchVariables = {
794
788
  ...fetchVariables,
795
789
  ...this._refetchVariables,
@@ -906,12 +900,8 @@ function createContainerWithFragments<
906
900
  }
907
901
 
908
902
  render() {
909
- const {
910
- componentRef,
911
- __relayContext,
912
- __rootIsQueryRenderer,
913
- ...props
914
- } = this.props;
903
+ const {componentRef, __relayContext, __rootIsQueryRenderer, ...props} =
904
+ this.props;
915
905
  return (
916
906
  <ReactRelayContext.Provider value={this.state.contextForChildren}>
917
907
  <Component
@@ -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,14 +12,6 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const invariant = require('invariant');
16
-
17
- const {
18
- createOperationDescriptor,
19
- isRelayModernEnvironment,
20
- __internal: {fetchQuery},
21
- } = require('relay-runtime');
22
-
23
15
  import type {
24
16
  CacheConfig,
25
17
  Disposable,
@@ -29,6 +21,13 @@ import type {
29
21
  Snapshot,
30
22
  } from 'relay-runtime';
31
23
 
24
+ const invariant = require('invariant');
25
+ const {
26
+ __internal: {fetchQuery},
27
+ createOperationDescriptor,
28
+ isRelayModernEnvironment,
29
+ } = require('relay-runtime');
30
+
32
31
  type OnDataChange = ({
33
32
  error?: Error,
34
33
  snapshot?: Snapshot,
@@ -341,8 +340,8 @@ class ReactRelayQueryFetcher {
341
340
  this._rootSubscription = environment.subscribe(this._snapshot, snapshot => {
342
341
  // Read from this._fetchOptions in case onDataChange() was lazily added.
343
342
  if (this._fetchOptions != null) {
344
- const maybeNewOnDataChangeCallbacks = this._fetchOptions
345
- .onDataChangeCallbacks;
343
+ const maybeNewOnDataChangeCallbacks =
344
+ this._fetchOptions.onDataChangeCallbacks;
346
345
  if (Array.isArray(maybeNewOnDataChangeCallbacks)) {
347
346
  maybeNewOnDataChangeCallbacks.forEach(onDataChange =>
348
347
  onDataChange({snapshot}),
@@ -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,20 +12,6 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const React = require('react');
16
- const ReactRelayContext = require('./ReactRelayContext');
17
- const ReactRelayQueryFetcher = require('./ReactRelayQueryFetcher');
18
- const ReactRelayQueryRendererContext = require('./ReactRelayQueryRendererContext');
19
-
20
- const areEqual = require('areEqual');
21
-
22
- const {
23
- createOperationDescriptor,
24
- deepFreeze,
25
- getRequest,
26
- RelayFeatureFlags,
27
- } = require('relay-runtime');
28
-
29
15
  import type {ReactRelayQueryRendererContext as ReactRelayQueryRendererContextType} from './ReactRelayQueryRendererContext';
30
16
  import type {
31
17
  CacheConfig,
@@ -36,6 +22,19 @@ import type {
36
22
  Snapshot,
37
23
  Variables,
38
24
  } from 'relay-runtime';
25
+
26
+ const ReactRelayContext = require('./ReactRelayContext');
27
+ const ReactRelayQueryFetcher = require('./ReactRelayQueryFetcher');
28
+ const ReactRelayQueryRendererContext = require('./ReactRelayQueryRendererContext');
29
+ const areEqual = require('areEqual');
30
+ const React = require('react');
31
+ const {
32
+ RelayFeatureFlags,
33
+ createOperationDescriptor,
34
+ deepFreeze,
35
+ getRequest,
36
+ } = require('relay-runtime');
37
+
39
38
  type RetryCallbacks = {|
40
39
  handleDataChange:
41
40
  | null
@@ -340,7 +339,8 @@ function resetQueryStateForUpdate(
340
339
  ): $Shape<State> {
341
340
  const {query} = props;
342
341
 
343
- const prevSelectionReferences = prevState.queryFetcher.getSelectionReferences();
342
+ const prevSelectionReferences =
343
+ prevState.queryFetcher.getSelectionReferences();
344
344
  prevState.queryFetcher.disposeRequest();
345
345
 
346
346
  let queryFetcher;
@@ -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.
@@ -12,33 +12,12 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const React = require('react');
16
- const ReactRelayContext = require('./ReactRelayContext');
17
- const ReactRelayQueryFetcher = require('./ReactRelayQueryFetcher');
18
-
19
- const areEqual = require('areEqual');
20
- const buildReactRelayContainer = require('./buildReactRelayContainer');
21
- const getRootVariablesForFragments = require('./getRootVariablesForFragments');
22
- const warning = require('warning');
23
-
24
- const {getContainerName} = require('./ReactRelayContainerUtils');
25
- const {assertRelayContext} = require('./RelayContext');
26
- const {
27
- Observable,
28
- createFragmentSpecResolver,
29
- createOperationDescriptor,
30
- getDataIDsFromObject,
31
- getRequest,
32
- getVariablesFromObject,
33
- isScalarAndEqual,
34
- } = require('relay-runtime');
35
-
36
15
  import type {
37
- $RelayProps,
38
- ObserverOrCallback,
39
16
  GeneratedNodeMap,
17
+ ObserverOrCallback,
40
18
  RefetchOptions,
41
19
  RelayRefetchProp,
20
+ $RelayProps,
42
21
  } from './ReactRelayTypes';
43
22
  import type {
44
23
  CacheConfig,
@@ -51,6 +30,25 @@ import type {
51
30
  } from 'relay-runtime';
52
31
  import type {FragmentSpecResolver} from 'relay-runtime';
53
32
 
33
+ const buildReactRelayContainer = require('./buildReactRelayContainer');
34
+ const getRootVariablesForFragments = require('./getRootVariablesForFragments');
35
+ const {getContainerName} = require('./ReactRelayContainerUtils');
36
+ const ReactRelayContext = require('./ReactRelayContext');
37
+ const ReactRelayQueryFetcher = require('./ReactRelayQueryFetcher');
38
+ const {assertRelayContext} = require('./RelayContext');
39
+ const areEqual = require('areEqual');
40
+ const React = require('react');
41
+ const {
42
+ Observable,
43
+ createFragmentSpecResolver,
44
+ createOperationDescriptor,
45
+ getDataIDsFromObject,
46
+ getRequest,
47
+ getVariablesFromObject,
48
+ isScalarAndEqual,
49
+ } = require('relay-runtime');
50
+ const warning = require('warning');
51
+
54
52
  type ContainerProps = $FlowFixMeProps;
55
53
 
56
54
  type ContainerState = {
@@ -332,11 +330,9 @@ function createContainerWithFragments<
332
330
  typeof refetchVariables === 'function'
333
331
  ? refetchVariables(this._getFragmentVariables())
334
332
  : refetchVariables;
335
- // $FlowFixMe[cannot-spread-interface]
336
333
  fetchVariables = {...rootVariables, ...fetchVariables};
337
334
  const fragmentVariables = renderVariables
338
- ? // $FlowFixMe[cannot-spread-interface]
339
- {...fetchVariables, ...renderVariables}
335
+ ? {...fetchVariables, ...renderVariables}
340
336
  : fetchVariables;
341
337
 
342
338
  const cacheConfig: ?CacheConfig = options
@@ -452,12 +448,8 @@ function createContainerWithFragments<
452
448
  };
453
449
 
454
450
  render() {
455
- const {
456
- componentRef,
457
- __relayContext,
458
- __rootIsQueryRenderer,
459
- ...props
460
- } = this.props;
451
+ const {componentRef, __relayContext, __rootIsQueryRenderer, ...props} =
452
+ this.props;
461
453
  const {relayProp, contextForChildren} = this.state;
462
454
  return (
463
455
  <ReactRelayContext.Provider value={contextForChildren}>
@@ -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,16 +12,6 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const areEqual = require('areEqual');
16
- const invariant = require('invariant');
17
- const warning = require('warning');
18
-
19
- const {
20
- createOperationDescriptor,
21
- isRelayModernEnvironment,
22
- Network,
23
- } = require('relay-runtime');
24
-
25
15
  import type {
26
16
  CacheConfig,
27
17
  ConcreteRequest,
@@ -32,6 +22,15 @@ import type {
32
22
  Variables,
33
23
  } from 'relay-runtime';
34
24
 
25
+ const areEqual = require('areEqual');
26
+ const invariant = require('invariant');
27
+ const {
28
+ Network,
29
+ createOperationDescriptor,
30
+ isRelayModernEnvironment,
31
+ } = require('relay-runtime');
32
+ const warning = require('warning');
33
+
35
34
  export type DataWriteConfig = {
36
35
  query: ConcreteRequest,
37
36
  variables: Variables,
@@ -66,7 +65,7 @@ let nextId = 0;
66
65
 
67
66
  class ReactRelayTestMocker {
68
67
  _environment: IEnvironment;
69
- _defaults: {[string]: $PropertyType<NetworkWriteConfig, 'payload'>, ...} = {};
68
+ _defaults: {[string]: NetworkWriteConfig['payload'], ...} = {};
70
69
  _pendingFetches: Array<PendingFetch> = [];
71
70
 
72
71
  constructor(env: IEnvironment) {
@@ -118,7 +117,6 @@ class ReactRelayTestMocker {
118
117
  * annoying to test (e.g. client_mutation_id, actor_id)
119
118
  */
120
119
  static stripUnused(variables: Variables): Variables {
121
- // $FlowFixMe[prop-missing]
122
120
  if (variables.input) {
123
121
  const toRemove = [
124
122
  'client_mutation_id',
@@ -126,7 +124,6 @@ class ReactRelayTestMocker {
126
124
  'clientMutationId',
127
125
  'actorId',
128
126
  ];
129
- // $FlowFixMe[cannot-spread-interface]
130
127
  const strippedVariables = {...variables, input: {...variables.input}};
131
128
  toRemove.forEach(item => (strippedVariables.input[item] = undefined));
132
129
  return strippedVariables;
@@ -143,7 +140,11 @@ class ReactRelayTestMocker {
143
140
  * their components behave under error conditions.
144
141
  */
145
142
  _mockNetworkLayer(env: IEnvironment): IEnvironment {
146
- const fetch = (request, variables, cacheConfig) => {
143
+ const fetch = (
144
+ request: RequestParameters,
145
+ variables: Variables,
146
+ cacheConfig: CacheConfig,
147
+ ) => {
147
148
  let resolve;
148
149
  let reject;
149
150
  const promise = new Promise((res, rej) => {
@@ -314,6 +315,7 @@ class ReactRelayTestMocker {
314
315
  );
315
316
 
316
317
  const realPayload =
318
+ // $FlowFixMe[incompatible-call]
317
319
  typeof payload === 'function' ? payload(toResolve.variables) : payload;
318
320
 
319
321
  // if there are errors, reject the query
@@ -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.
@@ -14,7 +14,7 @@
14
14
 
15
15
  import type {
16
16
  Disposable,
17
- FragmentReference,
17
+ FragmentType,
18
18
  GraphQLTaggedNode,
19
19
  IEnvironment,
20
20
  Observer,
@@ -94,7 +94,7 @@ export type RefetchOptions = {|
94
94
  *
95
95
  */
96
96
  export type $FragmentRef<T> = {
97
- +$fragmentRefs: $PropertyType<T, '$refType'>,
97
+ +$fragmentSpreads: T['$fragmentType'],
98
98
  ...
99
99
  };
100
100
 
@@ -105,14 +105,14 @@ export type $FragmentRef<T> = {
105
105
  // prettier-ignore
106
106
  export type $RelayProps<Props, RelayPropT = RelayProp> = $ObjMap<
107
107
  $Diff<Props, { relay: RelayPropT | void, ... }>,
108
- & (<T: { +$refType: empty, ... }>( T) => T)
109
- & (<T: { +$refType: empty, ... }>(?T) => ?T)
110
- & (<TRef: FragmentReference, T: { +$refType: TRef, ... }>( T ) => $FragmentRef<T> )
111
- & (<TRef: FragmentReference, T: { +$refType: TRef, ... }>(? T ) => ? $FragmentRef<T> )
112
- & (<TRef: FragmentReference, T: { +$refType: TRef, ... }>( $ReadOnlyArray< T>) => $ReadOnlyArray< $FragmentRef<T>>)
113
- & (<TRef: FragmentReference, T: { +$refType: TRef, ... }>(?$ReadOnlyArray< T>) => ?$ReadOnlyArray< $FragmentRef<T>>)
114
- & (<TRef: FragmentReference, T: { +$refType: TRef, ... }>( $ReadOnlyArray<?T>) => $ReadOnlyArray<?$FragmentRef<T>>)
115
- & (<TRef: FragmentReference, T: { +$refType: TRef, ... }>(?$ReadOnlyArray<?T>) => ?$ReadOnlyArray<?$FragmentRef<T>>)
108
+ & (<T: { +$fragmentType: empty, ... }>( T) => T)
109
+ & (<T: { +$fragmentType: empty, ... }>(?T) => ?T)
110
+ & (<TFragmentType: FragmentType, T: { +$fragmentType: TFragmentType, ... }>( T ) => $FragmentRef<T> )
111
+ & (<TFragmentType: FragmentType, T: { +$fragmentType: TFragmentType, ... }>(? T ) => ? $FragmentRef<T> )
112
+ & (<TFragmentType: FragmentType, T: { +$fragmentType: TFragmentType, ... }>( $ReadOnlyArray< T>) => $ReadOnlyArray< $FragmentRef<T>>)
113
+ & (<TFragmentType: FragmentType, T: { +$fragmentType: TFragmentType, ... }>(?$ReadOnlyArray< T>) => ?$ReadOnlyArray< $FragmentRef<T>>)
114
+ & (<TFragmentType: FragmentType, T: { +$fragmentType: TFragmentType, ... }>( $ReadOnlyArray<?T>) => $ReadOnlyArray<?$FragmentRef<T>>)
115
+ & (<TFragmentType: FragmentType, T: { +$fragmentType: TFragmentType, ... }>(?$ReadOnlyArray<?T>) => ?$ReadOnlyArray<?$FragmentRef<T>>)
116
116
  & (<T>(T) => T),
117
117
  >;
118
118