react-relay 16.1.0 → 17.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. package/ReactRelayContext.js +1 -1
  2. package/ReactRelayFragmentContainer.js.flow +8 -6
  3. package/ReactRelayLocalQueryRenderer.js.flow +4 -1
  4. package/ReactRelayPaginationContainer.js.flow +2 -0
  5. package/ReactRelayQueryRenderer.js.flow +1 -1
  6. package/ReactRelayTypes.js.flow +1 -0
  7. package/buildReactRelayContainer.js.flow +5 -3
  8. package/getRootVariablesForFragments.js.flow +1 -0
  9. package/hooks.js +1 -1
  10. package/hooks.js.flow +1 -1
  11. package/index.js +1 -1
  12. package/index.js.flow +1 -1
  13. package/legacy.js +1 -1
  14. package/lib/ReactRelayFragmentContainer.js +2 -2
  15. package/lib/buildReactRelayContainer.js +3 -3
  16. package/lib/relay-hooks/SuspenseResource.js +7 -4
  17. package/lib/relay-hooks/{FragmentResource.js → legacy/FragmentResource.js} +19 -20
  18. package/lib/relay-hooks/{useBlockingPaginationFragment.js → legacy/useBlockingPaginationFragment.js} +2 -2
  19. package/lib/relay-hooks/{useFragmentNode.js → legacy/useFragmentNode.js} +2 -2
  20. package/lib/relay-hooks/{useRefetchableFragmentNode.js → legacy/useRefetchableFragmentNode.js} +8 -8
  21. package/lib/relay-hooks/{experimental/readFragmentInternal_EXPERIMENTAL.js → readFragmentInternal.js} +7 -5
  22. package/lib/relay-hooks/useFragment.js +3 -13
  23. package/lib/relay-hooks/{experimental/useFragmentInternal_EXPERIMENTAL.js → useFragmentInternal.js} +67 -31
  24. package/lib/relay-hooks/useLazyLoadQueryNode.js +2 -13
  25. package/lib/relay-hooks/usePaginationFragment.js +17 -13
  26. package/lib/relay-hooks/useRefetchableFragment.js +3 -12
  27. package/lib/relay-hooks/{experimental/useRefetchableFragmentInternal_EXPERIMENTAL.js → useRefetchableFragmentInternal.js} +7 -7
  28. package/multi-actor/useRelayActorEnvironment.js.flow +1 -1
  29. package/package.json +2 -2
  30. package/react-relay-hooks.js +2 -2
  31. package/react-relay-hooks.min.js +2 -2
  32. package/react-relay-legacy.js +2 -2
  33. package/react-relay-legacy.min.js +2 -2
  34. package/react-relay.js +2 -2
  35. package/react-relay.min.js +2 -2
  36. package/relay-hooks/EntryPointTypes.flow.js.flow +22 -27
  37. package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +14 -1
  38. package/relay-hooks/NestedRelayEntryPointBuilderUtils.js.flow +5 -11
  39. package/relay-hooks/SuspenseResource.js.flow +11 -8
  40. package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +22 -1
  41. package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +19 -0
  42. package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +22 -0
  43. package/relay-hooks/{FragmentResource.js.flow → legacy/FragmentResource.js.flow} +21 -21
  44. package/relay-hooks/{useBlockingPaginationFragment.js.flow → legacy/useBlockingPaginationFragment.js.flow} +6 -6
  45. package/relay-hooks/{useFragmentNode.js.flow → legacy/useFragmentNode.js.flow} +3 -3
  46. package/relay-hooks/{useRefetchableFragmentNode.js.flow → legacy/useRefetchableFragmentNode.js.flow} +9 -9
  47. package/relay-hooks/loadQuery.js.flow +9 -8
  48. package/relay-hooks/{experimental/readFragmentInternal_EXPERIMENTAL.js.flow → readFragmentInternal.js.flow} +8 -4
  49. package/relay-hooks/useClientQuery.js.flow +1 -1
  50. package/relay-hooks/useEntryPointLoader.js.flow +1 -1
  51. package/relay-hooks/useFetchTrackingRef.js.flow +1 -1
  52. package/relay-hooks/useFragment.js.flow +16 -22
  53. package/relay-hooks/{experimental/useFragmentInternal_EXPERIMENTAL.js.flow → useFragmentInternal.js.flow} +71 -19
  54. package/relay-hooks/useIsMountedRef.js.flow +1 -1
  55. package/relay-hooks/useIsOperationNodeActive.js.flow +1 -1
  56. package/relay-hooks/useIsParentQueryActive.js.flow +5 -2
  57. package/relay-hooks/useLazyLoadQuery.js.flow +3 -2
  58. package/relay-hooks/useLazyLoadQueryNode.js.flow +3 -19
  59. package/relay-hooks/useLoadMoreFunction.js.flow +1 -1
  60. package/relay-hooks/useMemoOperationDescriptor.js.flow +1 -1
  61. package/relay-hooks/useMemoVariables.js.flow +1 -1
  62. package/relay-hooks/useMutation.js.flow +1 -1
  63. package/relay-hooks/usePaginationFragment.js.flow +62 -50
  64. package/relay-hooks/usePreloadedQuery.js.flow +2 -1
  65. package/relay-hooks/useQueryLoader.js.flow +2 -5
  66. package/relay-hooks/useRefetchableFragment.js.flow +7 -37
  67. package/relay-hooks/{experimental/useRefetchableFragmentInternal_EXPERIMENTAL.js.flow → useRefetchableFragmentInternal.js.flow} +11 -11
  68. package/relay-hooks/useRelayEnvironment.js.flow +1 -1
  69. package/relay-hooks/useStaticFragmentNodeWarning.js.flow +3 -1
  70. package/relay-hooks/useSubscribeToInvalidationState.js.flow +1 -1
  71. package/relay-hooks/useSubscription.js.flow +1 -1
  72. package/relay-hooks/useUnsafeRef_DEPRECATED.js.flow +1 -1
  73. package/lib/relay-hooks/HooksImplementation.js +0 -15
  74. package/lib/relay-hooks/experimental/useFragment_EXPERIMENTAL.js +0 -26
  75. package/lib/relay-hooks/experimental/usePaginationFragment_EXPERIMENTAL.js +0 -127
  76. package/lib/relay-hooks/experimental/useRefetchableFragment_EXPERIMENTAL.js +0 -23
  77. package/relay-hooks/HooksImplementation.js.flow +0 -45
  78. package/relay-hooks/experimental/useFragment_EXPERIMENTAL.js.flow +0 -66
  79. package/relay-hooks/experimental/usePaginationFragment_EXPERIMENTAL.js.flow +0 -161
  80. package/relay-hooks/experimental/useRefetchableFragment_EXPERIMENTAL.js.flow +0 -49
