@apollo/client 3.9.9 → 3.9.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/apollo-client.cjs +39 -18
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +8 -6
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +8 -6
- package/cache/inmemory/readFromStore.js +8 -6
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/core/core.cjs +1 -1
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +1 -1
- package/dev/dev.cjs +1 -1
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +1 -1
- package/package.json +16 -16
- package/react/hooks/hooks.cjs +17 -1
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +17 -1
- package/react/hooks/useBackgroundQuery.js +13 -0
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useReadQuery.js +10 -1
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +27 -0
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/internal/cache/QueryReference.js +9 -11
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/cache/SuspenseCache.d.ts +1 -0
- package/react/internal/cache/SuspenseCache.js +4 -0
- package/react/internal/cache/SuspenseCache.js.map +1 -1
- package/react/internal/internal.cjs +13 -10
- package/react/internal/internal.cjs.map +1 -1
- package/react/internal/internal.cjs.native.js +13 -10
- package/utilities/globals/globals.cjs +1 -1
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +1 -1
- package/version.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @apollo/client
|
|
2
2
|
|
|
3
|
+
## 3.9.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#11769](https://github.com/apollographql/apollo-client/pull/11769) [`04132af`](https://github.com/apollographql/apollo-client/commit/04132af121c9b48d6e03eb733b9b91f825defbac) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue where using `skipToken` or the `skip` option with `useSuspenseQuery` in React's strict mode would perform a network request.
|
|
8
|
+
|
|
9
|
+
## 3.9.10
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#11738](https://github.com/apollographql/apollo-client/pull/11738) [`b1a5eb8`](https://github.com/apollographql/apollo-client/commit/b1a5eb80cae8bdf2e9d8627f1eab65e088c43438) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue where rerendering `useBackgroundQuery` after the `queryRef` had been disposed, either via the auto dispose timeout or by unmounting `useReadQuery`, would cause the `queryRef` to be recreated potentially resulting in another network request.
|
|
14
|
+
|
|
15
|
+
- [#11738](https://github.com/apollographql/apollo-client/pull/11738) [`b1a5eb8`](https://github.com/apollographql/apollo-client/commit/b1a5eb80cae8bdf2e9d8627f1eab65e088c43438) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Allow queryRefs to be disposed of synchronously when a suspense hook unmounts. This prevents some situations where using a suspense hook with the same query/variables as the disposed queryRef accidentally used the disposed queryRef rather than creating a new instance.
|
|
16
|
+
|
|
17
|
+
- [#11670](https://github.com/apollographql/apollo-client/pull/11670) [`cc5c03b`](https://github.com/apollographql/apollo-client/commit/cc5c03b2690f452483d83eecb68611a23055d99e) Thanks [@phryneas](https://github.com/phryneas)! - Bail out of `executeSubSelectedArray` calls if the array has 0 elements.
|
|
18
|
+
|
|
3
19
|
## 3.9.9
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/apollo-client.cjs
CHANGED
|
@@ -31,7 +31,7 @@ function _interopNamespace(e) {
|
|
|
31
31
|
var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
|
|
32
32
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
33
33
|
|
|
34
|
-
var version = "3.9.
|
|
34
|
+
var version = "3.9.11";
|
|
35
35
|
|
|
36
36
|
function maybe(thunk) {
|
|
37
37
|
try {
|
|
@@ -3318,12 +3318,14 @@ var StoreReader = (function () {
|
|
|
3318
3318
|
}
|
|
3319
3319
|
}
|
|
3320
3320
|
else if (isArray(fieldValue)) {
|
|
3321
|
-
fieldValue
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3321
|
+
if (fieldValue.length > 0) {
|
|
3322
|
+
fieldValue = handleMissing(_this.executeSubSelectedArray({
|
|
3323
|
+
field: selection,
|
|
3324
|
+
array: fieldValue,
|
|
3325
|
+
enclosingRef: enclosingRef,
|
|
3326
|
+
context: context,
|
|
3327
|
+
}), resultName);
|
|
3328
|
+
}
|
|
3327
3329
|
}
|
|
3328
3330
|
else if (!selection.selectionSet) {
|
|
3329
3331
|
if (context.canonizeResults) {
|
|
@@ -8153,16 +8155,17 @@ var InternalQueryReference = (function () {
|
|
|
8153
8155
|
InternalQueryReference.prototype.reinitialize = function () {
|
|
8154
8156
|
var observable = this.observable;
|
|
8155
8157
|
var originalFetchPolicy = this.watchQueryOptions.fetchPolicy;
|
|
8158
|
+
var avoidNetworkRequests = originalFetchPolicy === "no-cache" || originalFetchPolicy === "standby";
|
|
8156
8159
|
try {
|
|
8157
|
-
if (
|
|
8158
|
-
observable.
|
|
8159
|
-
observable.silentSetOptions({ fetchPolicy: "cache-first" });
|
|
8160
|
+
if (avoidNetworkRequests) {
|
|
8161
|
+
observable.silentSetOptions({ fetchPolicy: "standby" });
|
|
8160
8162
|
}
|
|
8161
8163
|
else {
|
|
8162
|
-
observable.
|
|
8164
|
+
observable.resetLastResults();
|
|
8165
|
+
observable.silentSetOptions({ fetchPolicy: "cache-first" });
|
|
8163
8166
|
}
|
|
8164
8167
|
this.subscribeToQuery();
|
|
8165
|
-
if (
|
|
8168
|
+
if (avoidNetworkRequests) {
|
|
8166
8169
|
return;
|
|
8167
8170
|
}
|
|
8168
8171
|
observable.resetDiff();
|
|
@@ -8183,11 +8186,9 @@ var InternalQueryReference = (function () {
|
|
|
8183
8186
|
}
|
|
8184
8187
|
disposed = true;
|
|
8185
8188
|
_this.references--;
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
}
|
|
8190
|
-
});
|
|
8189
|
+
if (!_this.references) {
|
|
8190
|
+
_this.dispose();
|
|
8191
|
+
}
|
|
8191
8192
|
};
|
|
8192
8193
|
};
|
|
8193
8194
|
InternalQueryReference.prototype.softRetain = function () {
|
|
@@ -8355,6 +8356,10 @@ var SuspenseCache = (function () {
|
|
|
8355
8356
|
}
|
|
8356
8357
|
return ref.current;
|
|
8357
8358
|
};
|
|
8359
|
+
SuspenseCache.prototype.add = function (cacheKey, queryRef) {
|
|
8360
|
+
var ref = this.queryRefs.lookupArray(cacheKey);
|
|
8361
|
+
ref.current = queryRef;
|
|
8362
|
+
};
|
|
8358
8363
|
return SuspenseCache;
|
|
8359
8364
|
}());
|
|
8360
8365
|
|
|
@@ -8409,6 +8414,12 @@ function _useSuspenseQuery(query, options) {
|
|
|
8409
8414
|
dispose();
|
|
8410
8415
|
};
|
|
8411
8416
|
}, [queryRef]);
|
|
8417
|
+
React__namespace.useEffect(function () {
|
|
8418
|
+
if (queryRef.disposed) {
|
|
8419
|
+
suspenseCache.add(cacheKey, queryRef);
|
|
8420
|
+
queryRef.reinitialize();
|
|
8421
|
+
}
|
|
8422
|
+
});
|
|
8412
8423
|
var skipResult = React__namespace.useMemo(function () {
|
|
8413
8424
|
var error = toApolloError(queryRef.result);
|
|
8414
8425
|
return {
|
|
@@ -8516,6 +8527,11 @@ function _useBackgroundQuery(query, options) {
|
|
|
8516
8527
|
var promise = queryRef.applyOptions(watchQueryOptions);
|
|
8517
8528
|
updateWrappedQueryRef(wrappedQueryRef, promise);
|
|
8518
8529
|
}
|
|
8530
|
+
React__namespace.useEffect(function () {
|
|
8531
|
+
if (queryRef.disposed) {
|
|
8532
|
+
suspenseCache.add(cacheKey, queryRef);
|
|
8533
|
+
}
|
|
8534
|
+
});
|
|
8519
8535
|
var fetchMore = React__namespace.useCallback(function (options) {
|
|
8520
8536
|
var promise = queryRef.fetchMore(options);
|
|
8521
8537
|
setWrappedQueryRef(wrapQueryRef(queryRef));
|
|
@@ -8618,7 +8634,12 @@ function _useReadQuery(queryRef) {
|
|
|
8618
8634
|
internalQueryRef.reinitialize();
|
|
8619
8635
|
updateWrappedQueryRef(queryRef, internalQueryRef.promise);
|
|
8620
8636
|
}
|
|
8621
|
-
React__namespace.useEffect(function () {
|
|
8637
|
+
React__namespace.useEffect(function () {
|
|
8638
|
+
if (internalQueryRef.disposed) {
|
|
8639
|
+
internalQueryRef.reinitialize();
|
|
8640
|
+
}
|
|
8641
|
+
return internalQueryRef.retain();
|
|
8642
|
+
}, [internalQueryRef]);
|
|
8622
8643
|
var promise = useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
|
|
8623
8644
|
return internalQueryRef.listen(function (promise) {
|
|
8624
8645
|
updateWrappedQueryRef(queryRef, promise);
|