react-relay 15.0.0 → 16.1.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 (126) hide show
  1. package/ReactRelayContext.js +1 -1
  2. package/ReactRelayQueryFetcher.js.flow +1 -5
  3. package/ReactRelayQueryRenderer.js.flow +9 -36
  4. package/ReactRelayTypes.js.flow +1 -0
  5. package/buildReactRelayContainer.js.flow +3 -1
  6. package/hooks.js +1 -1
  7. package/index.js +1 -1
  8. package/legacy.js +1 -1
  9. package/lib/ReactRelayContainerUtils.js +0 -11
  10. package/lib/ReactRelayContext.js +0 -11
  11. package/lib/ReactRelayFragmentContainer.js +6 -78
  12. package/lib/ReactRelayFragmentMockRenderer.js +0 -11
  13. package/lib/ReactRelayLocalQueryRenderer.js +0 -17
  14. package/lib/ReactRelayPaginationContainer.js +5 -208
  15. package/lib/ReactRelayQueryFetcher.js +2 -51
  16. package/lib/ReactRelayQueryRenderer.js +6 -94
  17. package/lib/ReactRelayQueryRendererContext.js +0 -11
  18. package/lib/ReactRelayRefetchContainer.js +5 -91
  19. package/lib/ReactRelayTestMocker.js +9 -85
  20. package/lib/ReactRelayTypes.js +0 -11
  21. package/lib/RelayContext.js +0 -21
  22. package/lib/assertFragmentMap.js +0 -15
  23. package/lib/buildReactRelayContainer.js +0 -19
  24. package/lib/getRootVariablesForFragments.js +0 -14
  25. package/lib/hooks.js +0 -15
  26. package/lib/index.js +0 -17
  27. package/lib/isRelayEnvironment.js +1 -18
  28. package/lib/jest-react/enqueueTask.js +0 -20
  29. package/lib/jest-react/internalAct.js +0 -38
  30. package/lib/legacy.js +0 -15
  31. package/lib/multi-actor/ActorChange.js +0 -11
  32. package/lib/multi-actor/index.js +0 -11
  33. package/lib/multi-actor/useRelayActorEnvironment.js +0 -11
  34. package/lib/relay-hooks/EntryPointContainer.react.js +0 -11
  35. package/lib/relay-hooks/EntryPointTypes.flow.js +1 -14
  36. package/lib/relay-hooks/FragmentResource.js +76 -132
  37. package/lib/relay-hooks/HooksImplementation.js +1 -12
  38. package/lib/relay-hooks/InternalLogger.js +0 -11
  39. package/lib/relay-hooks/LRUCache.js +0 -22
  40. package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +0 -18
  41. package/lib/relay-hooks/MatchContainer.js +0 -94
  42. package/lib/relay-hooks/NestedRelayEntryPointBuilderUtils.js +9 -0
  43. package/lib/relay-hooks/ProfilerContext.js +0 -15
  44. package/lib/relay-hooks/QueryResource.js +2 -68
  45. package/lib/relay-hooks/RelayEnvironmentProvider.js +0 -11
  46. package/lib/relay-hooks/SuspenseResource.js +0 -34
  47. package/lib/relay-hooks/{react-cache/readFragmentInternal_REACT_CACHE.js → experimental/readFragmentInternal_EXPERIMENTAL.js} +5 -29
  48. package/lib/relay-hooks/{react-cache/useFragmentInternal_REACT_CACHE.js → experimental/useFragmentInternal_EXPERIMENTAL.js} +35 -100
  49. package/lib/relay-hooks/{react-cache/useFragment_REACT_CACHE.js → experimental/useFragment_EXPERIMENTAL.js} +1 -16
  50. package/lib/relay-hooks/{react-cache/usePaginationFragment_REACT_CACHE.js → experimental/usePaginationFragment_EXPERIMENTAL.js} +2 -24
  51. package/lib/relay-hooks/{react-cache/useRefetchableFragmentInternal_REACT_CACHE.js → experimental/useRefetchableFragmentInternal_EXPERIMENTAL.js} +14 -98
  52. package/lib/relay-hooks/{react-cache/useRefetchableFragment_REACT_CACHE.js → experimental/useRefetchableFragment_EXPERIMENTAL.js} +1 -15
  53. package/lib/relay-hooks/loadEntryPoint.js +1 -24
  54. package/lib/relay-hooks/loadQuery.js +2 -106
  55. package/lib/relay-hooks/preloadQuery_DEPRECATED.js +2 -27
  56. package/lib/relay-hooks/prepareEntryPoint_DEPRECATED.js +0 -13
  57. package/lib/relay-hooks/useBlockingPaginationFragment.js +0 -42
  58. package/lib/relay-hooks/useClientQuery.js +0 -18
  59. package/lib/relay-hooks/useEntryPointLoader.js +0 -69
  60. package/lib/relay-hooks/useFetchTrackingRef.js +0 -26
  61. package/lib/relay-hooks/useFragment.js +0 -17
  62. package/lib/relay-hooks/useFragmentNode.js +2 -32
  63. package/lib/relay-hooks/useIsMountedRef.js +0 -11
  64. package/lib/relay-hooks/useIsOperationNodeActive.js +0 -11
  65. package/lib/relay-hooks/useIsParentQueryActive.js +0 -11
  66. package/lib/relay-hooks/useLazyLoadQuery.js +0 -18
  67. package/lib/relay-hooks/useLazyLoadQueryNode.js +12 -37
  68. package/lib/relay-hooks/useLoadMoreFunction.js +9 -34
  69. package/lib/relay-hooks/useMemoOperationDescriptor.js +0 -11
  70. package/lib/relay-hooks/useMemoVariables.js +0 -17
  71. package/lib/relay-hooks/useMutation.js +0 -11
  72. package/lib/relay-hooks/usePaginationFragment.js +1 -26
  73. package/lib/relay-hooks/usePreloadedQuery.js +0 -27
  74. package/lib/relay-hooks/useQueryLoader.js +0 -74
  75. package/lib/relay-hooks/useRefetchableFragment.js +0 -16
  76. package/lib/relay-hooks/useRefetchableFragmentNode.js +14 -97
  77. package/lib/relay-hooks/useRelayEnvironment.js +0 -11
  78. package/lib/relay-hooks/useStaticFragmentNodeWarning.js +0 -15
  79. package/lib/relay-hooks/useSubscribeToInvalidationState.js +0 -25
  80. package/lib/relay-hooks/useSubscription.js +0 -15
  81. package/lib/relay-hooks/useUnsafeRef_DEPRECATED.js +0 -17
  82. package/package.json +2 -2
  83. package/react-relay-hooks.js +2 -2
  84. package/react-relay-hooks.min.js +2 -2
  85. package/react-relay-legacy.js +2 -2
  86. package/react-relay-legacy.min.js +2 -2
  87. package/react-relay.js +2 -2
  88. package/react-relay.min.js +2 -2
  89. package/relay-hooks/EntryPointContainer.react.js.flow +5 -0
  90. package/relay-hooks/EntryPointTypes.flow.js.flow +34 -35
  91. package/relay-hooks/FragmentResource.js.flow +114 -26
  92. package/relay-hooks/HooksImplementation.js.flow +3 -1
  93. package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +4 -2
  94. package/relay-hooks/NestedRelayEntryPointBuilderUtils.js.flow +51 -0
  95. package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +7 -5
  96. package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +5 -0
  97. package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +5 -0
  98. package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +2 -0
  99. package/relay-hooks/{react-cache/readFragmentInternal_REACT_CACHE.js.flow → experimental/readFragmentInternal_EXPERIMENTAL.js.flow} +4 -3
  100. package/relay-hooks/{react-cache/useFragmentInternal_REACT_CACHE.js.flow → experimental/useFragmentInternal_EXPERIMENTAL.js.flow} +32 -14
  101. package/relay-hooks/{react-cache/useFragment_REACT_CACHE.js.flow → experimental/useFragment_EXPERIMENTAL.js.flow} +4 -10
  102. package/relay-hooks/{react-cache/usePaginationFragment_REACT_CACHE.js.flow → experimental/usePaginationFragment_EXPERIMENTAL.js.flow} +30 -59
  103. package/relay-hooks/{react-cache/useRefetchableFragmentInternal_REACT_CACHE.js.flow → experimental/useRefetchableFragmentInternal_EXPERIMENTAL.js.flow} +30 -23
  104. package/relay-hooks/experimental/useRefetchableFragment_EXPERIMENTAL.js.flow +49 -0
  105. package/relay-hooks/loadEntryPoint.js.flow +4 -2
  106. package/relay-hooks/loadQuery.js.flow +21 -1
  107. package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +4 -2
  108. package/relay-hooks/useBlockingPaginationFragment.js.flow +10 -17
  109. package/relay-hooks/useClientQuery.js.flow +2 -2
  110. package/relay-hooks/useFragmentNode.js.flow +2 -2
  111. package/relay-hooks/useLazyLoadQueryNode.js.flow +17 -1
  112. package/relay-hooks/useLoadMoreFunction.js.flow +15 -9
  113. package/relay-hooks/useMutation.js.flow +26 -9
  114. package/relay-hooks/usePaginationFragment.js.flow +7 -15
  115. package/relay-hooks/useQueryLoader.js.flow +2 -8
  116. package/relay-hooks/useRefetchableFragment.js.flow +14 -16
  117. package/relay-hooks/useRefetchableFragmentNode.js.flow +33 -20
  118. package/lib/relay-hooks/react-cache/RelayReactCache.js +0 -32
  119. package/lib/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js +0 -290
  120. package/lib/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js +0 -49
  121. package/lib/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js +0 -110
  122. package/relay-hooks/react-cache/RelayReactCache.js.flow +0 -40
  123. package/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js.flow +0 -430
  124. package/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js.flow +0 -70
  125. package/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js.flow +0 -150
  126. package/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js.flow +0 -65
