react-relay 13.2.0 → 14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/ReactRelayContext.js +1 -1
  2. package/ReactRelayFragmentContainer.js.flow +7 -4
  3. package/ReactRelayPaginationContainer.js.flow +13 -8
  4. package/ReactRelayQueryFetcher.js.flow +1 -0
  5. package/ReactRelayQueryRenderer.js.flow +6 -2
  6. package/ReactRelayRefetchContainer.js.flow +10 -3
  7. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer.graphql.js.flow +2 -2
  8. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer2.graphql.js.flow +2 -2
  9. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtestQuery.graphql.js.flow +3 -3
  10. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtest_viewer.graphql.js.flow +3 -3
  11. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtestQuery.graphql.js.flow +3 -3
  12. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtest_viewer.graphql.js.flow +3 -3
  13. package/__flowtests__/__generated__/RelayModernFlowtest_badref.graphql.js.flow +2 -2
  14. package/__flowtests__/__generated__/RelayModernFlowtest_notref.graphql.js.flow +2 -2
  15. package/__flowtests__/__generated__/RelayModernFlowtest_user.graphql.js.flow +2 -2
  16. package/__flowtests__/__generated__/RelayModernFlowtest_users.graphql.js.flow +2 -2
  17. package/buildReactRelayContainer.js.flow +2 -2
  18. package/hooks.js +1 -1
  19. package/index.js +1 -1
  20. package/legacy.js +1 -1
  21. package/lib/ReactRelayQueryFetcher.js +1 -0
  22. package/lib/ReactRelayQueryRenderer.js +0 -1
  23. package/lib/readContext.js +2 -1
  24. package/lib/relay-hooks/FragmentResource.js +52 -10
  25. package/lib/relay-hooks/HooksImplementation.js +29 -0
  26. package/lib/relay-hooks/MatchContainer.js +1 -0
  27. package/lib/relay-hooks/QueryResource.js +2 -1
  28. package/lib/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js +203 -56
  29. package/lib/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js +254 -109
  30. package/lib/relay-hooks/react-cache/useFragment_REACT_CACHE.js +51 -0
  31. package/lib/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js +13 -2
  32. package/lib/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js +125 -0
  33. package/lib/relay-hooks/useFragment.js +15 -1
  34. package/lib/relay-hooks/useLazyLoadQuery.js +18 -2
  35. package/lib/relay-hooks/useMutation.js +4 -5
  36. package/lib/relay-hooks/usePreloadedQuery.js +18 -2
  37. package/package.json +2 -2
  38. package/react-relay-hooks.js +2 -2
  39. package/react-relay-hooks.min.js +2 -2
  40. package/react-relay-legacy.js +2 -2
  41. package/react-relay-legacy.min.js +2 -2
  42. package/react-relay.js +2 -2
  43. package/react-relay.min.js +2 -2
  44. package/readContext.js.flow +1 -0
  45. package/relay-hooks/FragmentResource.js.flow +55 -9
  46. package/relay-hooks/HooksImplementation.js.flow +45 -0
  47. package/relay-hooks/MatchContainer.js.flow +8 -1
  48. package/relay-hooks/QueryResource.js.flow +4 -2
  49. package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_user.graphql.js.flow +2 -2
  50. package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_users.graphql.js.flow +2 -2
  51. package/relay-hooks/loadQuery.js.flow +2 -1
  52. package/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js.flow +245 -64
  53. package/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js.flow +242 -99
  54. package/relay-hooks/react-cache/useFragment_REACT_CACHE.js.flow +74 -0
  55. package/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js.flow +10 -4
  56. package/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js.flow +153 -0
  57. package/relay-hooks/useFragment.js.flow +17 -10
  58. package/relay-hooks/useLazyLoadQuery.js.flow +38 -3
  59. package/relay-hooks/useMutation.js.flow +3 -3
  60. package/relay-hooks/usePreloadedQuery.js.flow +30 -2
  61. package/relay-hooks/useRefetchableFragmentNode.js.flow +26 -11
  62. package/relay-hooks/useSubscription.js.flow +14 -8
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v13.2.0
2
+ * Relay v14.0.0
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -11,11 +11,11 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
 
13
13
  'use strict';
14
-
15
14
  import type {GeneratedNodeMap, RelayProp, $RelayProps} from './ReactRelayTypes';