@@ -4,9 +4,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
5
5
  var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
6
6
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
7
- var _require = require('../QueryResource'),
7
+ var _require = require('./QueryResource'),
8
8
  getQueryResourceForEnvironment = _require.getQueryResourceForEnvironment;
9
- var useRelayEnvironment = require('../useRelayEnvironment');
9
+ var useRelayEnvironment = require('./useRelayEnvironment');
10
10
  var invariant = require('invariant');
11
11
  var _require2 = require('react'),
12
12
  useDebugValue = _require2.useDebugValue,
@@ -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,16 @@ 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
+ var _state$snapshot$selec, _state$snapshot$selec2;
120
+ handlePotentialSnapshotErrors(environment, state.snapshot.missingRequiredFields, state.snapshot.relayResolverErrors, state.snapshot.errorResponseFields, (_state$snapshot$selec = (_state$snapshot$selec2 = state.snapshot.selector.node.metadata) === null || _state$snapshot$selec2 === void 0 ? void 0 : _state$snapshot$selec2.throwOnFieldError) !== null && _state$snapshot$selec !== void 0 ? _state$snapshot$selec : false);
118
121
  } else if (state.kind === 'plural') {
119
122
  var _iterator5 = (0, _createForOfIteratorHelper2["default"])(state.snapshots),
120
123
  _step5;
121
124
  try {
122
125
  for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
126
+ var _snapshot$selector$no, _snapshot$selector$no2;
123
127
  var snapshot = _step5.value;
124
- handlePotentialSnapshotErrors(environment, snapshot.missingRequiredFields, snapshot.relayResolverErrors);
128
+ handlePotentialSnapshotErrors(environment, snapshot.missingRequiredFields, snapshot.relayResolverErrors, snapshot.errorResponseFields, (_snapshot$selector$no = (_snapshot$selector$no2 = snapshot.selector.node.metadata) === null || _snapshot$selector$no2 === void 0 ? void 0 : _snapshot$selector$no2.throwOnFieldError) !== null && _snapshot$selector$no !== void 0 ? _snapshot$selector$no : false);
125
129
  }
126
130
  } catch (err) {
127
131
  _iterator5.e(err);
@@ -149,7 +153,8 @@ function handleMissedUpdates(environment, state) {
149
153
  seenRecords: currentSnapshot.seenRecords,
150
154
  selector: currentSnapshot.selector,
151
155
  missingRequiredFields: currentSnapshot.missingRequiredFields,
152
- relayResolverErrors: currentSnapshot.relayResolverErrors
156
+ relayResolverErrors: currentSnapshot.relayResolverErrors,
157
+ errorResponseFields: currentSnapshot.errorResponseFields
153
158
  };
154
159
  return [updatedData !== state.snapshot.data, {
155
160
  kind: 'singular',
@@ -171,7 +176,8 @@ function handleMissedUpdates(environment, state) {
171
176
  seenRecords: _currentSnapshot.seenRecords,
172
177
  selector: _currentSnapshot.selector,
173
178
  missingRequiredFields: _currentSnapshot.missingRequiredFields,
174
- relayResolverErrors: _currentSnapshot.relayResolverErrors
179
+ relayResolverErrors: _currentSnapshot.relayResolverErrors,
180
+ errorResponseFields: _currentSnapshot.errorResponseFields
175
181
  };
176
182
  if (_updatedData !== snapshot.data) {
177
183
  didMissUpdates = true;
@@ -193,9 +199,10 @@ function handleMissingClientEdge(environment, parentFragmentNode, parentFragment
193
199
  });
194
200
  var queryOperationDescriptor = createOperationDescriptor(missingClientEdgeRequestInfo.request, variables, queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.networkCacheConfig);
195
201
  var QueryResource = getQueryResourceForEnvironment(environment);
196
- return QueryResource.prepare(queryOperationDescriptor, fetchQueryInternal(environment, queryOperationDescriptor), queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.fetchPolicy);
202
+ var queryResult = QueryResource.prepare(queryOperationDescriptor, fetchQueryInternal(environment, queryOperationDescriptor), queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.fetchPolicy);
203
+ return [queryResult, getPromiseForActiveRequest(environment, queryOperationDescriptor.request)];
197
204
  }
198
- function subscribeToSnapshot(environment, state, setState) {
205
+ function subscribeToSnapshot(environment, state, setState, hasPendingStateChanges) {
199
206
  if (state.kind === 'bailout') {
200
207
  return function () {};
201
208
  } else if (state.kind === 'singular') {
@@ -210,11 +217,13 @@ function subscribeToSnapshot(environment, state, setState) {
210
217
  name: 'useFragment.subscription.missedUpdates',
211
218
  hasDataChanges: dataChanged
212
219
  });
220
+ hasPendingStateChanges.current = dataChanged;
213
221
  return dataChanged ? nextState : prevState;
214
222
  } else {
215
223
  return prevState;
216
224
  }
217
225
  }
226
+ hasPendingStateChanges.current = true;
218
227
  return {
219
228
  kind: 'singular',
220
229
  snapshot: latestSnapshot,
@@ -239,6 +248,7 @@ function subscribeToSnapshot(environment, state, setState) {
239
248
  name: 'useFragment.subscription.missedUpdates',
240
249
  hasDataChanges: dataChanged
241
250
  });
251
+ hasPendingStateChanges.current = hasPendingStateChanges.current || dataChanged;
242
252
  return dataChanged ? nextState : prevState;
243
253
  } else {
244
254
  return prevState;
@@ -246,6 +256,7 @@ function subscribeToSnapshot(environment, state, setState) {
246
256
  }
247
257
  var updated = (0, _toConsumableArray2["default"])(prevState.snapshots);
248
258
  updated[index] = latestSnapshot;
259
+ hasPendingStateChanges.current = true;
249
260
  return {
250
261
  kind: 'plural',
251
262
  snapshots: updated,
@@ -291,7 +302,7 @@ function getFragmentState(environment, fragmentSelector) {
291
302
  };
292
303
  }
293
304
  }
294
- function useFragmentInternal_EXPERIMENTAL(fragmentNode, fragmentRef, hookDisplayName, queryOptions) {
305
+ function useFragmentInternal(fragmentNode, fragmentRef, hookDisplayName, queryOptions) {
295
306
  var _fragmentNode$metadat, _fragmentNode$metadat2;
296
307
  var fragmentSelector = useMemo(function () {
297
308
  return getSelector(fragmentNode, fragmentRef);
@@ -334,26 +345,38 @@ function useFragmentInternal_EXPERIMENTAL(fragmentNode, fragmentRef, hookDisplay
334
345
  committedFragmentSelectorRef.current = fragmentSelector;
335
346
  }, [fragmentSelector]);
336
347
  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));
348
+ var _useMemo = useMemo(function () {
349
+ var missingClientEdges = getMissingClientEdges(state);
350
+ var clientEdgeQueries;
351
+ var activeRequestPromises = [];
352
+ if (missingClientEdges !== null && missingClientEdges !== void 0 && missingClientEdges.length) {
353
+ clientEdgeQueries = [];
354
+ var _iterator7 = (0, _createForOfIteratorHelper2["default"])(missingClientEdges),
355
+ _step7;
356
+ try {
357
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
358
+ var edge = _step7.value;
359
+ var _handleMissingClientE = handleMissingClientEdge(environment, fragmentNode, fragmentRef, edge, queryOptions),
360
+ queryResult = _handleMissingClientE[0],
361
+ requestPromise = _handleMissingClientE[1];
362
+ clientEdgeQueries.push(queryResult);
363
+ if (requestPromise != null) {
364
+ activeRequestPromises.push(requestPromise);
365
+ }
366
+ }
367
+ } catch (err) {
368
+ _iterator7.e(err);
369
+ } finally {
370
+ _iterator7.f();
348
371
  }
349
- } catch (err) {
350
- _iterator7.e(err);
351
- } finally {
352
- _iterator7.f();
353
372
  }
354
- }
355
- return clientEdgeQueries;
356
- }, [state, environment, fragmentNode, fragmentRef, queryOptions]);
373
+ return [clientEdgeQueries, activeRequestPromises];
374
+ }, [state, environment, fragmentNode, fragmentRef, queryOptions]),
375
+ clientEdgeQueries = _useMemo[0],
376
+ activeRequestPromises = _useMemo[1];
377
+ if (activeRequestPromises.length) {
378
+ throw Promise.all(activeRequestPromises);
379
+ }
357
380
  useEffect(function () {
358
381
  var QueryResource = getQueryResourceForEnvironment(environment);
359
382
  if (clientEdgeQueries !== null && clientEdgeQueries !== void 0 && clientEdgeQueries.length) {
@@ -395,7 +418,7 @@ function useFragmentInternal_EXPERIMENTAL(fragmentNode, fragmentRef, hookDisplay
395
418
  return environment.getStore().getLiveResolverPromise(liveStateID);
396
419
  }));
397
420
  }
