react-relay 16.0.0 → 16.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. package/ReactRelayContext.js +1 -1
  2. package/ReactRelayTypes.js.flow +1 -0
  3. package/hooks.js +1 -1
  4. package/hooks.js.flow +1 -1
  5. package/index.js +1 -1
  6. package/index.js.flow +1 -1
  7. package/legacy.js +1 -1
  8. package/lib/relay-hooks/HooksImplementation.js +1 -1
  9. package/lib/relay-hooks/SuspenseResource.js +7 -4
  10. package/lib/relay-hooks/{react-cache/readFragmentInternal_REACT_CACHE.js → experimental/readFragmentInternal_EXPERIMENTAL.js} +4 -4
  11. package/lib/relay-hooks/{react-cache/useFragmentInternal_REACT_CACHE.js → experimental/useFragmentInternal_EXPERIMENTAL.js} +63 -29
  12. package/lib/relay-hooks/{react-cache/useFragment_REACT_CACHE.js → experimental/useFragment_EXPERIMENTAL.js} +1 -1
  13. package/lib/relay-hooks/{react-cache/usePaginationFragment_REACT_CACHE.js → experimental/usePaginationFragment_EXPERIMENTAL.js} +1 -1
  14. package/lib/relay-hooks/{react-cache/useRefetchableFragmentInternal_REACT_CACHE.js → experimental/useRefetchableFragmentInternal_EXPERIMENTAL.js} +2 -2
  15. package/lib/relay-hooks/{react-cache/useRefetchableFragment_REACT_CACHE.js → experimental/useRefetchableFragment_EXPERIMENTAL.js} +1 -1
  16. package/lib/relay-hooks/{FragmentResource.js → legacy/FragmentResource.js} +7 -6
  17. package/lib/relay-hooks/{useBlockingPaginationFragment.js → legacy/useBlockingPaginationFragment.js} +2 -2
  18. package/lib/relay-hooks/{useFragmentNode.js → legacy/useFragmentNode.js} +2 -2
  19. package/lib/relay-hooks/{useRefetchableFragmentNode.js → legacy/useRefetchableFragmentNode.js} +8 -8
  20. package/lib/relay-hooks/useFragment.js +1 -1
  21. package/lib/relay-hooks/useLazyLoadQueryNode.js +13 -3
  22. package/lib/relay-hooks/usePaginationFragment.js +1 -1
  23. package/lib/relay-hooks/useRefetchableFragment.js +1 -1
  24. package/package.json +2 -2
  25. package/react-relay-hooks.js +2 -2
  26. package/react-relay-hooks.min.js +2 -2
  27. package/react-relay-legacy.js +2 -2
  28. package/react-relay-legacy.min.js +2 -2
  29. package/react-relay.js +2 -2
  30. package/react-relay.min.js +2 -2
  31. package/relay-hooks/EntryPointTypes.flow.js.flow +25 -33
  32. package/relay-hooks/HooksImplementation.js.flow +3 -1
  33. package/relay-hooks/NestedRelayEntryPointBuilderUtils.js.flow +5 -11
  34. package/relay-hooks/SuspenseResource.js.flow +11 -8
  35. package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +1 -1
  36. package/relay-hooks/{react-cache/readFragmentInternal_REACT_CACHE.js.flow → experimental/readFragmentInternal_EXPERIMENTAL.js.flow} +4 -2
  37. package/relay-hooks/{react-cache/useFragmentInternal_REACT_CACHE.js.flow → experimental/useFragmentInternal_EXPERIMENTAL.js.flow} +61 -18
  38. package/relay-hooks/{react-cache/useFragment_REACT_CACHE.js.flow → experimental/useFragment_EXPERIMENTAL.js.flow} +10 -4
  39. package/relay-hooks/{react-cache/usePaginationFragment_REACT_CACHE.js.flow → experimental/usePaginationFragment_EXPERIMENTAL.js.flow} +2 -2
  40. package/relay-hooks/{react-cache/useRefetchableFragmentInternal_REACT_CACHE.js.flow → experimental/useRefetchableFragmentInternal_EXPERIMENTAL.js.flow} +11 -11
  41. package/relay-hooks/{react-cache/useRefetchableFragment_REACT_CACHE.js.flow → experimental/useRefetchableFragment_EXPERIMENTAL.js.flow} +1 -1
  42. package/relay-hooks/{FragmentResource.js.flow → legacy/FragmentResource.js.flow} +8 -5
  43. package/relay-hooks/{useBlockingPaginationFragment.js.flow → legacy/useBlockingPaginationFragment.js.flow} +13 -18
  44. package/relay-hooks/{useFragmentNode.js.flow → legacy/useFragmentNode.js.flow} +2 -2
  45. package/relay-hooks/{useRefetchableFragmentNode.js.flow → legacy/useRefetchableFragmentNode.js.flow} +12 -14
  46. package/relay-hooks/loadQuery.js.flow +1 -1
  47. package/relay-hooks/useFragment.js.flow +10 -4
  48. package/relay-hooks/useLazyLoadQueryNode.js.flow +18 -2
  49. package/relay-hooks/usePaginationFragment.js.flow +7 -9
  50. package/relay-hooks/useRefetchableFragment.js.flow +15 -18
  51. package/lib/relay-hooks/react-cache/RelayReactCache.js +0 -20
  52. package/lib/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js +0 -255
  53. package/lib/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js +0 -33
  54. package/lib/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js +0 -81
  55. package/relay-hooks/react-cache/RelayReactCache.js.flow +0 -40
  56. package/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js.flow +0 -430
  57. package/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js.flow +0 -70
  58. package/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js.flow +0 -150
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v16.0.0
2
+ * Relay v16.2.0
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -103,6 +103,7 @@ export type $FragmentRef<T> = {
103
103
  */
104
104
  // prettier-ignore
105
105
  // $FlowFixMe[extra-type-arg] xplat redux flow type error
106
+ // $FlowFixMe[deprecated-type]
106
107
  export type $RelayProps<Props, RelayPropT = RelayProp> = $ObjMap<
107
108
  $Diff<Props, { relay: RelayPropT | void, ... }>,
108
109
  & (<T: { +$fragmentType: empty, ... }>( T) => T)
package/hooks.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v16.0.0
2
+ * Relay v16.2.0
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
package/hooks.js.flow CHANGED
@@ -42,7 +42,7 @@ export type {
42
42
  RefetchFn,
43
43
  RefetchFnDynamic,
44
44
  Options as RefetchOptions,
45
- } from './relay-hooks/useRefetchableFragmentNode';
45
+ } from './relay-hooks/legacy/useRefetchableFragmentNode';
46
46
  export type {
47
47
  DataID,
48
48
  DeclarativeMutationConfig,
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v16.0.0
2
+ * Relay v16.2.0
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
package/index.js.flow CHANGED
@@ -59,7 +59,7 @@ export type {
59
59
  RefetchFn,
60
60
  RefetchFnDynamic,
61
61
  Options as RefetchOptions,
62
- } from './relay-hooks/useRefetchableFragmentNode';
62
+ } from './relay-hooks/legacy/useRefetchableFragmentNode';
63
63
  export type {
64
64
  DataID,
65
65
  DeclarativeMutationConfig,
package/legacy.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v16.0.0
2
+ * Relay v16.2.0
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -3,7 +3,7 @@
3
3
  var warning = require("fbjs/lib/warning");
4
4
  var implementation = null;
5
5
  function inject(impl) {
6
- process.env.NODE_ENV !== "production" ? warning(implementation !== null, 'Relay HooksImplementation was injected twice.') : void 0;
6
+ process.env.NODE_ENV !== "production" ? warning(implementation === null, 'Relay HooksImplementation was injected twice.') : void 0;
7
7
  implementation = impl;
8
8
  }
9
9
  function get() {
@@ -2,7 +2,7 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
5
- var invariant = require('invariant');
5
+ var warning = require("fbjs/lib/warning");
6
6
  var TEMPORARY_RETAIN_DURATION_MS = 5 * 60 * 1000;
7
7
  var SuspenseResource = /*#__PURE__*/function () {
8
8
  function SuspenseResource(retain) {
@@ -19,9 +19,12 @@ var SuspenseResource = /*#__PURE__*/function () {
19
19
  dispose: function dispose() {
20
20
  _this._retainCount = Math.max(0, _this._retainCount - 1);
21
21
  if (_this._retainCount === 0) {
22
- !(_this._retainDisposable != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected disposable to release query to be defined.' + "If you're seeing this, this is likely a bug in Relay.") : invariant(false) : void 0;
23
- _this._retainDisposable.dispose();
24
- _this._retainDisposable = null;
22
+ if (_this._retainDisposable != null) {
23
+ _this._retainDisposable.dispose();
24
+ _this._retainDisposable = null;
25
+ } else {
26
+ process.env.NODE_ENV !== "production" ? warning(false, 'Relay: Expected disposable to release query to be defined.' + "If you're seeing this, this is likely a bug in Relay.") : void 0;
27
+ }
25
28
  }
26
29
  }
27
30
  };
@@ -66,14 +66,14 @@ function getMissingClientEdges(state) {
66
66
  }
67
67
  function handlePotentialSnapshotErrorsForState(environment, state) {
68
68
  if (state.kind === 'singular') {
69
- handlePotentialSnapshotErrors(environment, state.snapshot.missingRequiredFields, state.snapshot.relayResolverErrors);
69
+ handlePotentialSnapshotErrors(environment, state.snapshot.missingRequiredFields, state.snapshot.relayResolverErrors, state.snapshot.errorResponseFields);
70
70
  } else if (state.kind === 'plural') {
71
71
  var _iterator3 = (0, _createForOfIteratorHelper2["default"])(state.snapshots),
72
72
  _step3;
73
73
  try {
74
74
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
75
75
  var snapshot = _step3.value;
76
- handlePotentialSnapshotErrors(environment, snapshot.missingRequiredFields, snapshot.relayResolverErrors);
76
+ handlePotentialSnapshotErrors(environment, snapshot.missingRequiredFields, snapshot.relayResolverErrors, snapshot.errorResponseFields);
77
77
  }
78
78
  } catch (err) {
79
79
  _iterator3.e(err);
@@ -118,7 +118,7 @@ function getFragmentState(environment, fragmentSelector) {
118
118
  };
119
119
  }
120
120
  }
121
- function readFragmentInternal_REACT_CACHE(environment, fragmentNode, fragmentRef, hookDisplayName, queryOptions, fragmentKey) {
121
+ function readFragmentInternal_EXPERIMENTAL(environment, fragmentNode, fragmentRef, hookDisplayName, queryOptions, fragmentKey) {
122
122
  var _fragmentNode$metadat, _fragmentNode$metadat2;
123
123
  var fragmentSelector = getSelector(fragmentNode, fragmentRef);
124
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;
@@ -179,4 +179,4 @@ function readFragmentInternal_REACT_CACHE(environment, fragmentNode, fragmentRef
179
179
  clientEdgeQueries: clientEdgeQueries
180
180
  };
181
181
  }
182
- module.exports = readFragmentInternal_REACT_CACHE;
182
+ module.exports = readFragmentInternal_EXPERIMENTAL;
@@ -15,7 +15,9 @@ var _require2 = require('react'),
15
15
  useRef = _require2.useRef,
16
16
  useState = _require2.useState;
17
17
  var _require3 = require('relay-runtime'),
18
- fetchQueryInternal = _require3.__internal.fetchQuery,
18
+ _require3$__internal = _require3.__internal,
19
+ fetchQueryInternal = _require3$__internal.fetchQuery,
20
+ getPromiseForActiveRequest = _require3$__internal.getPromiseForActiveRequest,
19
21
  RelayFeatureFlags = _require3.RelayFeatureFlags,
20
22
  areEqualSelectors = _require3.areEqualSelectors,
21
23
  createOperationDescriptor = _require3.createOperationDescriptor,
@@ -114,14 +116,14 @@ function getSuspendingLiveResolver(state) {
114
116
  }
115
117
  function handlePotentialSnapshotErrorsForState(environment, state) {
116
118
  if (state.kind === 'singular') {
117
- handlePotentialSnapshotErrors(environment, state.snapshot.missingRequiredFields, state.snapshot.relayResolverErrors);
119
+ handlePotentialSnapshotErrors(environment, state.snapshot.missingRequiredFields, state.snapshot.relayResolverErrors, state.snapshot.errorResponseFields);
118
120
  } else if (state.kind === 'plural') {
119
121
  var _iterator5 = (0, _createForOfIteratorHelper2["default"])(state.snapshots),
120
122
  _step5;
121
123
  try {
122
124
  for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
123
125
  var snapshot = _step5.value;
124
- handlePotentialSnapshotErrors(environment, snapshot.missingRequiredFields, snapshot.relayResolverErrors);
126
+ handlePotentialSnapshotErrors(environment, snapshot.missingRequiredFields, snapshot.relayResolverErrors, snapshot.errorResponseFields);
125
127
  }
126
128
  } catch (err) {
127
129
  _iterator5.e(err);
@@ -149,7 +151,8 @@ function handleMissedUpdates(environment, state) {
149
151
  seenRecords: currentSnapshot.seenRecords,
150
152
  selector: currentSnapshot.selector,
151
153
  missingRequiredFields: currentSnapshot.missingRequiredFields,
152
- relayResolverErrors: currentSnapshot.relayResolverErrors
154
+ relayResolverErrors: currentSnapshot.relayResolverErrors,
155
+ errorResponseFields: currentSnapshot.errorResponseFields
153
156
  };
154
157
  return [updatedData !== state.snapshot.data, {
155
158
  kind: 'singular',
@@ -171,7 +174,8 @@ function handleMissedUpdates(environment, state) {
171
174
  seenRecords: _currentSnapshot.seenRecords,
172
175
  selector: _currentSnapshot.selector,
173
176
  missingRequiredFields: _currentSnapshot.missingRequiredFields,
174
- relayResolverErrors: _currentSnapshot.relayResolverErrors
177
+ relayResolverErrors: _currentSnapshot.relayResolverErrors,
178
+ errorResponseFields: _currentSnapshot.errorResponseFields
175
179
  };
176
180
  if (_updatedData !== snapshot.data) {
177
181
  didMissUpdates = true;
@@ -193,9 +197,10 @@ function handleMissingClientEdge(environment, parentFragmentNode, parentFragment
193
197
  });
194
198
  var queryOperationDescriptor = createOperationDescriptor(missingClientEdgeRequestInfo.request, variables, queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.networkCacheConfig);
195
199
  var QueryResource = getQueryResourceForEnvironment(environment);
196
- return QueryResource.prepare(queryOperationDescriptor, fetchQueryInternal(environment, queryOperationDescriptor), queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.fetchPolicy);
200
+ var queryResult = QueryResource.prepare(queryOperationDescriptor, fetchQueryInternal(environment, queryOperationDescriptor), queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.fetchPolicy);
201
+ return [queryResult, getPromiseForActiveRequest(environment, queryOperationDescriptor.request)];
197
202
  }
198
- function subscribeToSnapshot(environment, state, setState) {
203
+ function subscribeToSnapshot(environment, state, setState, hasPendingStateChanges) {
199
204
  if (state.kind === 'bailout') {
200
205
  return function () {};
201
206
  } else if (state.kind === 'singular') {
@@ -210,11 +215,13 @@ function subscribeToSnapshot(environment, state, setState) {
210
215
  name: 'useFragment.subscription.missedUpdates',
211
216
  hasDataChanges: dataChanged
212
217
  });
218
+ hasPendingStateChanges.current = dataChanged;
213
219
  return dataChanged ? nextState : prevState;
214
220
  } else {
215
221
  return prevState;
216
222
  }
217
223
  }
224
+ hasPendingStateChanges.current = true;
218
225
  return {
219
226
  kind: 'singular',
220
227
  snapshot: latestSnapshot,
@@ -239,6 +246,7 @@ function subscribeToSnapshot(environment, state, setState) {
239
246
  name: 'useFragment.subscription.missedUpdates',
240
247
  hasDataChanges: dataChanged
241
248
  });
249
+ hasPendingStateChanges.current = hasPendingStateChanges.current || dataChanged;
242
250
  return dataChanged ? nextState : prevState;
243
251
  } else {
244
252
  return prevState;
@@ -246,6 +254,7 @@ function subscribeToSnapshot(environment, state, setState) {
246
254
  }
247
255
  var updated = (0, _toConsumableArray2["default"])(prevState.snapshots);
248
256
  updated[index] = latestSnapshot;
257
+ hasPendingStateChanges.current = true;
249
258
  return {
250
259
  kind: 'plural',
251
260
  snapshots: updated,
@@ -291,7 +300,7 @@ function getFragmentState(environment, fragmentSelector) {
291
300
  };
292
301
  }
293
302
  }
294
- function useFragmentInternal_REACT_CACHE(fragmentNode, fragmentRef, hookDisplayName, queryOptions) {
303
+ function useFragmentInternal_EXPERIMENTAL(fragmentNode, fragmentRef, hookDisplayName, queryOptions) {
295
304
  var _fragmentNode$metadat, _fragmentNode$metadat2;
296
305
  var fragmentSelector = useMemo(function () {
297
306
  return getSelector(fragmentNode, fragmentRef);
@@ -334,26 +343,38 @@ function useFragmentInternal_REACT_CACHE(fragmentNode, fragmentRef, hookDisplayN
334
343
  committedFragmentSelectorRef.current = fragmentSelector;
335
344
  }, [fragmentSelector]);
336
345
  if (((_fragmentNode$metadat2 = fragmentNode.metadata) === null || _fragmentNode$metadat2 === void 0 ? void 0 : _fragmentNode$metadat2.hasClientEdges) === true) {
337
- var clientEdgeQueries = useMemo(function () {
338
- var missingClientEdges = getMissingClientEdges(state);
339
- var clientEdgeQueries;
340
- if (missingClientEdges !== null && missingClientEdges !== void 0 && missingClientEdges.length) {
341
- clientEdgeQueries = [];
342
- var _iterator7 = (0, _createForOfIteratorHelper2["default"])(missingClientEdges),
343
- _step7;
344
- try {
345
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
346
- var edge = _step7.value;
347
- clientEdgeQueries.push(handleMissingClientEdge(environment, fragmentNode, fragmentRef, edge, queryOptions));
346
+ var _useMemo = useMemo(function () {
347
+ var missingClientEdges = getMissingClientEdges(state);
348
+ var clientEdgeQueries;
349
+ var activeRequestPromises = [];
350
+ if (missingClientEdges !== null && missingClientEdges !== void 0 && missingClientEdges.length) {
351
+ clientEdgeQueries = [];
352
+ var _iterator7 = (0, _createForOfIteratorHelper2["default"])(missingClientEdges),
353
+ _step7;
354
+ try {
355
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
356
+ var edge = _step7.value;
357
+ var _handleMissingClientE = handleMissingClientEdge(environment, fragmentNode, fragmentRef, edge, queryOptions),
358
+ queryResult = _handleMissingClientE[0],
359
+ requestPromise = _handleMissingClientE[1];
360
+ clientEdgeQueries.push(queryResult);
361
+ if (requestPromise != null) {
362
+ activeRequestPromises.push(requestPromise);
363
+ }
364
+ }
365
+ } catch (err) {
366
+ _iterator7.e(err);
367
+ } finally {
368
+ _iterator7.f();
348
369
  }
349
- } catch (err) {
350
- _iterator7.e(err);
351
- } finally {
352
- _iterator7.f();
353
370
  }
354
- }
355
- return clientEdgeQueries;
356
- }, [state, environment, fragmentNode, fragmentRef, queryOptions]);
371
+ return [clientEdgeQueries, activeRequestPromises];
372
+ }, [state, environment, fragmentNode, fragmentRef, queryOptions]),
373
+ clientEdgeQueries = _useMemo[0],
374
+ activeRequestPromises = _useMemo[1];
375
+ if (activeRequestPromises.length) {
376
+ throw Promise.all(activeRequestPromises);
377
+ }
357
378
  useEffect(function () {
358
379
  var QueryResource = getQueryResourceForEnvironment(environment);
359
380
  if (clientEdgeQueries !== null && clientEdgeQueries !== void 0 && clientEdgeQueries.length) {
@@ -395,7 +416,7 @@ function useFragmentInternal_REACT_CACHE(fragmentNode, fragmentRef, hookDisplayN
395
416
  return environment.getStore().getLiveResolverPromise(liveStateID);
396
417
  }));
397
418
  }
398
- if (!committedFragmentSelectorRef.current || !areEqualSelectors(committedFragmentSelectorRef.current, fragmentSelector)) {
419
+ if (environment !== previousEnvironment || !committedFragmentSelectorRef.current || !areEqualSelectors(committedFragmentSelectorRef.current, fragmentSelector)) {
399
420
  !(fragmentSelector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'refinement, see invariants above') : invariant(false) : void 0;
400
421
  var fragmentOwner = fragmentSelector.kind === 'PluralReaderSelector' ? fragmentSelector.selectors[0].owner : fragmentSelector.owner;
401
422
  var pendingOperationsResult = getPendingOperationsForFragment(environment, fragmentNode, fragmentOwner);
@@ -405,6 +426,7 @@ function useFragmentInternal_REACT_CACHE(fragmentNode, fragmentRef, hookDisplayN
405
426
  }
406
427
  }
407
428
  handlePotentialSnapshotErrorsForState(environment, state);
429
+ var hasPendingStateChanges = useRef(false);
408
430
  useEffect(function () {
409
431
  var currentState = subscribedState;
410
432
  var updates = handleMissedUpdates(environment, subscribedState);
@@ -416,8 +438,20 @@ function useFragmentInternal_REACT_CACHE(fragmentNode, fragmentRef, hookDisplayN
416
438
  }
417
439
  currentState = updatedState;
418
440
  }
419
- return subscribeToSnapshot(environment, currentState, setState);
441
+ return subscribeToSnapshot(environment, currentState, setState, hasPendingStateChanges);
420
442
  }, [environment, subscribedState]);
443
+ if (hasPendingStateChanges.current) {
444
+ var updates = handleMissedUpdates(environment, state);
445
+ if (updates != null) {
446
+ var hasStateUpdates = updates[0],
447
+ updatedState = updates[1];
448
+ if (hasStateUpdates) {
449
+ setState(updatedState);
450
+ state = updatedState;
451
+ }
452
+ }
453
+ hasPendingStateChanges.current = false;
454
+ }
421
455
  var data;
422
456
  if (isPlural) {
423
457
  var fragmentRefIsNullish = fragmentRef == null;
@@ -452,4 +486,4 @@ function useFragmentInternal_REACT_CACHE(fragmentNode, fragmentRef, hookDisplayN
452
486
  }
453
487
  return data;
454
488
  }
455
- module.exports = useFragmentInternal_REACT_CACHE;
489
+ module.exports = useFragmentInternal_EXPERIMENTAL;
@@ -3,7 +3,7 @@
3
3
  var _require = require('../loadQuery'),
4
4
  useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
5
5
  var useStaticFragmentNodeWarning = require('../useStaticFragmentNodeWarning');
6
- var useFragmentInternal = require('./useFragmentInternal_REACT_CACHE');
6
+ var useFragmentInternal = require('./useFragmentInternal_EXPERIMENTAL');
7
7
  var _require2 = require('react'),
8
8
  useDebugValue = _require2.useDebugValue;
9
9
  var _require3 = require('relay-runtime'),
@@ -5,7 +5,7 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
5
5
  var useLoadMoreFunction = require('../useLoadMoreFunction');
6
6
  var useRelayEnvironment = require('../useRelayEnvironment');
7
7
  var useStaticFragmentNodeWarning = require('../useStaticFragmentNodeWarning');
8
- var useRefetchableFragmentInternal = require('./useRefetchableFragmentInternal_REACT_CACHE');
8
+ var useRefetchableFragmentInternal = require('./useRefetchableFragmentInternal_EXPERIMENTAL');
9
9
  var _require = require('react'),
10
10
  useCallback = _require.useCallback,
11
11
  useDebugValue = _require.useDebugValue,
@@ -8,8 +8,8 @@ var _require = require('../QueryResource'),
8
8
  var useIsMountedRef = require('../useIsMountedRef');
9
9
  var useQueryLoader = require('../useQueryLoader');
10
10
  var useRelayEnvironment = require('../useRelayEnvironment');
11
- var readFragmentInternal = require('./readFragmentInternal_REACT_CACHE');
12
- var useFragmentInternal = require('./useFragmentInternal_REACT_CACHE');
11
+ var readFragmentInternal = require('./readFragmentInternal_EXPERIMENTAL');
12
+ var useFragmentInternal = require('./useFragmentInternal_EXPERIMENTAL');
13
13
  var invariant = require('invariant');
14
14
  var _require2 = require('react'),
15
15
  useCallback = _require2.useCallback,
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var useStaticFragmentNodeWarning = require('../useStaticFragmentNodeWarning');
4
- var useRefetchableFragmentInternal = require('./useRefetchableFragmentInternal_REACT_CACHE');
4
+ var useRefetchableFragmentInternal = require('./useRefetchableFragmentInternal_EXPERIMENTAL');
5
5
  var _require = require('react'),
6
6
  useDebugValue = _require.useDebugValue;
7
7
  var _require2 = require('relay-runtime'),
@@ -4,10 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
5
5
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
6
6
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
7
- var LRUCache = require('./LRUCache');
8
- var _require = require('./QueryResource'),
7
+ var LRUCache = require('../LRUCache');
8
+ var _require = require('../QueryResource'),
9
9
  getQueryResourceForEnvironment = _require.getQueryResourceForEnvironment;
10
- var SuspenseResource = require('./SuspenseResource');
10
+ var SuspenseResource = require('../SuspenseResource');
11
11
  var invariant = require('invariant');
12
12
  var _require2 = require('relay-runtime'),
13
13
  _require2$__internal = _require2.__internal,
@@ -311,10 +311,10 @@ var FragmentResourceImpl = /*#__PURE__*/function () {
311
311
  var _this4 = this;
312
312
  if (Array.isArray(snapshot)) {
313
313
  snapshot.forEach(function (s) {
314
- handlePotentialSnapshotErrors(_this4._environment, s.missingRequiredFields, s.relayResolverErrors);
314
+ handlePotentialSnapshotErrors(_this4._environment, s.missingRequiredFields, s.relayResolverErrors, s.errorResponseFields);
315
315
  });
316
316
  } else {
317
- handlePotentialSnapshotErrors(this._environment, snapshot.missingRequiredFields, snapshot.relayResolverErrors);
317
+ handlePotentialSnapshotErrors(this._environment, snapshot.missingRequiredFields, snapshot.relayResolverErrors, snapshot.errorResponseFields);
318
318
  }
319
319
  };
320
320
  _proto2.readSpec = function readSpec(fragmentNodes, fragmentRefs, componentDisplayName) {
@@ -459,7 +459,8 @@ var FragmentResourceImpl = /*#__PURE__*/function () {
459
459
  seenRecords: currentSnapshot.seenRecords,
460
460
  selector: currentSnapshot.selector,
461
461
  missingRequiredFields: currentSnapshot.missingRequiredFields,
462
- relayResolverErrors: currentSnapshot.relayResolverErrors
462
+ relayResolverErrors: currentSnapshot.relayResolverErrors,
463
+ errorResponseFields: currentSnapshot.errorResponseFields
463
464
  };
464
465
  if (updatedData !== renderData) {
465
466
  var _result = getFragmentResult(cacheKey, updatedCurrentSnapshot, storeEpoch);
@@ -4,9 +4,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
5
5
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
6
6
  var _excluded = ["disableStoreUpdates", "enableStoreUpdates"];
7
- var useLoadMoreFunction = require('./useLoadMoreFunction');
7
+ var useLoadMoreFunction = require('../useLoadMoreFunction');
8
+ var useStaticFragmentNodeWarning = require('../useStaticFragmentNodeWarning');
8
9
  var useRefetchableFragmentNode = require('./useRefetchableFragmentNode');
9
- var useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
10
10
  var invariant = require('invariant');
11
11
  var _require = require('react'),
12
12
  useCallback = _require.useCallback,
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ var useRelayEnvironment = require('../useRelayEnvironment');
4
+ var useUnsafeRef_DEPRECATED = require('../useUnsafeRef_DEPRECATED');
3
5
  var _require = require('./FragmentResource'),
4
6
  getFragmentResourceForEnvironment = _require.getFragmentResourceForEnvironment;
5
- var useRelayEnvironment = require('./useRelayEnvironment');
6
- var useUnsafeRef_DEPRECATED = require('./useUnsafeRef_DEPRECATED');
7
7
  var _require2 = require('react'),
8
8
  useEffect = _require2.useEffect,
9
9
  useState = _require2.useState;
@@ -2,15 +2,15 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
5
- var _require = require('./FragmentResource'),
6
- getFragmentResourceForEnvironment = _require.getFragmentResourceForEnvironment;
7
- var ProfilerContext = require('./ProfilerContext');
8
- var _require2 = require('./QueryResource'),
9
- getQueryResourceForEnvironment = _require2.getQueryResourceForEnvironment;
5
+ var ProfilerContext = require('../ProfilerContext');
6
+ var _require = require('../QueryResource'),
7
+ getQueryResourceForEnvironment = _require.getQueryResourceForEnvironment;
8
+ var useIsMountedRef = require('../useIsMountedRef');
9
+ var useQueryLoader = require('../useQueryLoader');
10
+ var useRelayEnvironment = require('../useRelayEnvironment');
11
+ var _require2 = require('./FragmentResource'),
12
+ getFragmentResourceForEnvironment = _require2.getFragmentResourceForEnvironment;
10
13
  var useFragmentNode = require('./useFragmentNode');
11
- var useIsMountedRef = require('./useIsMountedRef');
12
- var useQueryLoader = require('./useQueryLoader');
13
- var useRelayEnvironment = require('./useRelayEnvironment');
14
14
  var invariant = require('invariant');
15
15
  var _require3 = require('react'),
16
16
  useCallback = _require3.useCallback,
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var HooksImplementation = require('./HooksImplementation');
4
+ var useFragmentNode = require('./legacy/useFragmentNode');
4
5
  var _require = require('./loadQuery'),
5
6
  useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
6
- var useFragmentNode = require('./useFragmentNode');
7
7
  var useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
8
8
  var _require2 = require('react'),
9
9
  useDebugValue = _require2.useDebugValue;
@@ -1,11 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ var HooksImplementation = require('./HooksImplementation');
4
+ var useFragmentNode = require('./legacy/useFragmentNode');
3
5
  var ProfilerContext = require('./ProfilerContext');
4
6
  var _require = require('./QueryResource'),
5
7
  getQueryCacheIdentifier = _require.getQueryCacheIdentifier,
6
8
  getQueryResourceForEnvironment = _require.getQueryResourceForEnvironment;
7
9
  var useFetchTrackingRef = require('./useFetchTrackingRef');
8
- var useFragmentNode = require('./useFragmentNode');
9
10
  var useRelayEnvironment = require('./useRelayEnvironment');
10
11
  var React = require('react');
11
12
  var useContext = React.useContext,
@@ -61,8 +62,17 @@ function useLazyLoadQueryNode(_ref) {
61
62
  });
62
63
  var fragmentNode = preparedQueryResult.fragmentNode,
63
64
  fragmentRef = preparedQueryResult.fragmentRef;
64
- var _useFragmentNode = useFragmentNode(fragmentNode, fragmentRef, componentDisplayName),
65
- data = _useFragmentNode.data;
65
+ var data = useFragmentNodeImpl(fragmentNode, fragmentRef, componentDisplayName);
66
66
  return data;
67
67
  }
68
+ function useFragmentNodeImpl(fragment, key, componentDisplayName) {
69
+ var impl = HooksImplementation.get();
70
+ if (impl && impl.useFragment__internal) {
71
+ return impl.useFragment__internal(fragment, key, componentDisplayName);
72
+ } else {
73
+ var _useFragmentNode = useFragmentNode(fragment, key, componentDisplayName),
74
+ data = _useFragmentNode.data;
75
+ return data;
76
+ }
77
+ }
68
78
  module.exports = useLazyLoadQueryNode;
@@ -3,8 +3,8 @@
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
5
5
  var HooksImplementation = require('./HooksImplementation');
6
+ var useRefetchableFragmentNode = require('./legacy/useRefetchableFragmentNode');
6
7
  var useLoadMoreFunction = require('./useLoadMoreFunction');
7
- var useRefetchableFragmentNode = require('./useRefetchableFragmentNode');
8
8
  var useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
9
9
  var _require = require('react'),
10
10
  useCallback = _require.useCallback,
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var HooksImplementation = require('./HooksImplementation');
4
- var useRefetchableFragmentNode = require('./useRefetchableFragmentNode');
4
+ var useRefetchableFragmentNode = require('./legacy/useRefetchableFragmentNode');
5
5
  var useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
6
6
  var _require = require('react'),
7
7
  useDebugValue = _require.useDebugValue;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-relay",
3
3
  "description": "A framework for building GraphQL-driven React applications.",
4
- "version": "16.0.0",
4
+ "version": "16.2.0",
5
5
  "keywords": [
6
6
  "graphql",
7
7
  "relay",
@@ -20,7 +20,7 @@
20
20
  "fbjs": "^3.0.2",
21
21
  "invariant": "^2.2.4",
22
22
  "nullthrows": "^1.1.1",
23
- "relay-runtime": "16.0.0"
23
+ "relay-runtime": "16.2.0"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": "^16.9.0 || ^17 || ^18"