@apollo/client 3.10.0-alpha.1 → 3.10.0-rc.0
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/.changeset/chatty-llamas-switch.md +5 -0
- package/.changeset/pre.json +6 -3
- package/.changeset/stupid-bears-cheat.md +5 -0
- package/.changeset/tiny-bugs-tap.md +5 -0
- package/.changeset/twelve-apples-vanish.md +5 -0
- package/CHANGELOG.md +37 -3
- package/apollo-client.cjs +53 -13
- 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 +18 -15
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +18 -15
- package/dev/index.d.ts +2 -0
- package/dev/index.js +1 -0
- package/dev/index.js.map +1 -1
- package/dev/loadErrorMessageHandler.d.ts +6 -1
- package/dev/loadErrorMessageHandler.js +17 -14
- package/dev/loadErrorMessageHandler.js.map +1 -1
- package/dev/setErrorMessageHandler.d.ts +34 -0
- package/dev/setErrorMessageHandler.js +9 -0
- package/dev/setErrorMessageHandler.js.map +1 -0
- package/package.json +17 -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 +3 -1
- package/react/internal/cache/QueryReference.js +33 -6
- 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 +26 -5
- package/react/internal/internal.cjs.map +1 -1
- package/react/internal/internal.cjs.native.js +26 -5
- package/react/query-preloader/createQueryPreloader.d.ts +0 -1
- package/react/query-preloader/createQueryPreloader.js +0 -1
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/react.cjs.map +1 -1
- package/testing/core/core.cjs +103 -0
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +103 -0
- package/testing/core/createMockFetch.d.ts +38 -0
- package/testing/core/createMockFetch.js +79 -0
- package/testing/core/createMockFetch.js.map +1 -0
- package/testing/core/createProxiedSchema.d.ts +47 -0
- package/testing/core/createProxiedSchema.js +99 -0
- package/testing/core/createProxiedSchema.js.map +1 -0
- package/testing/core/index.d.ts +2 -0
- package/testing/core/index.js +2 -0
- package/testing/core/index.js.map +1 -1
- package/testing/graphql-tools/utils.d.ts +26 -0
- package/testing/graphql-tools/utils.js +172 -0
- package/testing/graphql-tools/utils.js.map +1 -0
- package/testing/graphql-tools/utils.test.d.ts +2 -0
- package/testing/graphql-tools/utils.test.js +139 -0
- package/testing/graphql-tools/utils.test.js.map +1 -0
- package/testing/index.d.ts +1 -0
- package/testing/index.js +1 -0
- package/testing/index.js.map +1 -1
- package/testing/testing.cjs +134 -0
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +134 -0
- 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/utilities/globals/invariantWrappers.d.ts +1 -1
- package/utilities/globals/invariantWrappers.js.map +1 -1
- package/version.js +1 -1
- package/.changeset/flat-singers-kiss.md +0 -5
package/.changeset/pre.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"mode": "pre",
|
|
3
|
-
"tag": "
|
|
3
|
+
"tag": "rc",
|
|
4
4
|
"initialVersions": {
|
|
5
5
|
"@apollo/client": "3.9.7"
|
|
6
6
|
},
|
|
7
7
|
"changesets": [
|
|
8
|
-
"
|
|
9
|
-
"
|
|
8
|
+
"chatty-llamas-switch",
|
|
9
|
+
"stupid-bears-cheat",
|
|
10
|
+
"tasty-pillows-ring",
|
|
11
|
+
"tiny-bugs-tap",
|
|
12
|
+
"twelve-apples-vanish"
|
|
10
13
|
]
|
|
11
14
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
# @apollo/client
|
|
2
2
|
|
|
3
|
-
## 3.10.0-
|
|
3
|
+
## 3.10.0-rc.0
|
|
4
4
|
|
|
5
|
-
###
|
|
5
|
+
### Minor Changes
|
|
6
6
|
|
|
7
|
-
- [#
|
|
7
|
+
- [#11605](https://github.com/apollographql/apollo-client/pull/11605) [`e2dd4c9`](https://github.com/apollographql/apollo-client/commit/e2dd4c95290cea604b548cc446826d89aafe8e11) Thanks [@alessbell](https://github.com/alessbell)! - Adds `createMockFetch` utility for integration testing that includes the link chain
|
|
8
|
+
|
|
9
|
+
- [#11605](https://github.com/apollographql/apollo-client/pull/11605) [`e2dd4c9`](https://github.com/apollographql/apollo-client/commit/e2dd4c95290cea604b548cc446826d89aafe8e11) Thanks [@alessbell](https://github.com/alessbell)! - Adds proxiedSchema and createMockSchema testing utilities
|
|
10
|
+
|
|
11
|
+
- [#11743](https://github.com/apollographql/apollo-client/pull/11743) [`78891f9`](https://github.com/apollographql/apollo-client/commit/78891f9ec81c0b7a7e010f5550a91965fa33a958) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove alpha designation for `queryRef.toPromise()` to stabilize the API.
|
|
12
|
+
|
|
13
|
+
- [#11743](https://github.com/apollographql/apollo-client/pull/11743) [`78891f9`](https://github.com/apollographql/apollo-client/commit/78891f9ec81c0b7a7e010f5550a91965fa33a958) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove alpha designation for `createQueryPreloader` to stabilize the API.
|
|
8
14
|
|
|
9
15
|
## 3.10.0-alpha.0
|
|
10
16
|
|
|
@@ -12,6 +18,34 @@
|
|
|
12
18
|
|
|
13
19
|
- [#11465](https://github.com/apollographql/apollo-client/pull/11465) [`7623da7`](https://github.com/apollographql/apollo-client/commit/7623da7720855b0c19e13ff9124679f426a39725) Thanks [@alessbell](https://github.com/alessbell)! - Add `watchFragment` method to the cache and expose it on ApolloClient, refactor `useFragment` using `watchFragment`.
|
|
14
20
|
|
|
21
|
+
## 3.9.10
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#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.
|
|
26
|
+
|
|
27
|
+
- [#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.
|
|
28
|
+
|
|
29
|
+
- [#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.
|
|
30
|
+
|
|
31
|
+
## 3.9.9
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- [#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.
|
|
36
|
+
|
|
37
|
+
## 3.9.8
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- [#11706](https://github.com/apollographql/apollo-client/pull/11706) [`8619bc7`](https://github.com/apollographql/apollo-client/commit/8619bc7e569c1c732afa6faf605c83a6ce0cdf0c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix issue in all suspense hooks where returning an empty array after calling `fetchMore` would rerender the component with an empty list.
|
|
42
|
+
|
|
43
|
+
- [#11694](https://github.com/apollographql/apollo-client/pull/11694) [`835d5f3`](https://github.com/apollographql/apollo-client/commit/835d5f30c532c432e2434561580e6f1ec44cc908) Thanks [@phryneas](https://github.com/phryneas)! - Expose `setErrorMessageHandler` from `@apollo/client/dev` entrypoint.
|
|
44
|
+
|
|
45
|
+
- [#11689](https://github.com/apollographql/apollo-client/pull/11689) [`cb8ffe5`](https://github.com/apollographql/apollo-client/commit/cb8ffe50e903397f741b62a44624bfe69b5f7b75) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix issue where passing a new `from` option to `useFragment` would first render with the previous value before rerendering with the correct value.
|
|
46
|
+
|
|
47
|
+
- [#11713](https://github.com/apollographql/apollo-client/pull/11713) [`642092c`](https://github.com/apollographql/apollo-client/commit/642092c713199093aede45f105a1ee3f637614cd) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix issue where setting a default `watchQuery` option in the `ApolloClient` constructor could break `startTransition` when used with suspense hooks.
|
|
48
|
+
|
|
15
49
|
## 3.9.7
|
|
16
50
|
|
|
17
51
|
### 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.10.0-
|
|
34
|
+
var version = "3.10.0-rc.0";
|
|
35
35
|
|
|
36
36
|
function maybe(thunk) {
|
|
37
37
|
try {
|
|
@@ -3345,12 +3345,14 @@ var StoreReader = (function () {
|
|
|
3345
3345
|
}
|
|
3346
3346
|
}
|
|
3347
3347
|
else if (isArray(fieldValue)) {
|
|
3348
|
-
fieldValue
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3348
|
+
if (fieldValue.length > 0) {
|
|
3349
|
+
fieldValue = handleMissing(_this.executeSubSelectedArray({
|
|
3350
|
+
field: selection,
|
|
3351
|
+
array: fieldValue,
|
|
3352
|
+
enclosingRef: enclosingRef,
|
|
3353
|
+
context: context,
|
|
3354
|
+
}), resultName);
|
|
3355
|
+
}
|
|
3354
3356
|
}
|
|
3355
3357
|
else if (!selection.selectionSet) {
|
|
3356
3358
|
if (context.canonizeResults) {
|
|
@@ -8151,6 +8153,7 @@ var InternalQueryReference = (function () {
|
|
|
8151
8153
|
this.key = {};
|
|
8152
8154
|
this.listeners = new Set();
|
|
8153
8155
|
this.references = 0;
|
|
8156
|
+
this.softReferences = 0;
|
|
8154
8157
|
this.handleNext = this.handleNext.bind(this);
|
|
8155
8158
|
this.handleError = this.handleError.bind(this);
|
|
8156
8159
|
this.dispose = this.dispose.bind(this);
|
|
@@ -8215,8 +8218,23 @@ var InternalQueryReference = (function () {
|
|
|
8215
8218
|
}
|
|
8216
8219
|
disposed = true;
|
|
8217
8220
|
_this.references--;
|
|
8221
|
+
if (!_this.references) {
|
|
8222
|
+
_this.dispose();
|
|
8223
|
+
}
|
|
8224
|
+
};
|
|
8225
|
+
};
|
|
8226
|
+
InternalQueryReference.prototype.softRetain = function () {
|
|
8227
|
+
var _this = this;
|
|
8228
|
+
this.softReferences++;
|
|
8229
|
+
var disposed = false;
|
|
8230
|
+
return function () {
|
|
8231
|
+
if (disposed) {
|
|
8232
|
+
return;
|
|
8233
|
+
}
|
|
8234
|
+
disposed = true;
|
|
8235
|
+
_this.softReferences--;
|
|
8218
8236
|
setTimeout(function () {
|
|
8219
|
-
if (!_this.references) {
|
|
8237
|
+
if (!_this.softReferences && !_this.references) {
|
|
8220
8238
|
_this.dispose();
|
|
8221
8239
|
}
|
|
8222
8240
|
});
|
|
@@ -8225,7 +8243,8 @@ var InternalQueryReference = (function () {
|
|
|
8225
8243
|
InternalQueryReference.prototype.didChangeOptions = function (watchQueryOptions) {
|
|
8226
8244
|
var _this = this;
|
|
8227
8245
|
return OBSERVED_CHANGED_OPTIONS.some(function (option) {
|
|
8228
|
-
return
|
|
8246
|
+
return option in watchQueryOptions &&
|
|
8247
|
+
!equal.equal(_this.watchQueryOptions[option], watchQueryOptions[option]);
|
|
8229
8248
|
});
|
|
8230
8249
|
};
|
|
8231
8250
|
InternalQueryReference.prototype.applyOptions = function (watchQueryOptions) {
|
|
@@ -8311,12 +8330,12 @@ var InternalQueryReference = (function () {
|
|
|
8311
8330
|
this.promise = this.createPendingPromise();
|
|
8312
8331
|
this.promise.catch(function () { });
|
|
8313
8332
|
returnedPromise
|
|
8314
|
-
.then(function (
|
|
8333
|
+
.then(function () {
|
|
8315
8334
|
setTimeout(function () {
|
|
8316
8335
|
var _a;
|
|
8317
8336
|
if (_this.promise.status === "pending") {
|
|
8318
|
-
_this.result =
|
|
8319
|
-
(_a = _this.resolve) === null || _a === void 0 ? void 0 : _a.call(_this, result);
|
|
8337
|
+
_this.result = _this.observable.getCurrentResult();
|
|
8338
|
+
(_a = _this.resolve) === null || _a === void 0 ? void 0 : _a.call(_this, _this.result);
|
|
8320
8339
|
}
|
|
8321
8340
|
});
|
|
8322
8341
|
})
|
|
@@ -8369,6 +8388,10 @@ var SuspenseCache = (function () {
|
|
|
8369
8388
|
}
|
|
8370
8389
|
return ref.current;
|
|
8371
8390
|
};
|
|
8391
|
+
SuspenseCache.prototype.add = function (cacheKey, queryRef) {
|
|
8392
|
+
var ref = this.queryRefs.lookupArray(cacheKey);
|
|
8393
|
+
ref.current = queryRef;
|
|
8394
|
+
};
|
|
8372
8395
|
return SuspenseCache;
|
|
8373
8396
|
}());
|
|
8374
8397
|
|
|
@@ -8423,6 +8446,12 @@ function _useSuspenseQuery(query, options) {
|
|
|
8423
8446
|
dispose();
|
|
8424
8447
|
};
|
|
8425
8448
|
}, [queryRef]);
|
|
8449
|
+
React__namespace.useEffect(function () {
|
|
8450
|
+
if (queryRef.disposed) {
|
|
8451
|
+
suspenseCache.add(cacheKey, queryRef);
|
|
8452
|
+
queryRef.reinitialize();
|
|
8453
|
+
}
|
|
8454
|
+
});
|
|
8426
8455
|
var skipResult = React__namespace.useMemo(function () {
|
|
8427
8456
|
var error = toApolloError(queryRef.result);
|
|
8428
8457
|
return {
|
|
@@ -8530,6 +8559,11 @@ function _useBackgroundQuery(query, options) {
|
|
|
8530
8559
|
var promise = queryRef.applyOptions(watchQueryOptions);
|
|
8531
8560
|
updateWrappedQueryRef(wrappedQueryRef, promise);
|
|
8532
8561
|
}
|
|
8562
|
+
React__namespace.useEffect(function () {
|
|
8563
|
+
if (queryRef.disposed) {
|
|
8564
|
+
suspenseCache.add(cacheKey, queryRef);
|
|
8565
|
+
}
|
|
8566
|
+
});
|
|
8533
8567
|
var fetchMore = React__namespace.useCallback(function (options) {
|
|
8534
8568
|
var promise = queryRef.fetchMore(options);
|
|
8535
8569
|
setWrappedQueryRef(wrapQueryRef(queryRef));
|
|
@@ -8540,6 +8574,7 @@ function _useBackgroundQuery(query, options) {
|
|
|
8540
8574
|
setWrappedQueryRef(wrapQueryRef(queryRef));
|
|
8541
8575
|
return promise;
|
|
8542
8576
|
}, [queryRef]);
|
|
8577
|
+
React__namespace.useEffect(function () { return queryRef.softRetain(); }, [queryRef]);
|
|
8543
8578
|
return [
|
|
8544
8579
|
didFetchResult.current ? wrappedQueryRef : void 0,
|
|
8545
8580
|
{ fetchMore: fetchMore, refetch: refetch },
|
|
@@ -8631,7 +8666,12 @@ function _useReadQuery(queryRef) {
|
|
|
8631
8666
|
internalQueryRef.reinitialize();
|
|
8632
8667
|
updateWrappedQueryRef(queryRef, internalQueryRef.promise);
|
|
8633
8668
|
}
|
|
8634
|
-
React__namespace.useEffect(function () {
|
|
8669
|
+
React__namespace.useEffect(function () {
|
|
8670
|
+
if (internalQueryRef.disposed) {
|
|
8671
|
+
internalQueryRef.reinitialize();
|
|
8672
|
+
}
|
|
8673
|
+
return internalQueryRef.retain();
|
|
8674
|
+
}, [internalQueryRef]);
|
|
8635
8675
|
var promise = useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
|
|
8636
8676
|
return internalQueryRef.listen(function (promise) {
|
|
8637
8677
|
updateWrappedQueryRef(queryRef, promise);
|