@@ -1,14 +1,3 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- * @oncall relay
10
- */
11
-
12
1
  'use strict';
13
2
 
14
3
  var preloadQuery_DEPRECATED = require('./preloadQuery_DEPRECATED');
@@ -26,7 +15,6 @@ function stableStringify(value) {
26
15
  return (_JSON$stringify = JSON.stringify(stableCopy(value))) !== null && _JSON$stringify !== void 0 ? _JSON$stringify : 'null';
27
16
  }
28
17
  function prepareEntryPoint(environmentProvider, entryPoint, entryPointParams) {
29
- // Start loading the code for the entrypoint
30
18
  var loadingPromise = null;
31
19
  if (entryPoint.root.getModuleIfRequired() == null) {
32
20
  loadingPromise = entryPoint.root.load();
@@ -71,7 +59,6 @@ function prepareEntryPoint(environmentProvider, entryPoint, entryPointParams) {
71
59
  loadingPromise = (_loadingPromise = loadingPromise) !== null && _loadingPromise !== void 0 ? _loadingPromise : entryPoint.root.load();
72
60
  throw loadingPromise;
73
61
  }
74
- // $FlowFixMe[incompatible-cast] - trust me Flow, its entryPoint component
75
62
  return component;
76
63
  },
77
64
  queries: preloadedQueries,
@@ -85,9 +72,6 @@ function LazyLoadEntryPointContainer_DEPRECATED(_ref) {
85
72
  environmentProvider = _ref.environmentProvider;
86
73
  var environment = useRelayEnvironment();
87
74
  var getPreloadProps = entryPoint.getPreloadProps;
88
- // IMPORTANT: Loading the component may suspend (throw), so the props
89
- // *must* be computed first to fetch the component's data-dependencies in
90
- // parallel with the component itself (the code).
91
75
  var entryPointParamsHash = stableStringify(entryPointParams);
92
76
  var _useMemo = useMemo(function () {
93
77
  return prepareEntryPoint(environmentProvider !== null && environmentProvider !== void 0 ? environmentProvider : {
@@ -95,8 +79,6 @@ function LazyLoadEntryPointContainer_DEPRECATED(_ref) {
95
79
  return environment;
96
80
  }
97
81
  }, entryPoint, entryPointParams);
98
- // NOTE: stableParams encodes the information from params
99
- // eslint-disable-next-line react-hooks/exhaustive-deps
100
82
  }, [environment, environmentProvider, getPreloadProps, entryPointParamsHash]),
101
83
  getComponent = _useMemo.getComponent,
102
84
  queries = _useMemo.queries,
@@ -1,92 +1,9 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- * @oncall relay
10
- */
11
-
12
1
  'use strict';
13
2
 
14
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
15
4
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
16
5
  var React = require('react');
17
6
  var useMemo = React.useMemo;
18
-
19
- /**
20
- * Renders the results of a data-driven dependency fetched with the `@match`
21
- * directive. The `@match` directive can be used to specify a mapping of
22
- * result types to the containers used to render those types. The result
23
- * value is an opaque object that described which component was selected
24
- * and a reference to its data. Use <MatchContainer/> to render these
25
- * values.
26
- *
27
- * ## Example
28
- *
29
- * For example, consider a piece of media content that might be text or
30
- * an image, where for clients that don't support images the application
31
- * should fall back to rendering the image caption as text. @match can be
32
- * used to dynamically select whether to render a given media item as
33
- * an image or text (on the server) and then fetch the corresponding
34
- * React component and its data dependencies (information about the
35
- * image or about the text).
36
- *
37
- * ```
38
- * // Media.react.js
39
- *
40
- * // Define a React component that uses <MatchContainer /> to render the
41
- * // results of a @module selection
42
- * function Media(props) {
43
- * const {media, ...restProps} = props;
44
- *
45
- * const loader = moduleReference => {
46
- * // given the data returned by your server for the @module directive,
47
- * // return the React component (or throw a Suspense promise if
48
- * // it is loading asynchronously).
49
- * todo_returnModuleOrThrowPromise(moduleReference);
50
- * };
51
- * return <MatchContainer
52
- * loader={loader}
53
- * match={media.mediaAttachment}
54
- * props={restProps}
55
- * />;
56
- * }
57
- *
58
- * module.exports = createSuspenseFragmentContainer(
59
- * Media,
60
- * {
61
- * media: graphql`
62
- * fragment Media_media on Media {
63
- * # ...
64
- * mediaAttachment @match {
65
- * ...ImageContainer_image @module(name: "ImageContainer.react")
66
- * ...TextContainer_text @module(name: "TextContainer.react")
67
- * }
68
- * }
69
- * `
70
- * },
71
- * );
72
- * ```
73
- *
74
- * ## API
75
- *
76
- * MatchContainer accepts the following props:
77
- * - `match`: The results (an opaque object) of a `@match` field.
78
- * - `props`: Props that should be passed through to the dynamically
79
- * selected component. Note that any of the components listed in
80
- * `@module()` could be selected, so all components should accept
81
- * the value passed here.
82
- * - `loader`: A function to load a module given a reference (whatever
83
- * your server returns for the `js(moduleName: String)` field).
84
- *
85
- */
86
-
87
- // Note: this type is intentionally non-exact, it is expected that the
88
- // object may contain sibling fields.
89
-
90
7
  function MatchContainer(_ref2) {
91
8
  var _ref;
92
9
  var fallback = _ref2.fallback,
@@ -96,13 +13,6 @@ function MatchContainer(_ref2) {
96
13
  if (match != null && typeof match !== 'object') {
97
14
  throw new Error('MatchContainer: Expected `match` value to be an object or null/undefined.');
98
15
  }
99
- // NOTE: the MatchPointer type has a $fragmentSpreads field to ensure that only
100
- // an object that contains a FragmentSpread can be passed. If the fragment
101
- // spread matches, then the metadata fields below (__id, __fragments, etc.)
102
- // will be present. But they can be missing if all the fragment spreads use
103
- // @module and none of the types matched. The cast here is necessary because
104
- // fragment Flow types don't describe metadata fields, only the actual schema
105
- // fields the developer selected.
106
16
  var _ref3 = (_ref = match) !== null && _ref !== void 0 ? _ref : {},
107
17
  __id = _ref3.__id,
108
18
  __fragments = _ref3.__fragments,
@@ -114,8 +24,6 @@ function MatchContainer(_ref2) {
114
24
  }
115
25
  var LoadedContainer = __module_component != null ? loader(__module_component) : null;
116
26
  var fragmentProps = useMemo(function () {
117
- // TODO: Perform this transformation in RelayReader so that unchanged
118
- // output of subscriptions already has a stable identity.
119
27
  if (__fragmentPropName != null && __id != null && __fragments != null) {
120
28
  var fragProps = {};
121
29
  fragProps[__fragmentPropName] = {
@@ -128,8 +36,6 @@ function MatchContainer(_ref2) {
128
36
  return null;
129
37
  }, [__id, __fragments, __fragmentOwner, __fragmentPropName]);
130
38
  if (LoadedContainer != null && fragmentProps != null) {
131
- // $FlowFixMe[incompatible-type]
132
- // $FlowFixMe[cannot-spread-indexer]
133
39
  return /*#__PURE__*/React.createElement(LoadedContainer, (0, _extends2["default"])({}, props, fragmentProps));
134
40
  } else {
135
41
  return fallback !== null && fallback !== void 0 ? fallback : null;
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NestedRelayEntryPoint = NestedRelayEntryPoint;
7
+ function NestedRelayEntryPoint(params) {
8
+ return params;
9
+ }
@@ -1,18 +1,3 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- * @oncall relay
10
- */
11
-
12
- // This contextual profiler can be used to wrap a react sub-tree. It will bind
13
- // the RelayProfiler during the render phase of these components. Allows
14
- // collecting metrics for a specific part of your application.
15
-
16
1
  'use strict';
17
2
 
18
3
  var React = require('react');
@@ -1,14 +1,3 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- * @oncall relay
10
- */
11
-
12
1
  'use strict';
13
2
 
14
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
@@ -58,9 +47,6 @@ function createCacheEntry(cacheIdentifier, operation, operationAvailability, val
58
47
  var retention = environment.retain(operation);
59
48
  return {
60
49
  dispose: function dispose() {
61
- // Normally if this entry never commits, the request would've ended by the
62
- // time this timeout expires and the temporary retain is released. However,
63
- // we need to do this for live queries which remain open indefinitely.
64
50
  if (isLiveQuery && currentNetworkSubscription != null) {
65
51
  currentNetworkSubscription.unsubscribe();
66
52
  }
@@ -111,34 +97,17 @@ var QueryResourceImpl = /*#__PURE__*/function () {
111
97
  _proto.prepare = function prepare(operation, fetchObservable, maybeFetchPolicy, maybeRenderPolicy, observer, cacheBreaker, profilerContext) {
112
98
  var cacheIdentifier = getQueryCacheIdentifier(this._environment, operation, maybeFetchPolicy, maybeRenderPolicy, cacheBreaker);
113
99
  return this.prepareWithIdentifier(cacheIdentifier, operation, fetchObservable, maybeFetchPolicy, maybeRenderPolicy, observer, profilerContext);
114
- }
115
-
116
- /**
117
- * This function should be called during a Component's render function,
118
- * to either read an existing cached value for the query, or fetch the query
119
- * and suspend.
120
- */;
100
+ };
121
101
  _proto.prepareWithIdentifier = function prepareWithIdentifier(cacheIdentifier, operation, fetchObservable, maybeFetchPolicy, maybeRenderPolicy, observer, profilerContext) {
122
102
  var environment = this._environment;
123
103
  var fetchPolicy = maybeFetchPolicy !== null && maybeFetchPolicy !== void 0 ? maybeFetchPolicy : operationIsLiveQuery(operation) ? DEFAULT_LIVE_FETCH_POLICY : DEFAULT_FETCH_POLICY;
124
104
  var renderPolicy = maybeRenderPolicy !== null && maybeRenderPolicy !== void 0 ? maybeRenderPolicy : environment.UNSTABLE_getDefaultRenderPolicy();
125
-
126
- // 1. Check if there's a cached value for this operation, and reuse it if
127
- // it's available
128
105
  var cacheEntry = this._cache.get(cacheIdentifier);
129
106
  var temporaryRetainDisposable = null;
130
107
  var entryWasCached = cacheEntry != null;
131
108
  if (cacheEntry == null) {
132
- // 2. If a cached value isn't available, try fetching the operation.
133
- // _fetchAndSaveQuery will update the cache with either a Promise or
134
- // an Error to throw, or a QueryResult to return.
135
109
  cacheEntry = this._fetchAndSaveQuery(cacheIdentifier, operation, fetchObservable, fetchPolicy, renderPolicy, profilerContext, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, observer), {}, {
136
110
  unsubscribe: function unsubscribe(subscription) {
137
- // 4. If the request is cancelled, make sure to dispose
138
- // of the temporary retain; this will ensure that a promise
139
- // doesn't remain unnecessarily cached until the temporary retain
140
- // expires. Not clearing the temporary retain might cause the
141
- // query to incorrectly re-suspend.
142
111
  if (temporaryRetainDisposable != null) {
143
112
  temporaryRetainDisposable.dispose();
144
113
  }
@@ -147,12 +116,6 @@ var QueryResourceImpl = /*#__PURE__*/function () {
147
116
  }
148
117
  }));
149
118
  }
150
-
151
- // 3. Temporarily retain here in render phase. When the component reading
152
- // the operation is committed, we will transfer ownership of data retention
153
- // to the component.
154
- // In case the component never commits (mounts or updates) from this render,
155
- // this data retention hold will auto-release itself after a timeout.
156
119
  temporaryRetainDisposable = cacheEntry.temporaryRetain(environment);
157
120
  var cachedValue = cacheEntry.getValue();
158
121
  if (isPromise(cachedValue)) {
@@ -170,13 +133,7 @@ var QueryResourceImpl = /*#__PURE__*/function () {
170
133
  throw cachedValue;
171
134
  }
172
135
  return cachedValue;
173
- }
174
-
175
- /**
176
- * This function should be called during a component's commit phase
177
- * (e.g. inside useEffect), in order to retain the operation in the Relay store
178
- * and transfer ownership of the operation to the component lifecycle.
179
- */;
136
+ };
180
137
  _proto.retain = function retain(queryResult, profilerContext) {
181
138
  var environment = this._environment;
182
139
  var cacheIdentifier = queryResult.cacheIdentifier,
@@ -216,19 +173,12 @@ var QueryResourceImpl = /*#__PURE__*/function () {
216
173
  _proto._fetchAndSaveQuery = function _fetchAndSaveQuery(cacheIdentifier, operation, fetchObservable, fetchPolicy, renderPolicy, profilerContext, observer) {
217
174
  var _this2 = this;
218
175
  var environment = this._environment;
219
-
220
- // NOTE: Running `check` will write missing data to the store using any
221
- // missing data handlers specified on the environment;
222
- // We run it here first to make the handlers get a chance to populate
223
- // missing data.
224
176
  var queryAvailability = environment.check(operation);
225
177
  var queryStatus = queryAvailability.status;
226
178
  var hasFullQuery = queryStatus === 'available';
227
179
  var canPartialRender = hasFullQuery || renderPolicy === 'partial' && queryStatus !== 'stale';
228
180
  var shouldFetch;
229
181
  var shouldAllowRender;
230
- // Different definitions for Promise in our repos can cause this variable
231
- // to cause errors when synced elsewhere
232
182
  var resolveNetworkPromise = function resolveNetworkPromise() {};
233
183
  switch (fetchPolicy) {
234
184
  case 'store-only':
@@ -257,11 +207,6 @@ var QueryResourceImpl = /*#__PURE__*/function () {
257
207
  break;
258
208
  }
259
209
  }
260
-
261
- // NOTE: If this value is false, we will cache a promise for this
262
- // query, which means we will suspend here at this query root.
263
- // If it's true, we will cache the query resource and allow rendering to
264
- // continue.
265
210
  if (shouldAllowRender) {
266
211
  var queryResult = getQueryResult(operation, cacheIdentifier);
267
212
  var _cacheEntry = createCacheEntry(cacheIdentifier, operation, queryAvailability, queryResult, null, this._clearCacheEntry);
@@ -281,7 +226,6 @@ var QueryResourceImpl = /*#__PURE__*/function () {
281
226
  if (observerStart) {
282
227
  var subscriptionWithConditionalCancelation = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, subscription), {}, {
283
228
  unsubscribe: function unsubscribe() {
284
- // Only live queries should have their network requests canceled.
285
229
  if (operationIsLiveQuery(operation)) {
286
230
  subscription.unsubscribe();
287
231
  }
@@ -303,17 +247,9 @@ var QueryResourceImpl = /*#__PURE__*/function () {
303
247
  },
304
248
  error: function error(_error) {
305
249
  var cacheEntry = _this2._getOrCreateCacheEntry(cacheIdentifier, operation, queryAvailability, _error, networkSubscription);
306
-
307
- // If, this is the first thing we receive for the query,
308
- // before any other payload handled is error, we will cache and
309
- // re-throw that error later.
310
-
311
- // We will ignore errors for any incremental payloads we receive.
312
250
  if (cacheEntry.processedPayloadsCount === 0) {
313
251
  cacheEntry.setValue(_error);
314
252
  } else {
315
- // TODO:T92030819 Remove this warning and actually throw the network error
316
- // To complete this task we need to have a way of precisely tracking suspendable points
317
253
  process.env.NODE_ENV !== "production" ? warning(false, 'QueryResource: An incremental payload for query `%s` returned an error: `%s`.', operation.fragment.node.name, String(_error.message)) : void 0;
318
254
  }
319
255
  resolveNetworkPromise();
@@ -339,8 +275,6 @@ var QueryResourceImpl = /*#__PURE__*/function () {
339
275
  var networkPromise = new Promise(function (resolve) {
340
276
  resolveNetworkPromise = resolve;
341
277
  });
342
-
343
- // $FlowExpectedError[prop-missing] Expando to annotate Promises.
344
278
  networkPromise.displayName = 'Relay(' + operation.fragment.node.name + ')';
345
279
  _cacheEntry2 = createCacheEntry(cacheIdentifier, operation, queryAvailability, networkPromise, networkSubscription, this._clearCacheEntry);
346
280
  this._cache.set(cacheIdentifier, _cacheEntry2);
@@ -1,14 +1,3 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- * @oncall relay
10
- */
11
-
12
1
  'use strict';
13
2
 
14
3
  var ReactRelayContext = require('./../ReactRelayContext');
@@ -1,26 +1,9 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- * @oncall relay
10
- */
11
-
12
1
  'use strict';
13
2
 
14
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
15
4
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
5
  var invariant = require('invariant');
17
6
  var TEMPORARY_RETAIN_DURATION_MS = 5 * 60 * 1000;
18
-
19
- /**
20
- * Allows you to retain a resource as part of a component lifecycle accounting
21
- * for Suspense. You temporarily retain the resource during render, then
22
- * permanently retain it during commit and release it during unmount.
23
- */
24
7
  var SuspenseResource = /*#__PURE__*/function () {
25
8
  function SuspenseResource(retain) {
26
9
  var _this = this;
@@ -48,20 +31,11 @@ var SuspenseResource = /*#__PURE__*/function () {
48
31
  _proto.temporaryRetain = function temporaryRetain(environment) {
49
32
  var _this2 = this;
50
33
  var _this$_releaseTempora;
51
- // If we're executing in a server environment, there's no need
52
- // to create temporary retains, since the component will never commit.
53
34
  if (environment.isServer()) {
54
35
  return {
55
36
  dispose: function dispose() {}
56
37
  };
57
38
  }
58
-
59
- // temporaryRetain is called during the render phase. However,
60
- // given that we can't tell if this render will eventually commit or not,
61
- // we create a timer to autodispose of this retain in case the associated
62
- // component never commits.
63
- // If the component /does/ commit, permanentRetain will clear this timeout
64
- // and permanently retain the data.
65
39
  var retention = this._retain(environment);
66
40
  var releaseQueryTimeout = null;
67
41
  var releaseTemporaryRetain = function releaseTemporaryRetain() {
@@ -71,14 +45,6 @@ var SuspenseResource = /*#__PURE__*/function () {
71
45
  retention.dispose();
72
46
  };
73
47
  releaseQueryTimeout = setTimeout(releaseTemporaryRetain, TEMPORARY_RETAIN_DURATION_MS);
74
-
75
- // NOTE: Since temporaryRetain can be called multiple times, we release
76
- // the previous temporary retain after we re-establish a new one, since
77
- // we only ever need a single temporary retain until the permanent retain is
78
- // established.
79
- // temporaryRetain may be called multiple times by React during the render
80
- // phase, as well as multiple times by other query components that are
81
- // rendering the same query/variables.
82
48
  (_this$_releaseTempora = this._releaseTemporaryRetain) === null || _this$_releaseTempora === void 0 ? void 0 : _this$_releaseTempora.call(this);
83
49
  this._releaseTemporaryRetain = releaseTemporaryRetain;
84
50
  return {
@@ -1,14 +1,3 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- * @oncall relay
10
- */
11
-
12
1
  'use strict';
13
2
 
14
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
@@ -19,6 +8,7 @@ var _require = require('../QueryResource'),
19
8
  var invariant = require('invariant');
20
9
  var _require2 = require('relay-runtime'),
21
10
  fetchQueryInternal = _require2.__internal.fetchQuery,
11
+ RelayFeatureFlags = _require2.RelayFeatureFlags,
22
12
  createOperationDescriptor = _require2.createOperationDescriptor,
23
13
  getPendingOperationsForFragment = _require2.getPendingOperationsForFragment,
24
14
  getSelector = _require2.getSelector,
@@ -95,14 +85,9 @@ function handlePotentialSnapshotErrorsForState(environment, state) {
95
85
  function handleMissingClientEdge(environment, parentFragmentNode, parentFragmentRef, missingClientEdgeRequestInfo, queryOptions) {
96
86
  var originalVariables = getVariablesFromFragment(parentFragmentNode, parentFragmentRef);
97
87
  var variables = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, originalVariables), {}, {
98
- id: missingClientEdgeRequestInfo.clientEdgeDestinationID // TODO should be a reserved name
88
+ id: missingClientEdgeRequestInfo.clientEdgeDestinationID
99
89
  });
100
-
101
90
  var queryOperationDescriptor = createOperationDescriptor(missingClientEdgeRequestInfo.request, variables, queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.networkCacheConfig);
102
- // This may suspend. We don't need to do anything with the results; all we're
103
- // doing here is started the query if needed and retaining and releasing it
104
- // according to the component mount/suspense cycle; QueryResource
105
- // already handles this by itself.
106
91
  var QueryResource = getQueryResourceForEnvironment(environment);
107
92
  return QueryResource.prepare(queryOperationDescriptor, fetchQueryInternal(environment, queryOperationDescriptor), queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.fetchPolicy);
108
93
  }
@@ -133,9 +118,7 @@ function getFragmentState(environment, fragmentSelector) {
133
118
  };
134
119
  }
135
120
  }
136
-
137
- // fragmentNode cannot change during the lifetime of the component, though fragmentRef may change.
138
- function readFragmentInternal_REACT_CACHE(environment, fragmentNode, fragmentRef, hookDisplayName, queryOptions, fragmentKey) {
121
+ function readFragmentInternal_EXPERIMENTAL(environment, fragmentNode, fragmentRef, hookDisplayName, queryOptions, fragmentKey) {
139
122
  var _fragmentNode$metadat, _fragmentNode$metadat2;
140
123
  var fragmentSelector = getSelector(fragmentNode, fragmentRef);
141
124
  var isPlural = (fragmentNode === null || fragmentNode === void 0 ? void 0 : (_fragmentNode$metadat = fragmentNode.metadata) === null || _fragmentNode$metadat === void 0 ? void 0 : _fragmentNode$metadat.plural) === true;
@@ -146,9 +129,6 @@ function readFragmentInternal_REACT_CACHE(environment, fragmentNode, fragmentRef
146
129
  }
147
130
  !(fragmentRef == null || isPlural && Array.isArray(fragmentRef) && fragmentRef.length === 0 || fragmentSelector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected to receive an object where `...%s` was spread, ' + 'but the fragment reference was not found`. This is most ' + 'likely the result of:\n' + "- Forgetting to spread `%s` in `%s`'s parent's fragment.\n" + '- Conditionally fetching `%s` but unconditionally passing %s prop ' + 'to `%s`. If the parent fragment only fetches the fragment conditionally ' + '- with e.g. `@include`, `@skip`, or inside a `... on SomeType { }` ' + 'spread - then the fragment reference will not exist. ' + 'In this case, pass `null` if the conditions for evaluating the ' + 'fragment are not met (e.g. if the `@include(if)` value is false.)', fragmentNode.name, fragmentNode.name, hookDisplayName, fragmentNode.name, fragmentKey == null ? 'a fragment reference' : "the `".concat(fragmentKey, "`"), hookDisplayName) : invariant(false) : void 0;
148
131
  var state = getFragmentState(environment, fragmentSelector);
149
-
150
- // Handle the queries for any missing client edges; this may suspend.
151
- // FIXME handle client edges in parallel.
152
132
  var clientEdgeQueries = null;
153
133
  if (((_fragmentNode$metadat2 = fragmentNode.metadata) === null || _fragmentNode$metadat2 === void 0 ? void 0 : _fragmentNode$metadat2.hasClientEdges) === true) {
154
134
  var missingClientEdges = getMissingClientEdges(state);
@@ -169,16 +149,12 @@ function readFragmentInternal_REACT_CACHE(environment, fragmentNode, fragmentRef
169
149
  }
170
150
  }
171
151
  if (isMissingData(state)) {
172
- // Suspend if an active operation bears on this fragment, either the
173
- // fragment's owner or some other mutation etc. that could affect it:
174
152
  !(fragmentSelector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'refinement, see invariants above') : invariant(false) : void 0;
175
153
  var fragmentOwner = fragmentSelector.kind === 'PluralReaderSelector' ? fragmentSelector.selectors[0].owner : fragmentSelector.owner;
176
154
  var pendingOperationsResult = getPendingOperationsForFragment(environment, fragmentNode, fragmentOwner);
177
155
  if (pendingOperationsResult) {
178
156
  throw pendingOperationsResult.promise;
179
157
  }
180
- // Report required fields only if we're not suspending, since that means
181
- // they're missing even though we are out of options for possibly fetching them:
182
158
  handlePotentialSnapshotErrorsForState(environment, state);
183
159
  }
184
160
  var data;
@@ -191,7 +167,7 @@ function readFragmentInternal_REACT_CACHE(environment, fragmentNode, fragmentRef
191
167
  return s.data;
192
168
  });
193
169
  }
194
- if (process.env.NODE_ENV !== "production") {
170
+ if (RelayFeatureFlags.LOG_MISSING_RECORDS_IN_PROD || process.env.NODE_ENV !== "production") {
195
171
  if (fragmentRef != null && (data === undefined || Array.isArray(data) && data.length > 0 && data.every(function (d) {
196
172
  return d === undefined;
197
173
  }))) {
@@ -203,4 +179,4 @@ function readFragmentInternal_REACT_CACHE(environment, fragmentNode, fragmentRef
203
179
  clientEdgeQueries: clientEdgeQueries
204
180
  };
205
181
  }
206
- module.exports = readFragmentInternal_REACT_CACHE;
182
+ module.exports = readFragmentInternal_EXPERIMENTAL;