398
- if (!committedFragmentSelectorRef.current || !areEqualSelectors(committedFragmentSelectorRef.current, fragmentSelector)) {
421
+ if (RelayFeatureFlags.ENABLE_RELAY_OPERATION_TRACKER_SUSPENSE || environment !== previousEnvironment || !committedFragmentSelectorRef.current || !areEqualSelectors(committedFragmentSelectorRef.current, fragmentSelector)) {
399
422
  !(fragmentSelector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'refinement, see invariants above') : invariant(false) : void 0;
400
423
  var fragmentOwner = fragmentSelector.kind === 'PluralReaderSelector' ? fragmentSelector.selectors[0].owner : fragmentSelector.owner;
401
424
  var pendingOperationsResult = getPendingOperationsForFragment(environment, fragmentNode, fragmentOwner);
@@ -405,6 +428,7 @@ function useFragmentInternal_EXPERIMENTAL(fragmentNode, fragmentRef, hookDisplay
405
428
  }
406
429
  }
407
430
  handlePotentialSnapshotErrorsForState(environment, state);
431
+ var hasPendingStateChanges = useRef(false);
408
432
  useEffect(function () {
409
433
  var currentState = subscribedState;
410
434
  var updates = handleMissedUpdates(environment, subscribedState);
@@ -416,8 +440,20 @@ function useFragmentInternal_EXPERIMENTAL(fragmentNode, fragmentRef, hookDisplay
416
440
  }
417
441
  currentState = updatedState;
418
442
  }
419
- return subscribeToSnapshot(environment, currentState, setState);
443
+ return subscribeToSnapshot(environment, currentState, setState, hasPendingStateChanges);
420
444
  }, [environment, subscribedState]);