16
15
  import type {
17
16
  FragmentMap,
18
17
  FragmentSpecResolver,
18
+ IEnvironment,
19
19
  RelayContext,
20
20
  } from 'relay-runtime';
21
21
 
@@ -58,7 +58,7 @@ function createContainerWithFragments<
58
58
 
59
59
  return class extends React.Component<ContainerProps, ContainerState> {
60
60
  static displayName = containerName;
61
- constructor(props) {
61
+ constructor(props: $FlowFixMe) {
62
62
  super(props);
63
63
  const relayContext = assertRelayContext(props.__relayContext);
64
64
  const rootIsQueryRenderer = props.__rootIsQueryRenderer ?? false;
@@ -163,7 +163,10 @@ function createContainerWithFragments<
163
163
  this.state.resolver.dispose();
164
164
  }
165
165
 
166
- shouldComponentUpdate(nextProps, nextState): boolean {
166
+ shouldComponentUpdate(
167
+ nextProps: ContainerProps,
168
+ nextState: ContainerState,
169
+ ): boolean {
167
170
  // Short-circuit if any Relay-related data has changed
168
171
  if (nextState.data !== this.state.data) {
169
172
  return true;
@@ -247,7 +250,7 @@ function createContainerWithFragments<
247
250
  };
248
251
  }
249
252
 
250
- function getRelayProp(environment) {
253
+ function getRelayProp(environment: IEnvironment) {
251
254
  return {
252
255
  environment,
253
256
  };
@@ -235,7 +235,7 @@ function createGetConnectionFromProps(metadata: ReactConnectionMetadata) {
235
235
  'ReactRelayPaginationContainer: Unable to synthesize a ' +
236
236
  'getConnectionFromProps function.',
237
237
  );
238
- return props => {
238
+ return (props: any) => {
239
239
  let data = props[metadata.fragmentName];
240
240
  for (let i = 0; i < path.length; i++) {
241
241
  if (!data || typeof data !== 'object') {
@@ -264,7 +264,9 @@ function createGetFragmentVariables(
264
264
 
265
265
  type ReactConnectionMetadata = ConnectionMetadata & {fragmentName: string, ...};
266
266
 
267
- function findConnectionMetadata(fragments): ReactConnectionMetadata {
267
+ function findConnectionMetadata(
268
+ fragments: FragmentMap,
269
+ ): ReactConnectionMetadata {
268
270
  let foundConnectionMetadata = null;
269
271
  let isRelayModern = false;
270
272
  for (const fragmentName in fragments) {
@@ -308,7 +310,7 @@ function toObserver(observerOrCallback: ?ObserverOrCallback): Observer<void> {
308
310
  ? {
309
311
  error: observerOrCallback,
310
312
  complete: observerOrCallback,
311
- unsubscribe: subscription => {
313
+ unsubscribe: (subscription: Subscription) => {
312
314
  typeof observerOrCallback === 'function' && observerOrCallback();
313
315
  },
314
316
  }
@@ -356,7 +358,7 @@ function createContainerWithFragments<
356
358
  _isUnmounted: boolean;
357
359
  _hasFetched: boolean;
358
360
 
359
- constructor(props) {
361
+ constructor(props: any) {
360
362
  super(props);
361
363
  const relayContext = assertRelayContext(props.__relayContext);
362
364
  const rootIsQueryRenderer = props.__rootIsQueryRenderer ?? false;
@@ -415,7 +417,7 @@ function createContainerWithFragments<
415
417
  * for updates. Props may be the same in which case previous data and
416
418
  * subscriptions can be reused.
417
419
  */
418
- UNSAFE_componentWillReceiveProps(nextProps) {
420
+ UNSAFE_componentWillReceiveProps(nextProps: any) {
419
421
  const relayContext = assertRelayContext(nextProps.__relayContext);
420
422
  const rootIsQueryRenderer = nextProps.__rootIsQueryRenderer ?? false;
421
423
  const prevIDs = getDataIDsFromObject(fragments, this.props);
@@ -479,7 +481,10 @@ function createContainerWithFragments<
479
481
  this._cleanup();
480
482
  }
481
483
 
482
- shouldComponentUpdate(nextProps, nextState): boolean {
484
+ shouldComponentUpdate(
485
+ nextProps: Props,
486
+ nextState: ContainerState,
487
+ ): boolean {
483
488
  // Short-circuit if any Relay-related data has changed
484
489
  if (
485
490
  nextState.data !== this.state.data ||
@@ -722,7 +727,7 @@ function createContainerWithFragments<
722
727
  return this._queryFetcher;
723
728
  }
724
729
 
725
- _canFetchPage(method): boolean {
730
+ _canFetchPage(method: 'loadMore' | 'refetchConnection'): boolean {
726
731
  if (this._isUnmounted) {
727
732
  warning(
728
733
  false,
@@ -813,7 +818,7 @@ function createContainerWithFragments<
813
818
  }
814
819
  this._hasFetched = true;
815
820
 
816
- const onNext = (payload, complete) => {
821
+ const onNext = (payload: mixed, complete: () => void) => {
817
822
  const prevData = this._resolver.resolve();
818
823
  this._resolver.setVariables(
819
824
  getFragmentVariables(
@@ -194,6 +194,7 @@ class ReactRelayQueryFetcher {
194
194
  onDataChange &&
195
195
  this._fetchOptions.onDataChangeCallbacks.indexOf(onDataChange) === -1
196
196
  ) {
197
+ // $FlowFixMe[incompatible-use]
197
198
  this._fetchOptions.onDataChangeCallbacks.push(onDataChange);
198
199
  }
199
200
 
@@ -29,7 +29,6 @@ const ReactRelayQueryRendererContext = require('./ReactRelayQueryRendererContext
29
29
  const areEqual = require('areEqual');
30
30
  const React = require('react');
31
31
  const {
32
- RelayFeatureFlags,
33
32
  createOperationDescriptor,
34
33
  deepFreeze,
35
34
  getRequest,
@@ -56,7 +55,12 @@ export type RenderProps<T> = {|
56
55
  * constructor. If a request is already in flight from a previous call to the
57
56
  * constructor, just reuse the query fetcher and wait for the response.
58
57
  */
59
- const requestCache = {};
58
+ const requestCache: {
59
+ [string]: void | {|
60
+ queryFetcher: ReactRelayQueryFetcher,
61
+ snapshot: ?Snapshot,
62
+ |},
63
+ } = {};
60
64
 
61
65
  const queryRendererContext: ReactRelayQueryRendererContextType = {
62
66
  rootIsQueryRenderer: true,
@@ -24,6 +24,7 @@ import type {
24
24
  Disposable,
25
25
  FragmentMap,
26
26
  GraphQLTaggedNode,
27
+ IEnvironment,
27
28
  RelayContext,
28
29
  Subscription,
29
30
  Variables,
@@ -86,7 +87,7 @@ function createContainerWithFragments<
86
87
  _queryFetcher: ?ReactRelayQueryFetcher;
87
88
  _isUnmounted: boolean;
88
89
 
89
- constructor(props) {
90
+ constructor(props: any) {
90
91
  super(props);
91
92
  const relayContext = assertRelayContext(props.__relayContext);
92
93
  const rootIsQueryRenderer = props.__rootIsQueryRenderer ?? false;
@@ -217,7 +218,10 @@ function createContainerWithFragments<
217
218
  this._refetchSubscription && this._refetchSubscription.unsubscribe();
218
219
  }
219
220
 
220
- shouldComponentUpdate(nextProps, nextState): boolean {
221
+ shouldComponentUpdate(
222
+ nextProps: ContainerProps,
223
+ nextState: ContainerState,
224
+ ): boolean {
221
225
  // Short-circuit if any Relay-related data has changed
222
226
  if (
223
227
  nextState.data !== this.state.data ||
@@ -465,7 +469,10 @@ function createContainerWithFragments<
465
469
  };
466
470
  }
467
471
 
468
- function getRelayProp(environment, refetch): RelayRefetchProp {
472
+ function getRelayProp(
473
+ environment: IEnvironment,
474
+ refetch: RelayRefetchProp['refetch'],
475
+ ): RelayRefetchProp {
469
476
  return {
470
477
  environment,
471
478
  refetch,
@@ -1,10 +1,10 @@
1
1
  /**
2
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.
6
6
  *
7
- * @generated SignedSource<<56e1daf6db87bf9886b3627a3e0d76f9>>
7
+ * @generated SignedSource<<23bcef30afc22a42d79dd52e0cfe899c>>
8
8
  * @flow
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
@@ -1,10 +1,10 @@
1
1
  /**
2
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.
6
6
  *
7
- * @generated SignedSource<<c4fb5411e941bc7c5102499b684cf810>>
7
+ * @generated SignedSource<<af6c4570779066ea564051c9c71c494f>>
8
8
  * @flow
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
@@ -1,10 +1,10 @@
1
1
  /**
2
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.
6
6
  *
7
- * @generated SignedSource<<059d6a6d94da6f9b3cf43a0418ecc7b8>>
7
+ * @generated SignedSource<<6d173a357c286b417fdc586a839384d4>>
8
8
  * @flow
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
@@ -27,8 +27,8 @@ export type ReactRelayPaginationContainerFlowtestQuery$data = {|
27
27
  |},
28
28
  |};
29
29
  export type ReactRelayPaginationContainerFlowtestQuery = {|
30
- variables: ReactRelayPaginationContainerFlowtestQuery$variables,
31
30
  response: ReactRelayPaginationContainerFlowtestQuery$data,
31
+ variables: ReactRelayPaginationContainerFlowtestQuery$variables,
32
32
  |};
33
33
  */
34
34
 
@@ -1,10 +1,10 @@
1
1
  /**
2
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.
6
6
  *
7
- * @generated SignedSource<<86f990ee88078c49934d0f28c6c31da4>>
7
+ * @generated SignedSource<<b3cddee250d0ff22e89a7f0331e85df6>>
8
8
  * @flow
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
@@ -23,7 +23,7 @@ export type ReactRelayPaginationContainerFlowtest_viewer$data = {|
23
23
  +friends: ?{|
24
24
  +edges: ?$ReadOnlyArray<?{|
25
25
  +node: ?{|
26
- +__typename: string,
26
+ +__typename: "User",
27
27
  |},
28
28
  |}>,
29
29
  |},
@@ -1,10 +1,10 @@
1
1
  /**
2
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.
6
6
  *
7
- * @generated SignedSource<<a07bf128347274d353ab379de5eaef1f>>
7
+ * @generated SignedSource<<3b1b16b5d5ec1c94783d6161ae61bc3d>>
8
8
  * @flow
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
@@ -27,8 +27,8 @@ export type ReactRelayRefetchContainerFlowtestQuery$data = {|
27
27
  |},
28
28
  |};
29
29
  export type ReactRelayRefetchContainerFlowtestQuery = {|
30
- variables: ReactRelayRefetchContainerFlowtestQuery$variables,
31
30
  response: ReactRelayRefetchContainerFlowtestQuery$data,
31
+ variables: ReactRelayRefetchContainerFlowtestQuery$variables,
32
32
  |};
33
33
  */
34
34
 
@@ -1,10 +1,10 @@
1
1
  /**
2
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.
6
6
  *
7
- * @generated SignedSource<<6d9922010e1474b1214c383c394daa24>>
7
+ * @generated SignedSource<<6d04d7f7bf097d5869a1fdf0dea1e659>>
8
8
  * @flow
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
@@ -23,7 +23,7 @@ export type ReactRelayRefetchContainerFlowtest_viewer$data = {|
23
23
  +friends: ?{|
24
24
  +edges: ?$ReadOnlyArray<?{|
25
25
  +node: ?{|
26
- +__typename: string,
26
+ +__typename: "User",
27
27
  |},
28
28
  |}>,
29
29
  |},
@@ -1,10 +1,10 @@
1
1
  /**
2
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.
6
6
  *
7
- * @generated SignedSource<<050146f21476e7ed6edd2243d4c6b65d>>
7
+ * @generated SignedSource<<d3c71cb965d8374d40fb30f3c5ae9fd4>>
8
8
  * @flow
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
@@ -1,10 +1,10 @@
1
1
  /**
2
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.
6
6
  *
7
- * @generated SignedSource<<d8eae7df6faa43d95f6140dc3c9ad3ba>>
7
+ * @generated SignedSource<<bd60df80c19d8248426865abbc23562e>>
8
8
  * @flow
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
@@ -1,10 +1,10 @@
1
1
  /**
2
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.
6
6
  *
7
- * @generated SignedSource<<a7ba31d9d2381b0c8b700175be271b75>>
7
+ * @generated SignedSource<<527809017626cb43378afb92fed67feb>>
8
8
  * @flow
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
@@ -1,10 +1,10 @@
1
1
  /**
2
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.
6
6
  *
7
- * @generated SignedSource<<d032f6e721c9c9cdd034cdd93dfcbad6>>
7
+ * @generated SignedSource<<8a94ce305c03af7280da9b95a665349f>>
8
8
  * @flow
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
@@ -11,7 +11,7 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
 
13
13
  'use strict';
14
-
14
+ import type {ReaderFragment} from '../relay-runtime/util/ReaderNode';
15
15
  import type {GeneratedNodeMap} from './ReactRelayTypes';
16
16
  import type {FragmentMap} from 'relay-runtime';
17
17
 
@@ -45,7 +45,7 @@ function buildReactRelayContainer<TBase: React$ComponentType<any>>(
45
45
  const containerName = getContainerName(ComponentClass);
46
46
  assertFragmentMap(getComponentName(ComponentClass), fragmentSpec);
47
47
 
48
- const fragments = {};
48
+ const fragments: {[string]: ReaderFragment} = {};
49
49
  for (const key in fragmentSpec) {
50
50
  fragments[key] = getFragment(fragmentSpec[key]);
51
51
  }
package/hooks.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v13.2.0
2
+ * Relay v14.0.0
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v13.2.0
2
+ * Relay v14.0.0
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
package/legacy.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v13.2.0
2
+ * Relay v14.0.0
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -153,6 +153,7 @@ var ReactRelayQueryFetcher = /*#__PURE__*/function () {
153
153
  };
154
154
 
155
155
  if (onDataChange && this._fetchOptions.onDataChangeCallbacks.indexOf(onDataChange) === -1) {
156
+ // $FlowFixMe[incompatible-use]
156
157
  this._fetchOptions.onDataChangeCallbacks.push(onDataChange);
157
158
  }
158
159
 
@@ -31,7 +31,6 @@ var areEqual = require("fbjs/lib/areEqual");
31
31
  var React = require('react');
32
32
 
33
33
  var _require = require('relay-runtime'),
34
- RelayFeatureFlags = _require.RelayFeatureFlags,
35
34
  createOperationDescriptor = _require.createOperationDescriptor,
36
35
  deepFreeze = _require.deepFreeze,
37
36
  getRequest = _require.getRequest;
@@ -10,7 +10,8 @@
10
10
  // flowlint ambiguous-object-type:error
11
11
  'use strict';
12
12
 
13
- var React = require('react');
13
+ var React = require('react'); // $FlowFixMe[incompatible-use]
14
+
14
15
 
15
16
  var _React$__SECRET_INTER =
16
17
  /* $FlowFixMe[prop-missing] Flow doesn't know about React's internals for
@@ -74,6 +74,16 @@ function hasMissingClientEdges(snapshot) {
74
74
  return ((_snapshot$missingClie = (_snapshot$missingClie2 = snapshot.missingClientEdges) === null || _snapshot$missingClie2 === void 0 ? void 0 : _snapshot$missingClie2.length) !== null && _snapshot$missingClie !== void 0 ? _snapshot$missingClie : 0) > 0;
75
75
  }
76
76
 
77
+ function missingLiveResolverFields(snapshot) {
78
+ if (Array.isArray(snapshot)) {
79
+ return snapshot.map(function (s) {
80
+ return s.missingLiveResolverFields;
81
+ }).filter(Boolean).flat();
82
+ }
83
+
84
+ return snapshot.missingLiveResolverFields;
85
+ }
86
+
77
87
  function singularOrPluralForEach(snapshot, f) {
78
88
  if (Array.isArray(snapshot)) {
79
89
  snapshot.forEach(f);
@@ -210,7 +220,7 @@ var FragmentResourceImpl = /*#__PURE__*/function () {
210
220
  _proto2.readWithIdentifier = function readWithIdentifier(fragmentNode, fragmentRef, fragmentIdentifier, componentDisplayName, fragmentKey) {
211
221
  var _this3 = this;
212
222
 
213
- var _fragmentNode$metadat, _clientEdgePromises;
223
+ var _fragmentNode$metadat, _fragmentNode$metadat2, _missingLiveResolverF2, _missingLiveResolverF3;
214
224
 
215
225
  var environment = this._environment; // If fragmentRef is null or undefined, pass it directly through.
216
226
  // This is a convenience when consuming fragments via a HOC API, when the
@@ -248,6 +258,8 @@ var FragmentResourceImpl = /*#__PURE__*/function () {
248
258
  var cachedValue = this._cache.get(fragmentIdentifier);
249
259
 
250
260
  if (cachedValue != null) {
261
+ var _missingLiveResolverF;
262
+
251
263
  if (cachedValue.kind === 'pending' && isPromise(cachedValue.promise)) {
252
264
  environment.__log({
253
265
  name: 'suspense.fragment',
@@ -262,7 +274,7 @@ var FragmentResourceImpl = /*#__PURE__*/function () {
262
274
  throw cachedValue.promise;
263
275
  }
264
276
 
265
- if (cachedValue.kind === 'done' && cachedValue.result.snapshot) {
277
+ if (cachedValue.kind === 'done' && cachedValue.result.snapshot && !((_missingLiveResolverF = missingLiveResolverFields(cachedValue.result.snapshot)) === null || _missingLiveResolverF === void 0 ? void 0 : _missingLiveResolverF.length)) {
266
278
  this._handlePotentialSnapshotErrorsInSnapshot(cachedValue.result.snapshot);
267
279
 
268
280
  return cachedValue.result;
@@ -300,7 +312,7 @@ var FragmentResourceImpl = /*#__PURE__*/function () {
300
312
 
301
313
  var clientEdgeRequests = null;
302
314
 
303
- if (RelayFeatureFlags.ENABLE_CLIENT_EDGES && hasMissingClientEdges(snapshot)) {
315
+ if (RelayFeatureFlags.ENABLE_CLIENT_EDGES && ((_fragmentNode$metadat2 = fragmentNode.metadata) === null || _fragmentNode$metadat2 === void 0 ? void 0 : _fragmentNode$metadat2.hasClientEdges) === true && hasMissingClientEdges(snapshot)) {
304
316
  clientEdgeRequests = [];
305
317
  var queryResource = getQueryResourceForEnvironment(this._environment);
306
318
  var queryResults = [];
@@ -328,14 +340,12 @@ var FragmentResourceImpl = /*#__PURE__*/function () {
328
340
  this._clientEdgeQueryResultsCache.recordQueryResults(fragmentIdentifier, queryResults);
329
341
  }
330
342
 
331
- var clientEdgePromises = null;
343
+ var clientEdgePromises = [];
332
344
 
333
345
  if (RelayFeatureFlags.ENABLE_CLIENT_EDGES && clientEdgeRequests) {
334
346
  clientEdgePromises = clientEdgeRequests.map(function (request) {
335
347
  return getPromiseForActiveRequest(_this3._environment, request);
336
- }).filter(function (p) {
337
- return p != null;
338
- });
348
+ }).filter(Boolean);
339
349
  } // Finally look for operations in flight for our parent query:
340
350
 
341
351
 
@@ -345,8 +355,15 @@ var FragmentResourceImpl = /*#__PURE__*/function () {
345
355
 
346
356
  var parentQueryPromiseResultPromise = parentQueryPromiseResult === null || parentQueryPromiseResult === void 0 ? void 0 : parentQueryPromiseResult.promise; // for refinement
347
357
 
348
- if (((_clientEdgePromises = clientEdgePromises) === null || _clientEdgePromises === void 0 ? void 0 : _clientEdgePromises.length) || isPromise(parentQueryPromiseResultPromise)) {
349
- var _parentQueryPromiseRe, _clientEdgeRequests2, _clientEdgePromises2;
358
+ var missingResolverFieldPromises = (_missingLiveResolverF2 = (_missingLiveResolverF3 = missingLiveResolverFields(snapshot)) === null || _missingLiveResolverF3 === void 0 ? void 0 : _missingLiveResolverF3.map(function (_ref2) {
359
+ var liveStateID = _ref2.liveStateID;
360
+ var store = environment.getStore(); // $FlowFixMe[prop-missing] This is expected to be a LiveResolverStore
361
+
362
+ return store.getLiveResolverPromise(liveStateID);
363
+ })) !== null && _missingLiveResolverF2 !== void 0 ? _missingLiveResolverF2 : [];
364
+
365
+ if (clientEdgePromises.length || missingResolverFieldPromises.length || isPromise(parentQueryPromiseResultPromise)) {
366
+ var _parentQueryPromiseRe, _clientEdgeRequests2;
350
367
 
351
368
  environment.__log({
352
369
  name: 'suspense.fragment',
@@ -355,10 +372,34 @@ var FragmentResourceImpl = /*#__PURE__*/function () {
355
372
  isRelayHooks: true,
356
373
  isPromiseCached: false,
357
374
  isMissingData: fragmentResult.isMissingData,
375
+ // TODO! Attach information here about missing live resolver fields
358
376
  pendingOperations: [].concat((0, _toConsumableArray2["default"])((_parentQueryPromiseRe = parentQueryPromiseResult === null || parentQueryPromiseResult === void 0 ? void 0 : parentQueryPromiseResult.pendingOperations) !== null && _parentQueryPromiseRe !== void 0 ? _parentQueryPromiseRe : []), (0, _toConsumableArray2["default"])((_clientEdgeRequests2 = clientEdgeRequests) !== null && _clientEdgeRequests2 !== void 0 ? _clientEdgeRequests2 : []))
359
377
  });
360
378
 
361
- throw ((_clientEdgePromises2 = clientEdgePromises) === null || _clientEdgePromises2 === void 0 ? void 0 : _clientEdgePromises2.length) ? Promise.all([parentQueryPromiseResultPromise].concat((0, _toConsumableArray2["default"])(clientEdgePromises))) : parentQueryPromiseResultPromise;
379
+ var promises = [];
380
+
381
+ if (clientEdgePromises.length > 0) {
382
+ promises = promises.concat(clientEdgePromises);
383
+ }
384
+
385
+ if (missingResolverFieldPromises.length > 0) {
386
+ promises = promises.concat(missingResolverFieldPromises);
387
+ }
388
+
389
+ if (promises.length > 0) {
390
+ if (parentQueryPromiseResultPromise) {
391
+ promises.push(parentQueryPromiseResultPromise);
392
+ }
393
+
394
+ throw Promise.all(promises);
395
+ } // Note: we are re-throwing the `parentQueryPromiseResultPromise` here,
396
+ // because some of our suspense-related code is relying on the instance equality
397
+ // of thrown promises. See FragmentResource-test.js
398
+
399
+
400
+ if (parentQueryPromiseResultPromise) {
401
+ throw parentQueryPromiseResultPromise;
402
+ }
362
403
  }
363
404
 
364
405
  this._handlePotentialSnapshotErrorsInSnapshot(snapshot);
@@ -553,6 +594,7 @@ var FragmentResourceImpl = /*#__PURE__*/function () {
553
594
  data: updatedData,
554
595
  isMissingData: currentSnapshot.isMissingData,
555
596
  missingClientEdges: currentSnapshot.missingClientEdges,
597
+ missingLiveResolverFields: currentSnapshot.missingLiveResolverFields,
556
598
  seenRecords: currentSnapshot.seenRecords,
557
599
  selector: currentSnapshot.selector,
558
600
  missingRequiredFields: currentSnapshot.missingRequiredFields,
@@ -0,0 +1,29 @@
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
+ * @emails oncall+relay
8
+ *
9
+ * @format
10
+ */
11
+ 'use strict'; // flowlint ambiguous-object-type:error
12
+
13
+ var warning = require("fbjs/lib/warning");
14
+
15
+ var implementation = null;
16
+
17
+ function inject(impl) {
18
+ process.env.NODE_ENV !== "production" ? warning(implementation !== null, 'Relay HooksImplementation was injected twice.') : void 0;
19
+ implementation = impl;
20
+ }
21
+
22
+ function get() {
23
+ return implementation;
24
+ }
25
+
26
+ module.exports = {
27
+ inject: inject,
28
+ get: get
29
+ };
@@ -137,6 +137,7 @@ function MatchContainer(_ref2) {
137
137
 
138
138
  if (LoadedContainer != null && fragmentProps != null) {
139
139
  // $FlowFixMe[incompatible-type]
140
+ // $FlowFixMe[cannot-spread-indexer]
140
141
  return /*#__PURE__*/React.createElement(LoadedContainer, (0, _extends2["default"])({}, props, fragmentProps));
141
142
  } else {
142
143
  return fallback !== null && fallback !== void 0 ? fallback : null;
@@ -266,7 +266,8 @@ var QueryResourceImpl = /*#__PURE__*/function () {
266
266
  var hasFullQuery = queryStatus === 'available';
267
267
  var canPartialRender = hasFullQuery || renderPolicy === 'partial' && queryStatus !== 'stale';
268
268
  var shouldFetch;
269
- var shouldAllowRender;
269
+ var shouldAllowRender; // Different definitions for Promise in our repos can cause this variable
270
+ // to cause errors when synced elsewhere
270
271
 
271
272
  var resolveNetworkPromise = function resolveNetworkPromise() {};
272
273