react-relay 14.0.0 → 15.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. package/ReactRelayContainerUtils.js.flow +1 -2
  2. package/ReactRelayContext.js +1 -1
  3. package/ReactRelayContext.js.flow +1 -2
  4. package/ReactRelayFragmentContainer.js.flow +6 -4
  5. package/ReactRelayFragmentMockRenderer.js.flow +1 -2
  6. package/ReactRelayLocalQueryRenderer.js.flow +5 -5
  7. package/ReactRelayPaginationContainer.js.flow +21 -14
  8. package/ReactRelayQueryFetcher.js.flow +28 -16
  9. package/ReactRelayQueryRenderer.js.flow +42 -13
  10. package/ReactRelayQueryRendererContext.js.flow +2 -3
  11. package/ReactRelayRefetchContainer.js.flow +9 -9
  12. package/ReactRelayTestMocker.js.flow +3 -3
  13. package/ReactRelayTypes.js.flow +7 -8
  14. package/RelayContext.js.flow +1 -2
  15. package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +4 -5
  16. package/__flowtests__/ReactRelayPaginationContainer-flowtest.js.flow +4 -5
  17. package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +4 -5
  18. package/__flowtests__/RelayModern-flowtest.js.flow +3 -4
  19. package/__flowtests__/RelayModernFlowtest_badref.graphql.js.flow +3 -4
  20. package/__flowtests__/RelayModernFlowtest_notref.graphql.js.flow +3 -4
  21. package/__flowtests__/RelayModernFlowtest_user.graphql.js.flow +3 -4
  22. package/__flowtests__/RelayModernFlowtest_users.graphql.js.flow +3 -4
  23. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer.graphql.js.flow +3 -1
  24. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer2.graphql.js.flow +3 -1
  25. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtestQuery.graphql.js.flow +4 -2
  26. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtest_viewer.graphql.js.flow +3 -1
  27. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtestQuery.graphql.js.flow +4 -2
  28. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtest_viewer.graphql.js.flow +3 -1
  29. package/__flowtests__/__generated__/RelayModernFlowtest_badref.graphql.js.flow +4 -2
  30. package/__flowtests__/__generated__/RelayModernFlowtest_notref.graphql.js.flow +4 -2
  31. package/__flowtests__/__generated__/RelayModernFlowtest_user.graphql.js.flow +3 -1
  32. package/__flowtests__/__generated__/RelayModernFlowtest_users.graphql.js.flow +3 -1
  33. package/assertFragmentMap.js.flow +1 -2
  34. package/buildReactRelayContainer.js.flow +7 -7
  35. package/getRootVariablesForFragments.js.flow +1 -3
  36. package/hooks.js +1 -1
  37. package/hooks.js.flow +4 -2
  38. package/index.js +1 -1
  39. package/index.js.flow +6 -2
  40. package/isRelayEnvironment.js.flow +1 -2
  41. package/jest-react/enqueueTask.js.flow +1 -1
  42. package/jest-react/index.js.flow +1 -1
  43. package/jest-react/internalAct.js.flow +1 -1
  44. package/legacy.js +1 -1
  45. package/legacy.js.flow +1 -2
  46. package/lib/ReactRelayContainerUtils.js +2 -3
  47. package/lib/ReactRelayContext.js +3 -4
  48. package/lib/ReactRelayFragmentContainer.js +47 -73
  49. package/lib/ReactRelayFragmentMockRenderer.js +2 -4
  50. package/lib/ReactRelayLocalQueryRenderer.js +18 -31
  51. package/lib/ReactRelayPaginationContainer.js +74 -164
  52. package/lib/ReactRelayQueryFetcher.js +49 -76
  53. package/lib/ReactRelayQueryRenderer.js +63 -84
  54. package/lib/ReactRelayQueryRendererContext.js +2 -2
  55. package/lib/ReactRelayRefetchContainer.js +58 -108
  56. package/lib/ReactRelayTestMocker.js +33 -68
  57. package/lib/ReactRelayTypes.js +2 -1
  58. package/lib/RelayContext.js +4 -7
  59. package/lib/assertFragmentMap.js +3 -5
  60. package/lib/buildReactRelayContainer.js +11 -27
  61. package/lib/getRootVariablesForFragments.js +6 -10
  62. package/lib/hooks.js +5 -18
  63. package/lib/index.js +7 -24
  64. package/lib/isRelayEnvironment.js +5 -4
  65. package/lib/jest-react/enqueueTask.js +5 -9
  66. package/lib/jest-react/index.js +0 -1
  67. package/lib/jest-react/internalAct.js +9 -20
  68. package/lib/legacy.js +2 -8
  69. package/lib/multi-actor/ActorChange.js +2 -5
  70. package/lib/multi-actor/index.js +2 -1
  71. package/lib/multi-actor/useRelayActorEnvironment.js +4 -8
  72. package/lib/relay-hooks/EntryPointContainer.react.js +9 -15
  73. package/lib/relay-hooks/EntryPointTypes.flow.js +5 -3
  74. package/lib/relay-hooks/FragmentResource.js +109 -203
  75. package/lib/relay-hooks/HooksImplementation.js +3 -6
  76. package/lib/relay-hooks/InternalLogger.js +2 -3
  77. package/lib/relay-hooks/LRUCache.js +2 -20
  78. package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +33 -54
  79. package/lib/relay-hooks/MatchContainer.js +15 -24
  80. package/lib/relay-hooks/ProfilerContext.js +3 -3
  81. package/lib/relay-hooks/QueryResource.js +31 -101
  82. package/lib/relay-hooks/RelayEnvironmentProvider.js +5 -9
  83. package/lib/relay-hooks/SuspenseResource.js +9 -33
  84. package/lib/relay-hooks/loadEntryPoint.js +19 -31
  85. package/lib/relay-hooks/loadQuery.js +42 -78
  86. package/lib/relay-hooks/preloadQuery_DEPRECATED.js +11 -37
  87. package/lib/relay-hooks/prepareEntryPoint_DEPRECATED.js +9 -15
  88. package/lib/relay-hooks/react-cache/RelayReactCache.js +7 -12
  89. package/lib/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js +27 -81
  90. package/lib/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js +206 -0
  91. package/lib/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js +195 -215
  92. package/lib/relay-hooks/react-cache/useFragment_REACT_CACHE.js +5 -15
  93. package/lib/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js +17 -24
  94. package/lib/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js +149 -0
  95. package/lib/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js +24 -39
  96. package/lib/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js +325 -0
  97. package/lib/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js +37 -0
  98. package/lib/relay-hooks/useBlockingPaginationFragment.js +73 -93
  99. package/lib/relay-hooks/useClientQuery.js +30 -0
  100. package/lib/relay-hooks/useEntryPointLoader.js +18 -38
  101. package/lib/relay-hooks/useFetchTrackingRef.js +10 -12
  102. package/lib/relay-hooks/useFragment.js +8 -19
  103. package/lib/relay-hooks/useFragmentNode.js +20 -32
  104. package/lib/relay-hooks/useIsMountedRef.js +4 -6
  105. package/lib/relay-hooks/useIsOperationNodeActive.js +8 -20
  106. package/lib/relay-hooks/useIsParentQueryActive.js +3 -6
  107. package/lib/relay-hooks/useLazyLoadQuery.js +7 -24
  108. package/lib/relay-hooks/useLazyLoadQueryNode.js +23 -34
  109. package/lib/relay-hooks/useLoadMoreFunction.js +46 -78
  110. package/lib/relay-hooks/useMemoOperationDescriptor.js +6 -15
  111. package/lib/relay-hooks/useMemoVariables.js +15 -34
  112. package/lib/relay-hooks/useMutation.js +9 -27
  113. package/lib/relay-hooks/usePaginationFragment.js +73 -76
  114. package/lib/relay-hooks/usePreloadedQuery.js +13 -44
  115. package/lib/relay-hooks/useQueryLoader.js +24 -49
  116. package/lib/relay-hooks/useRefetchableFragment.js +19 -17
  117. package/lib/relay-hooks/useRefetchableFragmentNode.js +65 -109
  118. package/lib/relay-hooks/useRelayEnvironment.js +4 -8
  119. package/lib/relay-hooks/useStaticFragmentNodeWarning.js +4 -8
  120. package/lib/relay-hooks/useSubscribeToInvalidationState.js +8 -9
  121. package/lib/relay-hooks/useSubscription.js +5 -10
  122. package/lib/relay-hooks/useUnsafeRef_DEPRECATED.js +29 -0
  123. package/multi-actor/ActorChange.js.flow +1 -1
  124. package/multi-actor/index.js.flow +1 -1
  125. package/multi-actor/useRelayActorEnvironment.js.flow +2 -4
  126. package/package.json +2 -2
  127. package/react-relay-hooks.js +2 -2
  128. package/react-relay-hooks.min.js +2 -2
  129. package/react-relay-legacy.js +2 -2
  130. package/react-relay-legacy.min.js +2 -2
  131. package/react-relay.js +2 -2
  132. package/react-relay.min.js +2 -2
  133. package/relay-hooks/EntryPointContainer.react.js.flow +3 -5
  134. package/relay-hooks/EntryPointTypes.flow.js.flow +37 -37
  135. package/relay-hooks/FragmentResource.js.flow +43 -19
  136. package/relay-hooks/HooksImplementation.js.flow +7 -9
  137. package/relay-hooks/InternalLogger.js.flow +1 -3
  138. package/relay-hooks/LRUCache.js.flow +1 -3
  139. package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +19 -14
  140. package/relay-hooks/MatchContainer.js.flow +6 -8
  141. package/relay-hooks/ProfilerContext.js.flow +1 -3
  142. package/relay-hooks/QueryResource.js.flow +29 -11
  143. package/relay-hooks/RelayEnvironmentProvider.js.flow +4 -6
  144. package/relay-hooks/SuspenseResource.js.flow +1 -3
  145. package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +6 -4
  146. package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +4 -4
  147. package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_user.graphql.js.flow +3 -1
  148. package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_users.graphql.js.flow +3 -1
  149. package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +39 -39
  150. package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +1 -3
  151. package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +37 -38
  152. package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +18 -20
  153. package/relay-hooks/__flowtests__/utils.js.flow +21 -12
  154. package/relay-hooks/loadEntryPoint.js.flow +11 -6
  155. package/relay-hooks/loadQuery.js.flow +11 -7
  156. package/relay-hooks/preloadQuery_DEPRECATED.js.flow +9 -12
  157. package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +13 -10
  158. package/relay-hooks/react-cache/RelayReactCache.js.flow +1 -3
  159. package/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js.flow +26 -20
  160. package/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js.flow +297 -0
  161. package/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js.flow +136 -96
  162. package/relay-hooks/react-cache/useFragment_REACT_CACHE.js.flow +1 -3
  163. package/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js.flow +3 -5
  164. package/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js.flow +190 -0
  165. package/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js.flow +3 -6
  166. package/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js.flow +601 -0
  167. package/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js.flow +65 -0
  168. package/relay-hooks/useBlockingPaginationFragment.js.flow +86 -59
  169. package/relay-hooks/useClientQuery.js.flow +39 -0
  170. package/relay-hooks/useEntryPointLoader.js.flow +16 -14
  171. package/relay-hooks/useFetchTrackingRef.js.flow +7 -8
  172. package/relay-hooks/useFragment.js.flow +2 -4
  173. package/relay-hooks/useFragmentNode.js.flow +7 -8
  174. package/relay-hooks/useIsMountedRef.js.flow +2 -4
  175. package/relay-hooks/useIsOperationNodeActive.js.flow +1 -1
  176. package/relay-hooks/useIsParentQueryActive.js.flow +1 -1
  177. package/relay-hooks/useLazyLoadQuery.js.flow +9 -32
  178. package/relay-hooks/useLazyLoadQueryNode.js.flow +4 -6
  179. package/relay-hooks/useLoadMoreFunction.js.flow +20 -17
  180. package/relay-hooks/useMemoOperationDescriptor.js.flow +3 -5
  181. package/relay-hooks/useMemoVariables.js.flow +13 -31
  182. package/relay-hooks/useMutation.js.flow +6 -8
  183. package/relay-hooks/usePaginationFragment.js.flow +75 -43
  184. package/relay-hooks/usePreloadedQuery.js.flow +49 -43
  185. package/relay-hooks/useQueryLoader.js.flow +89 -28
  186. package/relay-hooks/useRefetchableFragment.js.flow +83 -23
  187. package/relay-hooks/useRefetchableFragmentNode.js.flow +26 -22
  188. package/relay-hooks/useRelayEnvironment.js.flow +2 -4
  189. package/relay-hooks/useStaticFragmentNodeWarning.js.flow +3 -5
  190. package/relay-hooks/useSubscribeToInvalidationState.js.flow +2 -4
  191. package/relay-hooks/useSubscription.js.flow +1 -3
  192. package/relay-hooks/useUnsafeRef_DEPRECATED.js.flow +25 -0
  193. package/lib/readContext.js +0 -28
  194. package/readContext.js.flow +0 -31