445
+ if (hasPendingStateChanges.current) {
446
+ var updates = handleMissedUpdates(environment, state);
447
+ if (updates != null) {
448
+ var hasStateUpdates = updates[0],
449
+ updatedState = updates[1];
450
+ if (hasStateUpdates) {
451
+ setState(updatedState);
452
+ state = updatedState;
453
+ }
454
+ }
455
+ hasPendingStateChanges.current = false;
456
+ }
421
457
  var data;
422
458
  if (isPlural) {
423
459
  var fragmentRefIsNullish = fragmentRef == null;
@@ -452,4 +488,4 @@ function useFragmentInternal_EXPERIMENTAL(fragmentNode, fragmentRef, hookDisplay
452
488
  }
453
489
  return data;
454
490
  }
455
- module.exports = useFragmentInternal_EXPERIMENTAL;
491
+ module.exports = useFragmentInternal;
@@ -1,12 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var HooksImplementation = require('./HooksImplementation');
4
3
  var ProfilerContext = require('./ProfilerContext');
5
4
  var _require = require('./QueryResource'),
6
5
  getQueryCacheIdentifier = _require.getQueryCacheIdentifier,
7
6
  getQueryResourceForEnvironment = _require.getQueryResourceForEnvironment;
8
7
  var useFetchTrackingRef = require('./useFetchTrackingRef');
