react-relay 12.0.0 → 13.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +47 -0
  3. package/ReactRelayContainerUtils.js.flow +1 -1
  4. package/ReactRelayContext.js +2 -2
  5. package/ReactRelayContext.js.flow +3 -4
  6. package/ReactRelayFragmentContainer.js.flow +11 -17
  7. package/ReactRelayFragmentMockRenderer.js.flow +2 -2
  8. package/ReactRelayLocalQueryRenderer.js.flow +7 -8
  9. package/ReactRelayPaginationContainer.js.flow +30 -40
  10. package/ReactRelayQueryFetcher.js.flow +10 -11
  11. package/ReactRelayQueryRenderer.js.flow +16 -16
  12. package/ReactRelayQueryRendererContext.js.flow +1 -1
  13. package/ReactRelayRefetchContainer.js.flow +25 -33
  14. package/ReactRelayTestMocker.js.flow +17 -15
  15. package/ReactRelayTypes.js.flow +11 -11
  16. package/RelayContext.js.flow +4 -4
  17. package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +2 -3
  18. package/__flowtests__/ReactRelayPaginationContainer-flowtest.js.flow +2 -3
  19. package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +2 -3
  20. package/__flowtests__/RelayModern-flowtest.js.flow +79 -47
  21. package/__flowtests__/RelayModernFlowtest_badref.graphql.js.flow +6 -5
  22. package/__flowtests__/RelayModernFlowtest_notref.graphql.js.flow +6 -5
  23. package/__flowtests__/RelayModernFlowtest_user.graphql.js.flow +5 -4
  24. package/__flowtests__/RelayModernFlowtest_users.graphql.js.flow +5 -4
  25. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer.graphql.js.flow +14 -11
  26. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer2.graphql.js.flow +14 -11
  27. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtestQuery.graphql.js.flow +14 -9
  28. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtest_viewer.graphql.js.flow +14 -11
  29. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtestQuery.graphql.js.flow +14 -9
  30. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtest_viewer.graphql.js.flow +14 -11
  31. package/__flowtests__/__generated__/RelayModernFlowtest_badref.graphql.js.flow +16 -13
  32. package/__flowtests__/__generated__/RelayModernFlowtest_notref.graphql.js.flow +16 -13
  33. package/__flowtests__/__generated__/RelayModernFlowtest_user.graphql.js.flow +14 -11
  34. package/__flowtests__/__generated__/RelayModernFlowtest_users.graphql.js.flow +14 -11
  35. package/assertFragmentMap.js.flow +3 -3
  36. package/buildReactRelayContainer.js.flow +12 -11
  37. package/getRootVariablesForFragments.js.flow +3 -5
  38. package/hooks.js +2 -2
  39. package/hooks.js.flow +4 -6
  40. package/index.js +2 -2
  41. package/index.js.flow +5 -7
  42. package/isRelayEnvironment.js.flow +1 -1
  43. package/jest-react/enqueueTask.js.flow +2 -2
  44. package/jest-react/index.js.flow +1 -1
  45. package/jest-react/internalAct.js.flow +2 -4
  46. package/legacy.js +2 -2
  47. package/legacy.js.flow +1 -1
  48. package/lib/ReactRelayContainerUtils.js +1 -1
  49. package/lib/ReactRelayContext.js +1 -1
  50. package/lib/ReactRelayFragmentContainer.js +5 -5
  51. package/lib/ReactRelayFragmentMockRenderer.js +3 -3
  52. package/lib/ReactRelayLocalQueryRenderer.js +8 -9
  53. package/lib/ReactRelayPaginationContainer.js +19 -23
  54. package/lib/ReactRelayQueryFetcher.js +3 -3
  55. package/lib/ReactRelayQueryRenderer.js +5 -5
  56. package/lib/ReactRelayQueryRendererContext.js +1 -1
  57. package/lib/ReactRelayRefetchContainer.js +13 -15
  58. package/lib/ReactRelayTestMocker.js +8 -9
  59. package/lib/ReactRelayTypes.js +1 -1
  60. package/lib/RelayContext.js +4 -3
  61. package/lib/assertFragmentMap.js +3 -2
  62. package/lib/buildReactRelayContainer.js +8 -8
  63. package/lib/getRootVariablesForFragments.js +2 -3
  64. package/lib/hooks.js +6 -6
  65. package/lib/index.js +8 -8
  66. package/lib/isRelayEnvironment.js +1 -1
  67. package/lib/jest-react/enqueueTask.js +1 -1
  68. package/lib/jest-react/internalAct.js +3 -4
  69. package/lib/legacy.js +1 -1
  70. package/lib/multi-actor/ActorChange.js +3 -3
  71. package/lib/multi-actor/index.js +1 -1
  72. package/lib/multi-actor/useRelayActorEnvironment.js +3 -3
  73. package/lib/readContext.js +1 -1
  74. package/lib/relay-hooks/EntryPointContainer.react.js +4 -4
  75. package/lib/relay-hooks/EntryPointTypes.flow.js +1 -1
  76. package/lib/relay-hooks/FragmentResource.js +242 -46
  77. package/lib/relay-hooks/InternalLogger.js +1 -1
  78. package/lib/relay-hooks/LRUCache.js +1 -1
  79. package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +5 -5
  80. package/lib/relay-hooks/MatchContainer.js +2 -2
  81. package/lib/relay-hooks/ProfilerContext.js +1 -1
  82. package/lib/relay-hooks/QueryResource.js +84 -5
  83. package/lib/relay-hooks/RelayEnvironmentProvider.js +1 -1
  84. package/lib/relay-hooks/SuspenseResource.js +130 -0
  85. package/lib/relay-hooks/loadEntryPoint.js +1 -1
  86. package/lib/relay-hooks/loadQuery.js +9 -10
  87. package/lib/relay-hooks/preloadQuery_DEPRECATED.js +25 -11
  88. package/lib/relay-hooks/prepareEntryPoint_DEPRECATED.js +1 -1
  89. package/lib/relay-hooks/useBlockingPaginationFragment.js +3 -3
  90. package/lib/relay-hooks/useEntryPointLoader.js +3 -3
  91. package/lib/relay-hooks/useFetchTrackingRef.js +3 -2
  92. package/lib/relay-hooks/useFragment.js +7 -7
  93. package/lib/relay-hooks/useFragmentNode.js +5 -5
  94. package/lib/relay-hooks/useIsMountedRef.js +1 -1
  95. package/lib/relay-hooks/useIsOperationNodeActive.js +3 -3
  96. package/lib/relay-hooks/useIsParentQueryActive.js +1 -1
  97. package/lib/relay-hooks/useLazyLoadQuery.js +4 -4
  98. package/lib/relay-hooks/useLazyLoadQueryNode.js +5 -5
  99. package/lib/relay-hooks/useLoadMoreFunction.js +8 -10
  100. package/lib/relay-hooks/useMemoOperationDescriptor.js +3 -3
  101. package/lib/relay-hooks/useMemoVariables.js +3 -3
  102. package/lib/relay-hooks/useMutation.js +18 -7
  103. package/lib/relay-hooks/usePaginationFragment.js +1 -1
  104. package/lib/relay-hooks/usePreloadedQuery.js +6 -6
  105. package/lib/relay-hooks/useQueryLoader.js +5 -5
  106. package/lib/relay-hooks/useRefetchableFragment.js +1 -1
  107. package/lib/relay-hooks/useRefetchableFragmentNode.js +11 -13
  108. package/lib/relay-hooks/useRelayEnvironment.js +3 -3
  109. package/lib/relay-hooks/useStaticFragmentNodeWarning.js +3 -3
  110. package/lib/relay-hooks/useSubscribeToInvalidationState.js +3 -2
  111. package/lib/relay-hooks/useSubscription.js +1 -1
  112. package/multi-actor/ActorChange.js.flow +4 -5
  113. package/multi-actor/index.js.flow +1 -1
  114. package/multi-actor/useRelayActorEnvironment.js.flow +6 -8
  115. package/package.json +3 -3
  116. package/react-relay-hooks.js +2 -2
  117. package/react-relay-hooks.min.js +3 -3
  118. package/react-relay-legacy.js +2 -2
  119. package/react-relay-legacy.min.js +3 -3
  120. package/react-relay.js +2 -2
  121. package/react-relay.min.js +3 -3
  122. package/readContext.js.flow +1 -1
  123. package/relay-hooks/EntryPointContainer.react.js.flow +9 -16
  124. package/relay-hooks/EntryPointTypes.flow.js.flow +19 -25
  125. package/relay-hooks/FragmentResource.js.flow +221 -35
  126. package/relay-hooks/InternalLogger.js.flow +1 -1
  127. package/relay-hooks/LRUCache.js.flow +1 -1
  128. package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +33 -47
  129. package/relay-hooks/MatchContainer.js.flow +4 -3
  130. package/relay-hooks/ProfilerContext.js.flow +1 -1
  131. package/relay-hooks/QueryResource.js.flow +120 -18
  132. package/relay-hooks/RelayEnvironmentProvider.js.flow +10 -10
  133. package/relay-hooks/SuspenseResource.js.flow +115 -0
  134. package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +5 -4
  135. package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +2 -2
  136. package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_user.graphql.js.flow +59 -0
  137. package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_users.graphql.js.flow +61 -0
  138. package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +11 -10
  139. package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +55 -32
  140. package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +11 -10
  141. package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +11 -10
  142. package/relay-hooks/__flowtests__/utils.js.flow +21 -32
  143. package/relay-hooks/loadEntryPoint.js.flow +7 -13
  144. package/relay-hooks/loadQuery.js.flow +23 -24
  145. package/relay-hooks/preloadQuery_DEPRECATED.js.flow +30 -14
  146. package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +7 -13
  147. package/relay-hooks/useBlockingPaginationFragment.js.flow +13 -14
  148. package/relay-hooks/useEntryPointLoader.js.flow +8 -11
  149. package/relay-hooks/useFetchTrackingRef.js.flow +3 -3
  150. package/relay-hooks/useFragment.js.flow +31 -62
  151. package/relay-hooks/useFragmentNode.js.flow +6 -8
  152. package/relay-hooks/useIsMountedRef.js.flow +1 -1
  153. package/relay-hooks/useIsOperationNodeActive.js.flow +4 -6
  154. package/relay-hooks/useIsParentQueryActive.js.flow +4 -5
  155. package/relay-hooks/useLazyLoadQuery.js.flow +14 -16
  156. package/relay-hooks/useLazyLoadQueryNode.js.flow +12 -14
  157. package/relay-hooks/useLoadMoreFunction.js.flow +20 -28
  158. package/relay-hooks/useMemoOperationDescriptor.js.flow +6 -8
  159. package/relay-hooks/useMemoVariables.js.flow +7 -7
  160. package/relay-hooks/useMutation.js.flow +27 -27
  161. package/relay-hooks/usePaginationFragment.js.flow +38 -47
  162. package/relay-hooks/usePreloadedQuery.js.flow +14 -20
  163. package/relay-hooks/useQueryLoader.js.flow +14 -17
  164. package/relay-hooks/useRefetchableFragment.js.flow +8 -9
  165. package/relay-hooks/useRefetchableFragmentNode.js.flow +23 -31
  166. package/relay-hooks/useRelayEnvironment.js.flow +3 -5
  167. package/relay-hooks/useStaticFragmentNodeWarning.js.flow +3 -4
  168. package/relay-hooks/useSubscribeToInvalidationState.js.flow +4 -7
  169. package/relay-hooks/useSubscription.js.flow +7 -8
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ * @emails oncall+relay
9
+ * @format
10
+ */
11
+ // flowlint ambiguous-object-type:error
12
+ 'use strict';
13
+
14
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
15
+
16
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
+
18
+ var invariant = require('invariant');
19
+
20
+ var TEMPORARY_RETAIN_DURATION_MS = 5 * 60 * 1000;
21
+ /**
22
+ * Allows you to retain a resource as part of a component lifecycle accounting
23
+ * for Suspense. You temporarily retain the resource during render, then
24
+ * permanently retain it during commit and release it during unmount.
25
+ */
26
+
27
+ var SuspenseResource = /*#__PURE__*/function () {
28
+ function SuspenseResource(retain) {
29
+ var _this = this;
30
+
31
+ (0, _defineProperty2["default"])(this, "_retainCount", 0);
32
+ (0, _defineProperty2["default"])(this, "_retainDisposable", null);
33
+ (0, _defineProperty2["default"])(this, "_releaseTemporaryRetain", null);
34
+
35
+ this._retain = function (environment) {
36
+ _this._retainCount++;
37
+
38
+ if (_this._retainCount === 1) {
39
+ _this._retainDisposable = retain(environment);
40
+ }
41
+
42
+ return {
43
+ dispose: function dispose() {
44
+ _this._retainCount = Math.max(0, _this._retainCount - 1);
45
+
46
+ if (_this._retainCount === 0) {
47
+ !(_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;
48
+
49
+ _this._retainDisposable.dispose();
50
+
51
+ _this._retainDisposable = null;
52
+ }
53
+ }
54
+ };
55
+ };
56
+ }
57
+
58
+ var _proto = SuspenseResource.prototype;
59
+
60
+ _proto.temporaryRetain = function temporaryRetain(environment) {
61
+ var _this2 = this;
62
+
63
+ var _this$_releaseTempora;
64
+
65
+ // If we're executing in a server environment, there's no need
66
+ // to create temporary retains, since the component will never commit.
67
+ if (environment.isServer()) {
68
+ return {
69
+ dispose: function dispose() {}
70
+ };
71
+ } // temporaryRetain is called during the render phase. However,
72
+ // given that we can't tell if this render will eventually commit or not,
73
+ // we create a timer to autodispose of this retain in case the associated
74
+ // component never commits.
75
+ // If the component /does/ commit, permanentRetain will clear this timeout
76
+ // and permanently retain the data.
77
+
78
+
79
+ var retention = this._retain(environment);
80
+
81
+ var releaseQueryTimeout = null;
82
+
83
+ var releaseTemporaryRetain = function releaseTemporaryRetain() {
84
+ clearTimeout(releaseQueryTimeout);
85
+ releaseQueryTimeout = null;
86
+ _this2._releaseTemporaryRetain = null;
87
+ retention.dispose();
88
+ };
89
+
90
+ releaseQueryTimeout = setTimeout(releaseTemporaryRetain, TEMPORARY_RETAIN_DURATION_MS); // NOTE: Since temporaryRetain can be called multiple times, we release
91
+ // the previous temporary retain after we re-establish a new one, since
92
+ // we only ever need a single temporary retain until the permanent retain is
93
+ // established.
94
+ // temporaryRetain may be called multiple times by React during the render
95
+ // phase, as well as multiple times by other query components that are
96
+ // rendering the same query/variables.
97
+
98
+ (_this$_releaseTempora = this._releaseTemporaryRetain) === null || _this$_releaseTempora === void 0 ? void 0 : _this$_releaseTempora.call(this);
99
+ this._releaseTemporaryRetain = releaseTemporaryRetain;
100
+ return {
101
+ dispose: function dispose() {
102
+ var _this$_releaseTempora2;
103
+
104
+ (_this$_releaseTempora2 = _this2._releaseTemporaryRetain) === null || _this$_releaseTempora2 === void 0 ? void 0 : _this$_releaseTempora2.call(_this2);
105
+ }
106
+ };
107
+ };
108
+
109
+ _proto.permanentRetain = function permanentRetain(environment) {
110
+ var disposable = this._retain(environment);
111
+
112
+ this.releaseTemporaryRetain();
113
+ return disposable;
114
+ };
115
+
116
+ _proto.releaseTemporaryRetain = function releaseTemporaryRetain() {
117
+ var _this$_releaseTempora3;
118
+
119
+ (_this$_releaseTempora3 = this._releaseTemporaryRetain) === null || _this$_releaseTempora3 === void 0 ? void 0 : _this$_releaseTempora3.call(this);
120
+ this._releaseTemporaryRetain = null;
121
+ };
122
+
123
+ _proto.getRetainCount = function getRetainCount() {
124
+ return this._retainCount;
125
+ };
126
+
127
+ return SuspenseResource;
128
+ }();
129
+
130
+ module.exports = SuspenseResource;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -14,21 +14,21 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
14
14
 
15
15
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
16
16
 
17
- var React = require('react');
18
-
19
17
  var invariant = require('invariant');
20
18
 
21
- var warning = require("fbjs/lib/warning");
19
+ var React = require('react');
22
20
 
23
21
  var _require = require('relay-runtime'),
22
+ Observable = _require.Observable,
24
23
  PreloadableQueryRegistry = _require.PreloadableQueryRegistry,
24
+ RelayFeatureFlags = _require.RelayFeatureFlags,
25
25
  ReplaySubject = _require.ReplaySubject,
26
+ fetchQueryDeduped = _require.__internal.fetchQueryDeduped,
26
27
  createOperationDescriptor = _require.createOperationDescriptor,
27
28
  getRequest = _require.getRequest,
28
- getRequestIdentifier = _require.getRequestIdentifier,
29
- Observable = _require.Observable,
30
- RelayFeatureFlags = _require.RelayFeatureFlags,
31
- fetchQueryDeduped = _require.__internal.fetchQueryDeduped;
29
+ getRequestIdentifier = _require.getRequestIdentifier;
30
+
31
+ var warning = require("fbjs/lib/warning");
32
32
 
33
33
  var RenderDispatcher = null;
34
34
  var fetchKey = 100001;
@@ -254,8 +254,7 @@ function loadQuery(environment, preloadableRequest, variables, options, environm
254
254
  // store in the first place, so it couldn't have been cached.
255
255
  var networkObservable = fetchPolicy === 'store-only' ? null : makeNetworkRequest(params); // $FlowFixMe[method-unbinding] added when improving typing for this parameters
256
256
 
257
- var _PreloadableQueryRegi = PreloadableQueryRegistry.onLoad( // $FlowFixMe[incompatible-call]
258
- queryId, function (preloadedModule) {
257
+ var _PreloadableQueryRegi = PreloadableQueryRegistry.onLoad(queryId, function (preloadedModule) {
259
258
  cancelOnLoadCallback();
260
259
  var operation = createOperationDescriptor(preloadedModule, variables, networkCacheConfig);
261
260
  retainReference = environment.retain(operation);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -16,14 +16,15 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
16
16
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
17
17
 
18
18
  var _require = require('relay-runtime'),
19
- createOperationDescriptor = _require.createOperationDescriptor,
20
- getRequest = _require.getRequest,
21
- getRequestIdentifier = _require.getRequestIdentifier,
22
19
  Observable = _require.Observable,
23
20
  PreloadableQueryRegistry = _require.PreloadableQueryRegistry,
24
- ReplaySubject = _require.ReplaySubject;
21
+ RelayFeatureFlags = _require.RelayFeatureFlags,
22
+ ReplaySubject = _require.ReplaySubject,
23
+ createOperationDescriptor = _require.createOperationDescriptor,
24
+ getRequest = _require.getRequest,
25
+ getRequestIdentifier = _require.getRequestIdentifier; // Expire results by this delay after they resolve.
26
+
25
27
 
26
- // Expire results by this delay after they resolve.
27
28
  var DEFAULT_PREFETCH_TIMEOUT = 30 * 1000; // 30 seconds
28
29
 
29
30
  var WEAKMAP_SUPPORTED = typeof WeakMap === 'function';
@@ -58,7 +59,22 @@ function preloadQuery(environment, preloadableRequest, variables, options, envir
58
59
  var _subscription;
59
60
 
60
61
  (_subscription = subscription) === null || _subscription === void 0 ? void 0 : _subscription.unsubscribe();
61
- cleanup(pendingQueries, queryEntry);
62
+
63
+ if (environment.isServer()) {
64
+ return;
65
+ }
66
+
67
+ if (RelayFeatureFlags.DELAY_CLEANUP_OF_PENDING_PRELOAD_QUERIES === true) {
68
+ setTimeout(function () {
69
+ // Clear the cache entry after the default timeout
70
+ // null-check for Flow
71
+ if (queryEntry != null) {
72
+ cleanup(pendingQueries, queryEntry);
73
+ }
74
+ }, DEFAULT_PREFETCH_TIMEOUT);
75
+ } else {
76
+ cleanup(pendingQueries, queryEntry);
77
+ }
62
78
  };
63
79
  }) : null;
64
80
  return {
@@ -173,11 +189,9 @@ function preloadQueryDeduped(environment, pendingQueries, preloadableRequest, va
173
189
  };
174
190
  } else {
175
191
  nextQueryEntry = prevQueryEntry;
176
- } // $FlowFixMe[incompatible-call]
177
-
178
-
179
- pendingQueries.set(cacheKey, nextQueryEntry); // $FlowFixMe[incompatible-return]
192
+ }
180
193
 
194
+ pendingQueries.set(cacheKey, nextQueryEntry);
181
195
  return nextQueryEntry;
182
196
  }
183
197
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -17,14 +17,14 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
17
17
 
18
18
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
19
19
 
20
- var invariant = require('invariant');
21
-
22
20
  var useLoadMoreFunction = require('./useLoadMoreFunction');
23
21
 
24
22
  var useRefetchableFragmentNode = require('./useRefetchableFragmentNode');
25
23
 
26
24
  var useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
27
25
 
26
+ var invariant = require('invariant');
27
+
28
28
  var _require = require('react'),
29
29
  useCallback = _require.useCallback,
30
30
  useEffect = _require.useEffect,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -17,11 +17,11 @@ var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime
17
17
 
18
18
  var loadEntryPoint = require('./loadEntryPoint');
19
19
 
20
- var useIsMountedRef = require('./useIsMountedRef');
21
-
22
20
  var _require = require('./loadQuery'),
23
21
  useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
24
22
 
23
+ var useIsMountedRef = require('./useIsMountedRef');
24
+
25
25
  var _require2 = require('react'),
26
26
  useCallback = _require2.useCallback,
27
27
  useEffect = _require2.useEffect,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -15,7 +15,6 @@ var _require = require('react'),
15
15
  useCallback = _require.useCallback,
16
16
  useEffect = _require.useEffect,
17
17
  useRef = _require.useRef;
18
-
19
18
  /**
20
19
  * This hook returns a mutable React ref that holds the value of whether a
21
20
  * fetch request is in flight. The reason this is a mutable ref instead of
@@ -28,6 +27,8 @@ var _require = require('react'),
28
27
  * The additional functions returned by this Hook can be used to mutate
29
28
  * the ref.
30
29
  */
30
+
31
+
31
32
  function useFetchTrackingRef() {
32
33
  var subscriptionRef = useRef(null);
33
34
  var isFetchingRef = useRef(false);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -11,27 +11,27 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
  'use strict';
13
13
 
14
+ var _require = require('./loadQuery'),
15
+ useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
16
+
14
17
  var useFragmentNode = require('./useFragmentNode');
15
18
 
16
19
  var useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
17
20
 
18
- var _require = require('./loadQuery'),
19
- useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
20
-
21
21
  var _require2 = require('react'),
22
22
  useDebugValue = _require2.useDebugValue;
23
23
 
24
24
  var _require3 = require('relay-runtime'),
25
25
  getFragment = _require3.getFragment;
26
26
 
27
- function useFragment(fragmentInput, fragmentRef) {
27
+ function useFragment(fragment, key) {
28
28
  // We need to use this hook in order to be able to track if
29
29
  // loadQuery was called during render
30
30
  useTrackLoadQueryInRender();
31
- var fragmentNode = getFragment(fragmentInput);
31
+ var fragmentNode = getFragment(fragment);
32
32
  useStaticFragmentNodeWarning(fragmentNode, 'first argument of useFragment()');
33
33
 
34
- var _useFragmentNode = useFragmentNode(fragmentNode, fragmentRef, 'useFragment()'),
34
+ var _useFragmentNode = useFragmentNode(fragmentNode, key, 'useFragment()'),
35
35
  data = _useFragmentNode.data;
36
36
 
37
37
  if (process.env.NODE_ENV !== "production") {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -11,13 +11,11 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
  'use strict';
13
13
 
14
- var useRelayEnvironment = require('./useRelayEnvironment');
15
-
16
- var warning = require("fbjs/lib/warning");
17
-
18
14
  var _require = require('./FragmentResource'),
19
15
  getFragmentResourceForEnvironment = _require.getFragmentResourceForEnvironment;
20
16
 
17
+ var useRelayEnvironment = require('./useRelayEnvironment');
18
+
21
19
  var _require2 = require('react'),
22
20
  useEffect = _require2.useEffect,
23
21
  useRef = _require2.useRef,
@@ -26,6 +24,8 @@ var _require2 = require('react'),
26
24
  var _require3 = require('relay-runtime'),
27
25
  getFragmentIdentifier = _require3.getFragmentIdentifier;
28
26
 
27
+ var warning = require("fbjs/lib/warning");
28
+
29
29
  function useFragmentNode(fragmentNode, fragmentRef, componentDisplayName) {
30
30
  var environment = useRelayEnvironment();
31
31
  var FragmentResource = getFragmentResourceForEnvironment(environment);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -10,11 +10,11 @@
10
10
  */
11
11
  'use strict';
12
12
 
13
- var React = require('react');
13
+ var useRelayEnvironment = require('./useRelayEnvironment');
14
14
 
15
15
  var invariant = require('invariant');
16
16
 
17
- var useRelayEnvironment = require('./useRelayEnvironment');
17
+ var React = require('react');
18
18
 
19
19
  var _require = require('relay-runtime'),
20
20
  getObservableForActiveRequest = _require.__internal.getObservableForActiveRequest,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -11,15 +11,15 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
  'use strict';
13
13
 
14
+ var _require = require('./loadQuery'),
15
+ useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
16
+
14
17
  var useLazyLoadQueryNode = require('./useLazyLoadQueryNode');
15
18
 
16
19
  var useMemoOperationDescriptor = require('./useMemoOperationDescriptor');
17
20
 
18
21
  var useRelayEnvironment = require('./useRelayEnvironment');
19
22
 
20
- var _require = require('./loadQuery'),
21
- useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
22
-
23
23
  var _require2 = require('relay-runtime'),
24
24
  fetchQuery = _require2.__internal.fetchQuery;
25
25
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -13,7 +13,9 @@
13
13
 
14
14
  var ProfilerContext = require('./ProfilerContext');
15
15
 
16
- var React = require('react');
16
+ var _require = require('./QueryResource'),
17
+ getQueryCacheIdentifier = _require.getQueryCacheIdentifier,
18
+ getQueryResourceForEnvironment = _require.getQueryResourceForEnvironment;
17
19
 
18
20
  var useFetchTrackingRef = require('./useFetchTrackingRef');
19
21
 
@@ -21,9 +23,7 @@ var useFragmentNode = require('./useFragmentNode');
21
23
 
22
24
  var useRelayEnvironment = require('./useRelayEnvironment');
23
25
 
24
- var _require = require('./QueryResource'),
25
- getQueryResourceForEnvironment = _require.getQueryResourceForEnvironment,
26
- getQueryCacheIdentifier = _require.getQueryCacheIdentifier;
26
+ var React = require('react');
27
27
 
28
28
  var useContext = React.useContext,
29
29
  useEffect = React.useEffect,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -15,8 +15,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
15
15
 
16
16
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
17
17
 
18
- var invariant = require('invariant');
19
-
20
18
  var useFetchTrackingRef = require('./useFetchTrackingRef');
21
19
 
22
20
  var useIsMountedRef = require('./useIsMountedRef');
@@ -25,7 +23,7 @@ var useIsOperationNodeActive = require('./useIsOperationNodeActive');
25
23
 
26
24
  var useRelayEnvironment = require('./useRelayEnvironment');
27
25
 
28
- var warning = require("fbjs/lib/warning");
26
+ var invariant = require('invariant');
29
27
 
30
28
  var _require = require('react'),
31
29
  useCallback = _require.useCallback,
@@ -37,8 +35,10 @@ var _require2 = require('relay-runtime'),
37
35
  fetchQuery = _require2.__internal.fetchQuery,
38
36
  createOperationDescriptor = _require2.createOperationDescriptor,
39
37
  getPaginationVariables = _require2.getPaginationVariables,
40
- getValueAtPath = _require2.getValueAtPath,
41
- getSelector = _require2.getSelector;
38
+ getSelector = _require2.getSelector,
39
+ getValueAtPath = _require2.getValueAtPath;
40
+
41
+ var warning = require("fbjs/lib/warning");
42
42
 
43
43
  function useLoadMoreFunction(args) {
44
44
  var direction = args.direction,
@@ -124,11 +124,9 @@ function useLoadMoreFunction(args) {
124
124
  !(fragmentSelector != null && fragmentSelector.kind !== 'PluralReaderSelector') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected to be able to find a non-plural fragment owner for ' + "fragment `%s` when using `%s`. If you're seeing this, " + 'this is likely a bug in Relay.', fragmentNode.name, componentDisplayName) : invariant(false) : void 0;
125
125
  var parentVariables = fragmentSelector.owner.variables;
126
126
  var fragmentVariables = fragmentSelector.variables;
127
- var extraVariables = options === null || options === void 0 ? void 0 : options.UNSTABLE_extraVariables; // $FlowFixMe[cannot-spread-interface]
128
-
127
+ var extraVariables = options === null || options === void 0 ? void 0 : options.UNSTABLE_extraVariables;
129
128
  var baseVariables = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, parentVariables), fragmentVariables);
130
- var paginationVariables = getPaginationVariables(direction, count, cursor, baseVariables, // $FlowFixMe[cannot-spread-interface]
131
- (0, _objectSpread2["default"])({}, extraVariables), paginationMetadata); // If the query needs an identifier value ('id' or similar) and one
129
+ var paginationVariables = getPaginationVariables(direction, count, cursor, baseVariables, (0, _objectSpread2["default"])({}, extraVariables), paginationMetadata); // If the query needs an identifier value ('id' or similar) and one
132
130
  // was not explicitly provided, read it from the fragment data.
133
131
 
134
132
  if (identifierField != null) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -11,10 +11,10 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
  'use strict';
13
13
 
14
- var React = require('react');
15
-
16
14
  var useMemoVariables = require('./useMemoVariables');
17
15
 
16
+ var React = require('react');
17
+
18
18
  var _require = require('relay-runtime'),
19
19
  createOperationDescriptor = _require.createOperationDescriptor,
20
20
  getRequest = _require.getRequest;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -11,10 +11,10 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
  'use strict';
13
13
 
14
- var React = require('react');
15
-
16
14
  var areEqual = require("fbjs/lib/areEqual");
17
15
 
16
+ var React = require('react');
17
+
18
18
  var useMemo = React.useMemo,
19
19
  useRef = React.useRef,
20
20
  useState = React.useState;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -15,10 +15,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
15
15
 
16
16
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
17
17
 
18
- var React = require('react');
18
+ var useIsMountedRef = require('./useIsMountedRef');
19
19
 
20
20
  var useRelayEnvironment = require('./useRelayEnvironment');
21
21
 
22
+ var React = require('react');
23
+
22
24
  var _require = require('relay-runtime'),
23
25
  defaultCommitMutation = _require.commitMutation;
24
26
 
@@ -27,8 +29,6 @@ var useState = React.useState,
27
29
  useRef = React.useRef,
28
30
  useCallback = React.useCallback;
29
31
 
30
- var useIsMountedRef = require('./useIsMountedRef');
31
-
32
32
  function useMutation(mutation) {
33
33
  var commitMutationFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultCommitMutation;
34
34
  var environment = useRelayEnvironment();
@@ -66,16 +66,27 @@ function useMutation(mutation) {
66
66
  var disposable = commitMutationFn(environment, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, config), {}, {
67
67
  mutation: mutation,
68
68
  onCompleted: function onCompleted(response, errors) {
69
+ var _config$onCompleted;
70
+
69
71
  cleanup(disposable);
70
- config.onCompleted && config.onCompleted(response, errors);
72
+ (_config$onCompleted = config.onCompleted) === null || _config$onCompleted === void 0 ? void 0 : _config$onCompleted.call(config, response, errors);
71
73
  },
72
74
  onError: function onError(error) {
75
+ var _config$onError;
76
+
73
77
  cleanup(disposable);
74
- config.onError && config.onError(error);
78
+ (_config$onError = config.onError) === null || _config$onError === void 0 ? void 0 : _config$onError.call(config, error);
75
79
  },
76
80
  onUnsubscribe: function onUnsubscribe() {
81
+ var _config$onUnsubscribe;
82
+
77
83
  cleanup(disposable);
78
- config.onUnsubscribe && config.onUnsubscribe();
84
+ (_config$onUnsubscribe = config.onUnsubscribe) === null || _config$onUnsubscribe === void 0 ? void 0 : _config$onUnsubscribe.call(config);
85
+ },
86
+ onNext: function onNext() {
87
+ var _config$onNext;
88
+
89
+ (_config$onNext = config.onNext) === null || _config$onNext === void 0 ? void 0 : _config$onNext.call(config);
79
90
  }
80
91
  }));
81
92
  inFlightMutationsRef.current.add(disposable);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.