@@ -5,44 +5,36 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  *
8
- * @emails oncall+relay
9
8
  * @format
9
+ * @oncall relay
10
10
  */
11
- // flowlint ambiguous-object-type:error
12
- 'use strict';
13
11
 
14
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
12
+ 'use strict';
15
13
 
14
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
16
15
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
17
-
18
16
  var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
19
-
20
17
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
21
-
18
+ var _require = require('../QueryResource'),
19
+ getQueryResourceForEnvironment = _require.getQueryResourceForEnvironment;
22
20
  var useRelayEnvironment = require('../useRelayEnvironment');
23
-
24
- var getQueryResultOrFetchQuery = require('./getQueryResultOrFetchQuery_REACT_CACHE');
25
-
26
21
  var invariant = require('invariant');
27
-
28
- var _require = require('react'),
29
- useDebugValue = _require.useDebugValue,
30
- useEffect = _require.useEffect,
31
- useMemo = _require.useMemo,
32
- useRef = _require.useRef,
33
- useState = _require.useState;
34
-
35
- var _require2 = require('relay-runtime'),
36
- areEqualSelectors = _require2.areEqualSelectors,
37
- createOperationDescriptor = _require2.createOperationDescriptor,
38
- getPendingOperationsForFragment = _require2.getPendingOperationsForFragment,
39
- getSelector = _require2.getSelector,
40
- getVariablesFromFragment = _require2.getVariablesFromFragment,
41
- handlePotentialSnapshotErrors = _require2.handlePotentialSnapshotErrors,
42
- recycleNodesInto = _require2.recycleNodesInto;
43
-
22
+ var _require2 = require('react'),
23
+ useDebugValue = _require2.useDebugValue,
24
+ useEffect = _require2.useEffect,
25
+ useMemo = _require2.useMemo,
26
+ useRef = _require2.useRef,
27
+ useState = _require2.useState;
28
+ var _require3 = require('relay-runtime'),
29
+ fetchQueryInternal = _require3.__internal.fetchQuery,
30
+ areEqualSelectors = _require3.areEqualSelectors,
31
+ createOperationDescriptor = _require3.createOperationDescriptor,
32
+ getPendingOperationsForFragment = _require3.getPendingOperationsForFragment,
33
+ getSelector = _require3.getSelector,
34
+ getVariablesFromFragment = _require3.getVariablesFromFragment,
35
+ handlePotentialSnapshotErrors = _require3.handlePotentialSnapshotErrors,
36
+ recycleNodesInto = _require3.recycleNodesInto;
44
37
  var warning = require("fbjs/lib/warning");