9
- var useFragmentNode = require('./useFragmentNode');
8
+ var useFragmentInternal = require('./useFragmentInternal');
10
9
  var useRelayEnvironment = require('./useRelayEnvironment');
11
10
  var React = require('react');
12
11
  var useContext = React.useContext,
@@ -62,17 +61,7 @@ function useLazyLoadQueryNode(_ref) {
62
61
  });
63
62
  var fragmentNode = preparedQueryResult.fragmentNode,
64
63
  fragmentRef = preparedQueryResult.fragmentRef;
65
- var data = useFragmentNodeImpl(fragmentNode, fragmentRef, componentDisplayName);
64
+ var data = useFragmentInternal(fragmentNode, fragmentRef, componentDisplayName);
66
65
  return data;
67
66
  }
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
- }
78
67
  module.exports = useLazyLoadQueryNode;
@@ -2,9 +2,9 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
5
- var HooksImplementation = require('./HooksImplementation');
6
5
  var useLoadMoreFunction = require('./useLoadMoreFunction');
7
- var useRefetchableFragmentNode = require('./useRefetchableFragmentNode');
6
+ var useRefetchableFragmentInternal = require('./useRefetchableFragmentInternal');
7
+ var useRelayEnvironment = require('./useRelayEnvironment');
8
8
  var useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
