@apollo/client 3.9.8 → 3.9.10
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 +48 -9
- 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 +18 -1
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +18 -1
- package/react/hooks/useBackgroundQuery.js +14 -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.d.ts +2 -0
- package/react/internal/cache/QueryReference.js +20 -2
- 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 +21 -1
- package/react/internal/internal.cjs.map +1 -1
- package/react/internal/internal.cjs.native.js +21 -1
- 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.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#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.
|
|
8
|
+
|
|
9
|
+
- [#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.
|
|
10
|
+
|
|
11
|
+
- [#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.
|
|
12
|
+
|
|
13
|
+
## 3.9.9
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#11696](https://github.com/apollographql/apollo-client/pull/11696) [`466ef82`](https://github.com/apollographql/apollo-client/commit/466ef82198486fc696da64d17d82b46140760ac4) Thanks [@PiR1](https://github.com/PiR1)! - Immediately dispose of the `queryRef` if `useBackgroundQuery` unmounts before the auto dispose timeout kicks in.
|
|
18
|
+
|
|
3
19
|
## 3.9.8
|
|
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.10";
|
|
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) {
|
|
@@ -8118,6 +8120,7 @@ var InternalQueryReference = (function () {
|
|
|
8118
8120
|
this.key = {};
|
|
8119
8121
|
this.listeners = new Set();
|
|
8120
8122
|
this.references = 0;
|
|
8123
|
+
this.softReferences = 0;
|
|
8121
8124
|
this.handleNext = this.handleNext.bind(this);
|
|
8122
8125
|
this.handleError = this.handleError.bind(this);
|
|
8123
8126
|
this.dispose = this.dispose.bind(this);
|
|
@@ -8182,8 +8185,23 @@ var InternalQueryReference = (function () {
|
|
|
8182
8185
|
}
|
|
8183
8186
|
disposed = true;
|
|
8184
8187
|
_this.references--;
|
|
8188
|
+
if (!_this.references) {
|
|
8189
|
+
_this.dispose();
|
|
8190
|
+
}
|
|
8191
|
+
};
|
|
8192
|
+
};
|
|
8193
|
+
InternalQueryReference.prototype.softRetain = function () {
|
|
8194
|
+
var _this = this;
|
|
8195
|
+
this.softReferences++;
|
|
8196
|
+
var disposed = false;
|
|
8197
|
+
return function () {
|
|
8198
|
+
if (disposed) {
|
|
8199
|
+
return;
|
|
8200
|
+
}
|
|
8201
|
+
disposed = true;
|
|
8202
|
+
_this.softReferences--;
|
|
8185
8203
|
setTimeout(function () {
|
|
8186
|
-
if (!_this.references) {
|
|
8204
|
+
if (!_this.softReferences && !_this.references) {
|
|
8187
8205
|
_this.dispose();
|
|
8188
8206
|
}
|
|
8189
8207
|
});
|
|
@@ -8337,6 +8355,10 @@ var SuspenseCache = (function () {
|
|
|
8337
8355
|
}
|
|
8338
8356
|
return ref.current;
|
|
8339
8357
|
};
|
|
8358
|
+
SuspenseCache.prototype.add = function (cacheKey, queryRef) {
|
|
8359
|
+
var ref = this.queryRefs.lookupArray(cacheKey);
|
|
8360
|
+
ref.current = queryRef;
|
|
8361
|
+
};
|
|
8340
8362
|
return SuspenseCache;
|
|
8341
8363
|
}());
|
|
8342
8364
|
|
|
@@ -8391,6 +8413,12 @@ function _useSuspenseQuery(query, options) {
|
|
|
8391
8413
|
dispose();
|
|
8392
8414
|
};
|
|
8393
8415
|
}, [queryRef]);
|
|
8416
|
+
React__namespace.useEffect(function () {
|
|
8417
|
+
if (queryRef.disposed) {
|
|
8418
|
+
suspenseCache.add(cacheKey, queryRef);
|
|
8419
|
+
queryRef.reinitialize();
|
|
8420
|
+
}
|
|
8421
|
+
});
|
|
8394
8422
|
var skipResult = React__namespace.useMemo(function () {
|
|
8395
8423
|
var error = toApolloError(queryRef.result);
|
|
8396
8424
|
return {
|
|
@@ -8498,6 +8526,11 @@ function _useBackgroundQuery(query, options) {
|
|
|
8498
8526
|
var promise = queryRef.applyOptions(watchQueryOptions);
|
|
8499
8527
|
updateWrappedQueryRef(wrappedQueryRef, promise);
|
|
8500
8528
|
}
|
|
8529
|
+
React__namespace.useEffect(function () {
|
|
8530
|
+
if (queryRef.disposed) {
|
|
8531
|
+
suspenseCache.add(cacheKey, queryRef);
|
|
8532
|
+
}
|
|
8533
|
+
});
|
|
8501
8534
|
var fetchMore = React__namespace.useCallback(function (options) {
|
|
8502
8535
|
var promise = queryRef.fetchMore(options);
|
|
8503
8536
|
setWrappedQueryRef(wrapQueryRef(queryRef));
|
|
@@ -8508,6 +8541,7 @@ function _useBackgroundQuery(query, options) {
|
|
|
8508
8541
|
setWrappedQueryRef(wrapQueryRef(queryRef));
|
|
8509
8542
|
return promise;
|
|
8510
8543
|
}, [queryRef]);
|
|
8544
|
+
React__namespace.useEffect(function () { return queryRef.softRetain(); }, [queryRef]);
|
|
8511
8545
|
return [
|
|
8512
8546
|
didFetchResult.current ? wrappedQueryRef : void 0,
|
|
8513
8547
|
{ fetchMore: fetchMore, refetch: refetch },
|
|
@@ -8599,7 +8633,12 @@ function _useReadQuery(queryRef) {
|
|
|
8599
8633
|
internalQueryRef.reinitialize();
|
|
8600
8634
|
updateWrappedQueryRef(queryRef, internalQueryRef.promise);
|
|
8601
8635
|
}
|
|
8602
|
-
React__namespace.useEffect(function () {
|
|
8636
|
+
React__namespace.useEffect(function () {
|
|
8637
|
+
if (internalQueryRef.disposed) {
|
|
8638
|
+
internalQueryRef.reinitialize();
|
|
8639
|
+
}
|
|
8640
|
+
return internalQueryRef.retain();
|
|
8641
|
+
}, [internalQueryRef]);
|
|
8603
8642
|
var promise = useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
|
|
8604
8643
|
return internalQueryRef.listen(function (promise) {
|
|
8605
8644
|
updateWrappedQueryRef(queryRef, promise);
|