45
-
46
38
  function isMissingData(state) {
47
39
  if (state.kind === 'bailout') {
48
40
  return false;
@@ -54,32 +46,24 @@ function isMissingData(state) {
54
46
  });
55
47
  }
56
48
  }
57
-
58
49
  function getMissingClientEdges(state) {
59
50
  if (state.kind === 'bailout') {
60
51
  return null;
61
52
  } else if (state.kind === 'singular') {
62
53
  var _state$snapshot$missi;
63
-
64
54
  return (_state$snapshot$missi = state.snapshot.missingClientEdges) !== null && _state$snapshot$missi !== void 0 ? _state$snapshot$missi : null;
65
55
  } else {
66
56
  var edges = null;
67
-
68
57
  var _iterator = (0, _createForOfIteratorHelper2["default"])(state.snapshots),
69
- _step;
70
-
58
+ _step;
71
59
  try {
72
60
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
73
61
  var snapshot = _step.value;
74
-
75
62
  if (snapshot.missingClientEdges) {
76
63
  var _edges;
77
-
78
64
  edges = (_edges = edges) !== null && _edges !== void 0 ? _edges : [];
79
-
80
65
  var _iterator2 = (0, _createForOfIteratorHelper2["default"])(snapshot.missingClientEdges),
81
- _step2;
82
-
66
+ _step2;
83
67
  try {
84
68
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
85
69
  var edge = _step2.value;
@@ -97,50 +81,81 @@ function getMissingClientEdges(state) {
97
81
  } finally {
98
82
  _iterator.f();
99
83
  }
100
-
101
84
  return edges;
102
85
  }
103
86
  }
104
-
105
- function handlePotentialSnapshotErrorsForState(environment, state) {
106
- if (state.kind === 'singular') {
107
- handlePotentialSnapshotErrors(environment, state.snapshot.missingRequiredFields, state.snapshot.relayResolverErrors);
108
- } else if (state.kind === 'plural') {
87
+ function getSuspendingLiveResolver(state) {
88
+ if (state.kind === 'bailout') {
89
+ return null;
90
+ } else if (state.kind === 'singular') {
91
+ var _state$snapshot$missi2;
92
+ return (_state$snapshot$missi2 = state.snapshot.missingLiveResolverFields) !== null && _state$snapshot$missi2 !== void 0 ? _state$snapshot$missi2 : null;
93
+ } else {
94
+ var missingFields = null;
109
95
  var _iterator3 = (0, _createForOfIteratorHelper2["default"])(state.snapshots),
110
- _step3;
111
-
96
+ _step3;
112
97
  try {
113
98
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
114
99
  var snapshot = _step3.value;
115
- handlePotentialSnapshotErrors(environment, snapshot.missingRequiredFields, snapshot.relayResolverErrors);
100
+ if (snapshot.missingLiveResolverFields) {
101
+ var _missingFields;
102
+ missingFields = (_missingFields = missingFields) !== null && _missingFields !== void 0 ? _missingFields : [];
103
+ var _iterator4 = (0, _createForOfIteratorHelper2["default"])(snapshot.missingLiveResolverFields),
104
+ _step4;
105
+ try {
106
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
107
+ var edge = _step4.value;
108
+ missingFields.push(edge);
109
+ }
110
+ } catch (err) {
111
+ _iterator4.e(err);
112
+ } finally {
113
+ _iterator4.f();
114
+ }
115
+ }
116
116
  }
117
117
  } catch (err) {
118
118
  _iterator3.e(err);
119
119
  } finally {
120
120
  _iterator3.f();
121
121
  }
122
+ return missingFields;
123
+ }
124
+ }
125
+ function handlePotentialSnapshotErrorsForState(environment, state) {
126
+ if (state.kind === 'singular') {
127
+ handlePotentialSnapshotErrors(environment, state.snapshot.missingRequiredFields, state.snapshot.relayResolverErrors);
128
+ } else if (state.kind === 'plural') {
129
+ var _iterator5 = (0, _createForOfIteratorHelper2["default"])(state.snapshots),
130
+ _step5;
131
+ try {
132
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
133
+ var snapshot = _step5.value;
134
+ handlePotentialSnapshotErrors(environment, snapshot.missingRequiredFields, snapshot.relayResolverErrors);
135
+ }
136
+ } catch (err) {
137
+ _iterator5.e(err);
138
+ } finally {
139
+ _iterator5.f();
140
+ }
122
141
  }
123
142
  }
143
+
124
144
  /**
125
145
  * Check for updates to the store that occurred concurrently with rendering the given `state` value,
126
146
  * returning a new (updated) state if there were updates or null if there were no changes.
127
147
  */
128
-
129
-
130
148
  function handleMissedUpdates(environment, state) {
131
149
  if (state.kind === 'bailout') {
132
150
  return null;
133
- } // FIXME this is invalid if we've just switched environments.
134
-
135
-
151
+ }
152
+ // FIXME this is invalid if we've just switched environments.
136
153
  var currentEpoch = environment.getStore().getEpoch();
137
-
138
154
  if (currentEpoch === state.epoch) {
139
155
  return null;
140
- } // The store has updated since we rendered (without us being subscribed yet),
156
+ }
157
+ // The store has updated since we rendered (without us being subscribed yet),
141
158
  // so check for any updates to the data we're rendering:
142
-
143
-
144
159
  if (state.kind === 'singular') {
145
160
  var currentSnapshot = environment.lookup(state.snapshot.selector);
146
161
  var updatedData = recycleNodesInto(state.snapshot.data, currentSnapshot.data);
@@ -162,14 +177,10 @@ function handleMissedUpdates(environment, state) {
162
177
  } else {
163
178
  var didMissUpdates = false;
164
179
  var currentSnapshots = [];
165
-
166
180
  for (var index = 0; index < state.snapshots.length; index++) {
167
181
  var snapshot = state.snapshots[index];
168
-
169
182
  var _currentSnapshot = environment.lookup(snapshot.selector);
170
-
171
183
  var _updatedData = recycleNodesInto(snapshot.data, _currentSnapshot.data);
172
-
173
184
  var _updatedCurrentSnapshot = {
174
185
  data: _updatedData,
175
186
  isMissingData: _currentSnapshot.isMissingData,
@@ -180,14 +191,11 @@ function handleMissedUpdates(environment, state) {
180
191
  missingRequiredFields: _currentSnapshot.missingRequiredFields,
181
192
  relayResolverErrors: _currentSnapshot.relayResolverErrors
182
193
  };
183
-
184
194
  if (_updatedData !== snapshot.data) {
185
195
  didMissUpdates = true;
186
196
  }
187
-
188
197
  currentSnapshots.push(_updatedCurrentSnapshot);
189
198
  }
190
-
191
199
  !(currentSnapshots.length === state.snapshots.length) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected same number of snapshots') : invariant(false) : void 0;
192
200
  return [didMissUpdates, {
193
201
  kind: 'plural',
@@ -196,33 +204,32 @@ function handleMissedUpdates(environment, state) {
196
204
  }];
197
205
  }
198
206
  }
199
-
200
207
  function handleMissingClientEdge(environment, parentFragmentNode, parentFragmentRef, missingClientEdgeRequestInfo, queryOptions) {
201
208
  var originalVariables = getVariablesFromFragment(parentFragmentNode, parentFragmentRef);
202
209
  var variables = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, originalVariables), {}, {
203
210
  id: missingClientEdgeRequestInfo.clientEdgeDestinationID // TODO should be a reserved name
204
-
205
211
  });
206
- var queryOperationDescriptor = createOperationDescriptor(missingClientEdgeRequestInfo.request, variables, queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.networkCacheConfig); // This may suspend. We don't need to do anything with the results; all we're
212
+
213
+ var queryOperationDescriptor = createOperationDescriptor(missingClientEdgeRequestInfo.request, variables, queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.networkCacheConfig);
214
+ // This may suspend. We don't need to do anything with the results; all we're
207
215
  // doing here is started the query if needed and retaining and releasing it
208
- // according to the component mount/suspense cycle; getQueryResultOrFetchQuery
216
+ // according to the component mount/suspense cycle; QueryResource
209
217
  // already handles this by itself.
210
-
211
- var _getQueryResultOrFetc = getQueryResultOrFetchQuery(environment, queryOperationDescriptor, {
212
- fetchPolicy: queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.fetchPolicy
213
- }),
214
- _ = _getQueryResultOrFetc[0],
215
- effect = _getQueryResultOrFetc[1];
216
-
217
- return effect;
218
+ var QueryResource = getQueryResourceForEnvironment(environment);
219
+ return QueryResource.prepare(queryOperationDescriptor, fetchQueryInternal(environment, queryOperationDescriptor), queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.fetchPolicy);
218
220
  }
219
-
220
221
  function subscribeToSnapshot(environment, state, setState) {
221
222
  if (state.kind === 'bailout') {
222
223
  return function () {};
223
224
  } else if (state.kind === 'singular') {
224
225
  var disposable = environment.subscribe(state.snapshot, function (latestSnapshot) {
225
- setState(function (_) {
226
+ setState(function (prevState) {
227
+ // In theory a setState from a subscription could be batched together
228
+ // with a setState to change the fragment selector. Guard against this
229
+ // by bailing out of the state update if the selector has changed.
230
+ if (prevState.kind !== 'singular' || prevState.snapshot.selector !== latestSnapshot.selector) {
231
+ return prevState;
232
+ }
226
233
  return {
227
234
  kind: 'singular',
228
235
  snapshot: latestSnapshot,
@@ -236,9 +243,15 @@ function subscribeToSnapshot(environment, state, setState) {
236
243
  } else {
237
244
  var disposables = state.snapshots.map(function (snapshot, index) {
238
245
  return environment.subscribe(snapshot, function (latestSnapshot) {
239
- setState(function (existing) {
240
- !(existing.kind === 'plural') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot go from singular to plural or from bailout to plural.') : invariant(false) : void 0;
241
- var updated = (0, _toConsumableArray2["default"])(existing.snapshots);
246
+ setState(function (prevState) {
247
+ var _prevState$snapshots$;
248
+ // In theory a setState from a subscription could be batched together
249
+ // with a setState to change the fragment selector. Guard against this
250
+ // by bailing out of the state update if the selector has changed.
251
+ if (prevState.kind !== 'plural' || ((_prevState$snapshots$ = prevState.snapshots[index]) === null || _prevState$snapshots$ === void 0 ? void 0 : _prevState$snapshots$.selector) !== latestSnapshot.selector) {
252
+ return prevState;
253
+ }
254
+ var updated = (0, _toConsumableArray2["default"])(prevState.snapshots);
242
255
  updated[index] = latestSnapshot;
243
256
  return {
244
257
  kind: 'plural',
@@ -249,29 +262,29 @@ function subscribeToSnapshot(environment, state, setState) {
249
262
  });
250
263
  });
251
264
  return function () {
252
- var _iterator4 = (0, _createForOfIteratorHelper2["default"])(disposables),
253
- _step4;
254
-
265
+ var _iterator6 = (0, _createForOfIteratorHelper2["default"])(disposables),
266
+ _step6;
255
267
  try {
256
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
257
- var d = _step4.value;
268
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
269
+ var d = _step6.value;
258
270
  d.dispose();
259
271
  }
260
272
  } catch (err) {
261
- _iterator4.e(err);
273
+ _iterator6.e(err);
262
274
  } finally {
263
- _iterator4.f();
275
+ _iterator6.f();
264
276
  }
265
277
  };
266
278
  }
267
279
  }
268
-
269
- function getFragmentState(environment, fragmentSelector, isPlural) {
280
+ function getFragmentState(environment, fragmentSelector) {
270
281
  if (fragmentSelector == null) {
271
282
  return {
272
283
  kind: 'bailout'
273
284
  };
274
285
  } else if (fragmentSelector.kind === 'PluralReaderSelector') {
286
+ // Note that if fragmentRef is an empty array, fragmentSelector will be null so we'll hit the above case.
287
+ // Null is returned by getSelector if fragmentRef has no non-null items.
275
288
  return {
276
289
  kind: 'plural',
277
290
  snapshots: fragmentSelector.selectors.map(function (s) {
@@ -286,229 +299,200 @@ function getFragmentState(environment, fragmentSelector, isPlural) {
286
299
  epoch: environment.getStore().getEpoch()
287
300
  };
288
301
  }
289
- } // fragmentNode cannot change during the lifetime of the component, though fragmentRef may change.
290
-
302
+ }
291
303
 
304
+ // fragmentNode cannot change during the lifetime of the component, though fragmentRef may change.
292
305
  function useFragmentInternal_REACT_CACHE(fragmentNode, fragmentRef, hookDisplayName, queryOptions, fragmentKey) {
293
306
  var _fragmentNode$metadat, _fragmentNode$metadat2;
294
-
295
307
  var fragmentSelector = useMemo(function () {
296
308
  return getSelector(fragmentNode, fragmentRef);
297
309
  }, [fragmentNode, fragmentRef]);
298
310
  var isPlural = (fragmentNode === null || fragmentNode === void 0 ? void 0 : (_fragmentNode$metadat = fragmentNode.metadata) === null || _fragmentNode$metadat === void 0 ? void 0 : _fragmentNode$metadat.plural) === true;
299
-
300
311
  if (isPlural) {
301
312
  !(fragmentRef == null || Array.isArray(fragmentRef)) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected fragment pointer%s for fragment `%s` to be ' + 'an array, instead got `%s`. Remove `@relay(plural: true)` ' + 'from fragment `%s` to allow the prop to be an object.', fragmentKey != null ? " for key `".concat(fragmentKey, "`") : '', fragmentNode.name, typeof fragmentRef, fragmentNode.name) : invariant(false) : void 0;
302
313
  } else {
303
314
  !!Array.isArray(fragmentRef) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected fragment pointer%s for fragment `%s` not to be ' + 'an array, instead got `%s`. Add `@relay(plural: true)` ' + 'to fragment `%s` to allow the prop to be an array.', fragmentKey != null ? " for key `".concat(fragmentKey, "`") : '', fragmentNode.name, typeof fragmentRef, fragmentNode.name) : invariant(false) : void 0;
304
315
  }
305
-
306
316
  !(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;
307
317
  var environment = useRelayEnvironment();
308
-
309
318
  var _useState = useState(function () {
310
- return getFragmentState(environment, fragmentSelector, isPlural);
311
- }),
312
- rawState = _useState[0],
313
- setState = _useState[1]; // On second look this separate rawState may not be needed at all, it can just be
314
- // put into getFragmentState. Exception: can we properly handle the case where the
315
- // fragmentRef goes from non-null to null?
316
-
317
-
318
- var stateFromRawState = function stateFromRawState(state) {
319
- if (fragmentRef == null) {
320
- return {
321
- kind: 'bailout'
322
- };
323
- } else if (state.kind === 'plural' && state.snapshots.length === 0) {
324
- return {
325
- kind: 'bailout'
326
- };
327
- } else {
328
- return state;
329
- }
330
- };
319
+ return getFragmentState(environment, fragmentSelector);
320
+ }),
321
+ _state = _useState[0],
322
+ setState = _useState[1];
323
+ var state = _state;
331
324
 
332
- var state = stateFromRawState(rawState); // This copy of the state we only update when something requires us to
325
+ // This copy of the state we only update when something requires us to
333
326
  // unsubscribe and re-subscribe, namely a changed environment or
334
327
  // fragment selector.
335
-
336
328
  var _useState2 = useState(state),
337
- rawSubscribedState = _useState2[0],
338
- setSubscribedState = _useState2[1]; // FIXME since this is used as an effect dependency, it needs to be memoized.
339
-
340
-
341
- var subscribedState = stateFromRawState(rawSubscribedState);
342
-
329
+ _subscribedState = _useState2[0],
330
+ setSubscribedState = _useState2[1];
331
+ // FIXME since this is used as an effect dependency, it needs to be memoized.
332
+ var subscribedState = _subscribedState;
343
333
  var _useState3 = useState(fragmentSelector),
344
- previousFragmentSelector = _useState3[0],
345
- setPreviousFragmentSelector = _useState3[1];
346
-
334
+ previousFragmentSelector = _useState3[0],
335
+ setPreviousFragmentSelector = _useState3[1];
347
336
  var _useState4 = useState(environment),
348
- previousEnvironment = _useState4[0],
349
- setPreviousEnvironment = _useState4[1];
350
-
337
+ previousEnvironment = _useState4[0],
338
+ setPreviousEnvironment = _useState4[1];
351
339
  if (!areEqualSelectors(fragmentSelector, previousFragmentSelector) || environment !== previousEnvironment) {
352
340
  // Enqueue setState to record the new selector and state
353
341
  setPreviousFragmentSelector(fragmentSelector);
354
342
  setPreviousEnvironment(environment);
355
- var newState = stateFromRawState(getFragmentState(environment, fragmentSelector, isPlural));
343
+ var newState = getFragmentState(environment, fragmentSelector);
356
344
  setState(newState);
357
345
  setSubscribedState(newState); // This causes us to form a new subscription
358
346
  // But render with the latest state w/o waiting for the setState. Otherwise
359
347
  // the component would render the wrong information temporarily (including
360
348
  // possibly incorrectly triggering some warnings below).
361
-
362
349
  state = newState;
363
350
  subscribedState = newState;
364
- } // Handle the queries for any missing client edges; this may suspend.
365
- // FIXME handle client edges in parallel.
351
+ }
366
352
 
353
+ // The purpose of this is to detect whether we have ever committed, because we
354
+ // don't suspend on store updates, only when the component either is first trying
355
+ // to mount or when the our selector changes. The selector change in particular is
356
+ // how we suspend for pagination and refetech. Also, fragment selector can be null
357
+ // or undefined, so we use false as a special value to distinguish from all fragment
358
+ // selectors; false means that the component hasn't mounted yet.
359
+ var committedFragmentSelectorRef = useRef(false);
360
+ useEffect(function () {
361
+ committedFragmentSelectorRef.current = fragmentSelector;
362
+ }, [fragmentSelector]);
367
363
 
364
+ // Handle the queries for any missing client edges; this may suspend.
365
+ // FIXME handle client edges in parallel.
368
366
  if (((_fragmentNode$metadat2 = fragmentNode.metadata) === null || _fragmentNode$metadat2 === void 0 ? void 0 : _fragmentNode$metadat2.hasClientEdges) === true) {
369
367
  // The fragment is validated to be static (in useFragment) and hasClientEdges is
370
368
  // a static (constant) property of the fragment. In practice, this effect will
371
369
  // always or never run for a given invocation of this hook.
372
370
  // eslint-disable-next-line react-hooks/rules-of-hooks
373
- var effects = useMemo(function () {
374
- var missingClientEdges = getMissingClientEdges(state); // eslint-disable-next-line no-shadow
375
-
376
- var effects;
377
-
378
- if (missingClientEdges === null || missingClientEdges === void 0 ? void 0 : missingClientEdges.length) {
379
- effects = [];
380
-
381
- var _iterator5 = (0, _createForOfIteratorHelper2["default"])(missingClientEdges),
382
- _step5;
383
-
371
+ var clientEdgeQueries = useMemo(function () {
372
+ var missingClientEdges = getMissingClientEdges(state);
373
+ // eslint-disable-next-line no-shadow
374
+ var clientEdgeQueries;
375
+ if (missingClientEdges !== null && missingClientEdges !== void 0 && missingClientEdges.length) {
376
+ clientEdgeQueries = [];
377
+ var _iterator7 = (0, _createForOfIteratorHelper2["default"])(missingClientEdges),
378
+ _step7;
384
379
  try {
385
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
386
- var edge = _step5.value;
387
- effects.push(handleMissingClientEdge(environment, fragmentNode, fragmentRef, edge, queryOptions));
380
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
381
+ var edge = _step7.value;
382
+ clientEdgeQueries.push(handleMissingClientEdge(environment, fragmentNode, fragmentRef, edge, queryOptions));
388
383
  }
389
384
  } catch (err) {
390
- _iterator5.e(err);
385
+ _iterator7.e(err);
391
386
  } finally {
392
- _iterator5.f();
387
+ _iterator7.f();
393
388
  }
394
389
  }
390
+ return clientEdgeQueries;
391
+ }, [state, environment, fragmentNode, fragmentRef, queryOptions]);
395
392
 
396
- return effects;
397
- }, [state, environment, fragmentNode, fragmentRef, queryOptions]); // See above note
393
+ // See above note
398
394
  // eslint-disable-next-line react-hooks/rules-of-hooks
399
-
400
395
  useEffect(function () {
401
- if (effects === null || effects === void 0 ? void 0 : effects.length) {
402
- var cleanups = [];
403
-
404
- var _iterator6 = (0, _createForOfIteratorHelper2["default"])(effects),
405
- _step6;
406
-
396
+ var QueryResource = getQueryResourceForEnvironment(environment);
397
+ if (clientEdgeQueries !== null && clientEdgeQueries !== void 0 && clientEdgeQueries.length) {
398
+ var disposables = [];
399
+ var _iterator8 = (0, _createForOfIteratorHelper2["default"])(clientEdgeQueries),
400
+ _step8;
407
401
  try {
408
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
409
- var effect = _step6.value;
410
- cleanups.push(effect());
402
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
403
+ var query = _step8.value;
404
+ disposables.push(QueryResource.retain(query));
411
405
  }
412
406
  } catch (err) {
413
- _iterator6.e(err);
407
+ _iterator8.e(err);
414
408
  } finally {
415
- _iterator6.f();
409
+ _iterator8.f();
416
410
  }
417
-
418
411
  return function () {
419
- var _iterator7 = (0, _createForOfIteratorHelper2["default"])(cleanups),
420
- _step7;
421
-
412
+ var _iterator9 = (0, _createForOfIteratorHelper2["default"])(disposables),
413
+ _step9;
422
414
  try {
423
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
424
- var cleanup = _step7.value;
425
- cleanup();
415
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
416
+ var disposable = _step9.value;
417
+ disposable.dispose();
426
418
  }
427
419
  } catch (err) {
428
- _iterator7.e(err);
420
+ _iterator9.e(err);
429
421
  } finally {
430
- _iterator7.f();
422
+ _iterator9.f();
431
423
  }
432
424
  };
433
425
  }
434
- }, [effects]);
426
+ }, [environment, clientEdgeQueries]);
435
427
  }
436
-
437
428
  if (isMissingData(state)) {
429
+ // Suspend if a Live Resolver within this fragment is in a suspended state:
430
+ var suspendingLiveResolvers = getSuspendingLiveResolver(state);
431
+ if (suspendingLiveResolvers != null && suspendingLiveResolvers.length > 0) {
432
+ throw Promise.all(suspendingLiveResolvers.map(function (_ref) {
433
+ var liveStateID = _ref.liveStateID;
434
+ // $FlowFixMe[prop-missing] This is expected to be a LiveResolverStore
435
+ return environment.getStore().getLiveResolverPromise(liveStateID);
436
+ }));
437
+ }
438
438
  // Suspend if an active operation bears on this fragment, either the
439
- // fragment's owner or some other mutation etc. that could affect it:
440
- !(fragmentSelector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'refinement, see invariants above') : invariant(false) : void 0;
441
- var fragmentOwner = fragmentSelector.kind === 'PluralReaderSelector' ? fragmentSelector.selectors[0].owner : fragmentSelector.owner;
442
- var pendingOperationsResult = getPendingOperationsForFragment(environment, fragmentNode, fragmentOwner);
443
-
444
- if (pendingOperationsResult) {
445
- throw pendingOperationsResult.promise;
446
- } // Report required fields only if we're not suspending, since that means
439
+ // fragment's owner or some other mutation etc. that could affect it.
440
+ // We only suspend when the component is first trying to mount or changing
441
+ // selectors, not if data becomes missing later:
442
+ if (!committedFragmentSelectorRef.current || !areEqualSelectors(committedFragmentSelectorRef.current, fragmentSelector)) {
443
+ !(fragmentSelector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'refinement, see invariants above') : invariant(false) : void 0;
444
+ var fragmentOwner = fragmentSelector.kind === 'PluralReaderSelector' ? fragmentSelector.selectors[0].owner : fragmentSelector.owner;
445
+ var pendingOperationsResult = getPendingOperationsForFragment(environment, fragmentNode, fragmentOwner);
446
+ if (pendingOperationsResult) {
447
+ throw pendingOperationsResult.promise;
448
+ }
449
+ }
450
+ // Report required fields only if we're not suspending, since that means
447
451
  // they're missing even though we are out of options for possibly fetching them:
448
-
449
-
450
452
  handlePotentialSnapshotErrorsForState(environment, state);
451
453
  }
452
-
453
454
  useEffect(function () {
454
455
  // Check for updates since the state was rendered
455
456
  var currentState = subscribedState;
456
457
  var updates = handleMissedUpdates(environment, subscribedState);
457
-
458
458
  if (updates !== null) {
459
459
  var didMissUpdates = updates[0],
460
- updatedState = updates[1]; // TODO: didMissUpdates only checks for changes to snapshot data, but it's possible
460
+ updatedState = updates[1];
461
+ // TODO: didMissUpdates only checks for changes to snapshot data, but it's possible
461
462
  // that other snapshot properties may have changed that should also trigger a re-render,
462
463
  // such as changed missing resolver fields, missing client edges, etc.
463
464
  // A potential alternative is for handleMissedUpdates() to recycle the entire state
464
465
  // value, and return the new (recycled) state only if there was some change. In that
465
466
  // case the code would always setState if something in the snapshot changed, in addition
466
467
  // to using the latest snapshot to subscribe.
467
-
468
468
  if (didMissUpdates) {
469
469
  setState(updatedState);
470
470
  }
471
-
472
471
  currentState = updatedState;
473
472
  }
474
-
475
- return subscribeToSnapshot(environment, currentState, function (updater) {
476
- setState(function (latestState) {
477
- var _latestState$snapshot, _currentState$snapsho;
478
-
479
- if (((_latestState$snapshot = latestState.snapshot) === null || _latestState$snapshot === void 0 ? void 0 : _latestState$snapshot.selector) !== ((_currentState$snapsho = currentState.snapshot) === null || _currentState$snapsho === void 0 ? void 0 : _currentState$snapsho.selector)) {
480
- // Ignore updates to the subscription if it's for a previous fragment selector
481
- // than the latest one to be rendered. This can happen if the store is updated
482
- // after we re-render with a new fragmentRef prop but before the effect fires
483
- // in which we unsubscribe to the old one and subscribe to the new one.
484
- // (NB: it's safe to compare the selectors by reference because the selector
485
- // is recycled into new snapshots.)
486
- return latestState;
487
- } else {
488
- return updater(latestState);
489
- }
490
- });
491
- });
473
+ return subscribeToSnapshot(environment, currentState, setState);
492
474
  }, [environment, subscribedState]);
493
475
  var data;
494
-
495
476
  if (isPlural) {
496
477
  // Plural fragments require allocating an array of the snasphot data values,
497
478
  // which has to be memoized to avoid triggering downstream re-renders.
498
479
  //
499
480
  // Note that isPlural is a constant property of the fragment and does not change
500
481
  // for a particular useFragment invocation site
482
+ var fragmentRefIsNullish = fragmentRef == null; // for less sensitive memoization
501
483
  // eslint-disable-next-line react-hooks/rules-of-hooks
502
484
  data = useMemo(function () {
503
485
  if (state.kind === 'bailout') {
504
- return [];
486
+ // Bailout state can happen if the fragmentRef is a plural array that is empty or has no
487
+ // non-null entries. In that case, the compatible behavior is to return [] instead of null.
488
+ return fragmentRefIsNullish ? null : [];
505
489
  } else {
506
490
  !(state.kind === 'plural') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected state to be plural because fragment is plural') : invariant(false) : void 0;
507
491
  return state.snapshots.map(function (s) {
508
492
  return s.data;
509
493
  });
510
494
  }
511
- }, [state]);
495
+ }, [state, fragmentRefIsNullish]);
512
496
  } else if (state.kind === 'bailout') {
513
497
  // This case doesn't allocate a new object so it doesn't have to be memoized
514
498
  data = null;
@@ -517,7 +501,6 @@ function useFragmentInternal_REACT_CACHE(fragmentNode, fragmentRef, hookDisplayN
517
501
  !(state.kind === 'singular') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected state to be singular because fragment is singular') : invariant(false) : void 0;
518
502
  data = state.snapshot.data;
519
503
  }
520
-
521
504
  if (process.env.NODE_ENV !== "production") {
522
505
  if (fragmentRef != null && (data === undefined || Array.isArray(data) && data.length > 0 && data.every(function (d) {
523
506
  return d === undefined;
@@ -525,7 +508,6 @@ function useFragmentInternal_REACT_CACHE(fragmentNode, fragmentRef, hookDisplayN
525
508
  process.env.NODE_ENV !== "production" ? warning(false, 'Relay: Expected to have been able to read non-null data for ' + 'fragment `%s` declared in ' + '`%s`, since fragment reference was non-null. ' + "Make sure that that `%s`'s parent isn't " + 'holding on to and/or passing a fragment reference for data that ' + 'has been deleted.', fragmentNode.name, hookDisplayName, hookDisplayName) : void 0;
526
509
  }
527
510
  }
528
-
529
511
  if (process.env.NODE_ENV !== "production") {
530
512
  // eslint-disable-next-line react-hooks/rules-of-hooks
531
513
  useDebugValue({
@@ -533,8 +515,6 @@ function useFragmentInternal_REACT_CACHE(fragmentNode, fragmentRef, hookDisplayN
533
515
  data: data
534
516
  });
535
517
  }
536
-
537
518
  return data;
538
519
  }
539
-
540
520
  module.exports = useFragmentInternal_REACT_CACHE;