9
9
  var _require = require('react'),
10
10
  useCallback = _require.useCallback,
@@ -14,7 +14,7 @@ var _require2 = require('relay-runtime'),
14
14
  getFragment = _require2.getFragment,
15
15
  getFragmentIdentifier = _require2.getFragmentIdentifier,
16
16
  getPaginationMetadata = _require2.getPaginationMetadata;
17
- function usePaginationFragment_LEGACY(fragmentInput, parentFragmentRef) {
17
+ function usePaginationFragment(fragmentInput, parentFragmentRef) {
18
18
  var fragmentNode = getFragment(fragmentInput);
19
19
  useStaticFragmentNodeWarning(fragmentNode, 'first argument of usePaginationFragment()');
20
20
  var componentDisplayName = 'usePaginationFragment()';
@@ -22,7 +22,7 @@ function usePaginationFragment_LEGACY(fragmentInput, parentFragmentRef) {
22
22
  connectionPathInFragmentData = _getPaginationMetadat.connectionPathInFragmentData,
23
23
  paginationRequest = _getPaginationMetadat.paginationRequest,
24
24
  paginationMetadata = _getPaginationMetadat.paginationMetadata;
25
- var _useRefetchableFragme = useRefetchableFragmentNode(fragmentNode, parentFragmentRef, componentDisplayName),
25
+ var _useRefetchableFragme = useRefetchableFragmentInternal(fragmentNode, parentFragmentRef, componentDisplayName),
26
26
  fragmentData = _useRefetchableFragme.fragmentData,
27
27
  fragmentRef = _useRefetchableFragme.fragmentRef,
28
28
  refetch = _useRefetchableFragme.refetch;
@@ -86,9 +86,21 @@ function usePaginationFragment_LEGACY(fragmentInput, parentFragmentRef) {
86
86
  };
87
87
  }
88
88
  function useLoadMore(args) {
89
+ var environment = useRelayEnvironment();
89
90
  var _useState = useState(false),
90
91
  isLoadingMore = _useState[0],
91
- setIsLoadingMore = _useState[1];
92
+ reallySetIsLoadingMore = _useState[1];
93
+ var setIsLoadingMore = function setIsLoadingMore(value) {
94
+ var _environment$getSched;
95
+ var schedule = (_environment$getSched = environment.getScheduler()) === null || _environment$getSched === void 0 ? void 0 : _environment$getSched.schedule;
96
+ if (schedule) {
97
+ schedule(function () {
98
+ reallySetIsLoadingMore(value);
99
+ });
100
+ } else {
101
+ reallySetIsLoadingMore(value);
102
+ }
103
+ };
92
104
  var observer = {
93
105
  start: function start() {
94
106
  return setIsLoadingMore(true);
@@ -112,12 +124,4 @@ function useLoadMore(args) {
112
124
  disposeFetch = _useLoadMoreFunction[2];
113
125
  return [loadMore, hasMore, isLoadingMore, disposeFetch];
114
126
  }
115
- function usePaginationFragment(fragmentInput, parentFragmentRef) {
116
- var impl = HooksImplementation.get();
117
- if (impl) {
118
- return impl.usePaginationFragment(fragmentInput, parentFragmentRef);
119
- } else {
120
- return usePaginationFragment_LEGACY(fragmentInput, parentFragmentRef);
121
- }
122
- }
123
127
  module.exports = usePaginationFragment;
@@ -1,16 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var HooksImplementation = require('./HooksImplementation');
4
- var useRefetchableFragmentNode = require('./useRefetchableFragmentNode');
3
+ var useRefetchableFragmentInternal = require('./useRefetchableFragmentInternal');
5
4
  var useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
6
5
  var _require = require('react'),
7
6
  useDebugValue = _require.useDebugValue;
8
7
  var _require2 = require('relay-runtime'),
9
8
  getFragment = _require2.getFragment;
10
- function useRefetchableFragment_LEGACY(fragmentInput, fragmentRef) {
9
+ function useRefetchableFragment(fragmentInput, fragmentRef) {
11
10
  var fragmentNode = getFragment(fragmentInput);
12
11
  useStaticFragmentNodeWarning(fragmentNode, 'first argument of useRefetchableFragment()');
13
- var _useRefetchableFragme = useRefetchableFragmentNode(fragmentNode, fragmentRef, 'useRefetchableFragment()'),
12
+ var _useRefetchableFragme = useRefetchableFragmentInternal(fragmentNode, fragmentRef, 'useRefetchableFragment()'),
14
13
  fragmentData = _useRefetchableFragme.fragmentData,
15
14
  refetch = _useRefetchableFragme.refetch;
16
15
  if (process.env.NODE_ENV !== "production") {
@@ -21,12 +20,4 @@ function useRefetchableFragment_LEGACY(fragmentInput, fragmentRef) {
21
20
  }
22
21
  return [fragmentData, refetch];
23
22
  }
24
- function useRefetchableFragment(fragmentInput, parentFragmentRef) {
25
- var impl = HooksImplementation.get();
26
- if (impl) {
27
- return impl.useRefetchableFragment(fragmentInput, parentFragmentRef);
28
- } else {
29
- return useRefetchableFragment_LEGACY(fragmentInput, parentFragmentRef);
30
- }
31
- }
32
23
  module.exports = useRefetchableFragment;
@@ -2,14 +2,14 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
5
- var ProfilerContext = require('../ProfilerContext');
6
- var _require = require('../QueryResource'),
5
+ var ProfilerContext = require('./ProfilerContext');
6
+ var _require = require('./QueryResource'),
7
7
  getQueryResourceForEnvironment = _require.getQueryResourceForEnvironment;
8
- var useIsMountedRef = require('../useIsMountedRef');
9
- var useQueryLoader = require('../useQueryLoader');
10
- var useRelayEnvironment = require('../useRelayEnvironment');
11
- var readFragmentInternal = require('./readFragmentInternal_EXPERIMENTAL');
12
- var useFragmentInternal = require('./useFragmentInternal_EXPERIMENTAL');
8
+ var readFragmentInternal = require('./readFragmentInternal');
9
+ var useFragmentInternal = require('./useFragmentInternal');
10
+ var useIsMountedRef = require('./useIsMountedRef');
11
+ var useQueryLoader = require('./useQueryLoader');
12
+ var useRelayEnvironment = require('./useRelayEnvironment');
13
13
  var invariant = require('invariant');
14
14
  var _require2 = require('react'),
15
15
  useCallback = _require2.useCallback,
@@ -20,7 +20,7 @@ const ReactRelayContext = require('./../ReactRelayContext');
20
20
  const invariant = require('invariant');
21
21
  const {useContext} = require('react');
22
22
 
23
- function useRelayActorEnvironment(
23
+ hook useRelayActorEnvironment(
24
24
  actorIdentifier: ActorIdentifier,
25
25
  ): IActorEnvironment {
26
26
  const context = useContext(ReactRelayContext);
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.1.0",
4
+ "version": "17.0.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.1.0"
23
+ "relay-runtime": "17.0.0"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": "^16.9.0 || ^17 || ^18"