@apollo/client 3.10.0-alpha.1 → 3.10.0-rc.1
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/cold-dancers-call.md +5 -0
- package/.changeset/green-garlics-protect.md +5 -0
- package/.changeset/hungry-bobcats-battle.md +5 -0
- package/.changeset/kind-foxes-float.md +5 -0
- package/.changeset/old-onions-sleep.md +5 -0
- package/.changeset/pre.json +14 -3
- package/.changeset/spotty-garlics-knock.md +5 -0
- package/.changeset/strong-paws-kneel.md +5 -0
- 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/.changeset/wet-plants-admire.md +5 -0
- package/CHANGELOG.md +64 -2
- package/apollo-client.cjs +70 -19
- 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/index.d.ts +1 -1
- package/cache/index.js.map +1 -1
- package/cache/inmemory/readFromStore.js +8 -6
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/core/ApolloClient.js +1 -0
- package/core/ApolloClient.js.map +1 -1
- package/core/core.cjs +2 -1
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +2 -1
- package/core/index.d.ts +1 -1
- package/core/index.js.map +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 +18 -16
- package/react/hooks/hooks.cjs +28 -2
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +28 -2
- package/react/hooks/internal/wrapHook.d.ts +2 -1
- package/react/hooks/internal/wrapHook.js.map +1 -1
- package/react/hooks/useBackgroundQuery.js +14 -0
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.js +12 -0
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReadQuery.js +19 -2
- 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 +39 -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 +32 -10
- package/react/internal/internal.cjs.map +1 -1
- package/react/internal/internal.cjs.native.js +32 -10
- 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/experimental/createSchemaFetch.d.ts +43 -0
- package/testing/experimental/createSchemaFetch.js +99 -0
- package/testing/experimental/createSchemaFetch.js.map +1 -0
- package/testing/experimental/createTestSchema.d.ts +55 -0
- package/testing/experimental/createTestSchema.js +110 -0
- package/testing/experimental/createTestSchema.js.map +1 -0
- package/testing/experimental/experimental.cjs +274 -0
- package/testing/experimental/experimental.cjs.map +1 -0
- package/testing/experimental/experimental.cjs.native.js +274 -0
- package/testing/experimental/graphql-tools/utils.d.ts +26 -0
- package/testing/experimental/graphql-tools/utils.js +172 -0
- package/testing/experimental/graphql-tools/utils.js.map +1 -0
- package/testing/experimental/graphql-tools/utils.test.d.ts +2 -0
- package/testing/experimental/graphql-tools/utils.test.js +139 -0
- package/testing/experimental/graphql-tools/utils.test.js.map +1 -0
- package/testing/experimental/index.d.ts +3 -0
- package/testing/experimental/index.js +3 -0
- package/testing/experimental/index.js.map +1 -0
- package/testing/experimental/package.json +8 -0
- package/testing/internal/profile/profile.js +6 -2
- package/testing/internal/profile/profile.js.map +1 -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/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,22 @@
|
|
|
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
|
+
"cold-dancers-call",
|
|
10
|
+
"green-garlics-protect",
|
|
11
|
+
"hungry-bobcats-battle",
|
|
12
|
+
"kind-foxes-float",
|
|
13
|
+
"old-onions-sleep",
|
|
14
|
+
"spotty-garlics-knock",
|
|
15
|
+
"strong-paws-kneel",
|
|
16
|
+
"stupid-bears-cheat",
|
|
17
|
+
"tasty-pillows-ring",
|
|
18
|
+
"tiny-bugs-tap",
|
|
19
|
+
"twelve-apples-vanish",
|
|
20
|
+
"wet-plants-admire"
|
|
10
21
|
]
|
|
11
22
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,38 @@
|
|
|
1
1
|
# @apollo/client
|
|
2
2
|
|
|
3
|
-
## 3.10.0-
|
|
3
|
+
## 3.10.0-rc.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#11760](https://github.com/apollographql/apollo-client/pull/11760) [`acd1982`](https://github.com/apollographql/apollo-client/commit/acd1982a59ed66fc44fa9e70b08a31c69dac35a6) Thanks [@alessbell](https://github.com/alessbell)! - `createTestSchema` now uses graphql-tools `mergeResolvers` to merge resolvers instead of a shallow merge.
|
|
8
|
+
|
|
9
|
+
- [#11764](https://github.com/apollographql/apollo-client/pull/11764) [`f046aa9`](https://github.com/apollographql/apollo-client/commit/f046aa9fc24ac197a797045d280811a3bbe05806) Thanks [@alessbell](https://github.com/alessbell)! - Rename `createProxiedSchema` to `createTestSchema` and `createMockFetch` to `createSchemaFetch`.
|
|
10
|
+
|
|
11
|
+
- [#11777](https://github.com/apollographql/apollo-client/pull/11777) [`5dfc79f`](https://github.com/apollographql/apollo-client/commit/5dfc79fa6d974362f38361f7dffbe984a9546377) Thanks [@alessbell](https://github.com/alessbell)! - Call `createMockSchema` inside `createTestSchema`.
|
|
12
|
+
|
|
13
|
+
- [#11774](https://github.com/apollographql/apollo-client/pull/11774) [`2583488`](https://github.com/apollographql/apollo-client/commit/2583488677912cb4500e5fb9e3f91b5c113c4cdb) Thanks [@alessbell](https://github.com/alessbell)! - Add ability to set min and max delay in `createSchemaFetch`
|
|
14
|
+
|
|
15
|
+
- [#11783](https://github.com/apollographql/apollo-client/pull/11783) [`440563a`](https://github.com/apollographql/apollo-client/commit/440563ab2c47efcb9c7d08f52531ade33d753037) Thanks [@alessbell](https://github.com/alessbell)! - Moves new testing utilities to their own entrypoint, `testing/experimental`
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
6
18
|
|
|
7
|
-
- [#
|
|
19
|
+
- [#11757](https://github.com/apollographql/apollo-client/pull/11757) [`9825295`](https://github.com/apollographql/apollo-client/commit/982529530893f66a1d236f0fff53862e513fc9a8) Thanks [@phryneas](https://github.com/phryneas)! - Adjust `useReadQuery` wrapper logic to work with transported objects.
|
|
20
|
+
|
|
21
|
+
- [#11771](https://github.com/apollographql/apollo-client/pull/11771) [`e72cbba`](https://github.com/apollographql/apollo-client/commit/e72cbba07e5caa6d75b44ca8c766846e855a6c93) Thanks [@phryneas](https://github.com/phryneas)! - Wrap `useQueryRefHandlers` in `wrapHook`.
|
|
22
|
+
|
|
23
|
+
- [#11754](https://github.com/apollographql/apollo-client/pull/11754) [`80d2ba5`](https://github.com/apollographql/apollo-client/commit/80d2ba579fe6d2a2d102d1fe79d7d503f31cd931) Thanks [@alessbell](https://github.com/alessbell)! - Export `WatchFragmentOptions` and `WatchFragmentResult` from main entrypoint and fix bug where `this` wasn't bound to the `watchFragment` method on `ApolloClient`.
|
|
24
|
+
|
|
25
|
+
## 3.10.0-rc.0
|
|
26
|
+
|
|
27
|
+
### Minor Changes
|
|
28
|
+
|
|
29
|
+
- [#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
|
|
30
|
+
|
|
31
|
+
- [#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
|
|
32
|
+
|
|
33
|
+
- [#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.
|
|
34
|
+
|
|
35
|
+
- [#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
36
|
|
|
9
37
|
## 3.10.0-alpha.0
|
|
10
38
|
|
|
@@ -12,6 +40,40 @@
|
|
|
12
40
|
|
|
13
41
|
- [#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
42
|
|
|
43
|
+
## 3.9.11
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- [#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.
|
|
48
|
+
|
|
49
|
+
## 3.9.10
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- [#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.
|
|
54
|
+
|
|
55
|
+
- [#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.
|
|
56
|
+
|
|
57
|
+
- [#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.
|
|
58
|
+
|
|
59
|
+
## 3.9.9
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- [#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.
|
|
64
|
+
|
|
65
|
+
## 3.9.8
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- [#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.
|
|
70
|
+
|
|
71
|
+
- [#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.
|
|
72
|
+
|
|
73
|
+
- [#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.
|
|
74
|
+
|
|
75
|
+
- [#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.
|
|
76
|
+
|
|
15
77
|
## 3.9.7
|
|
16
78
|
|
|
17
79
|
### 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.1";
|
|
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) {
|
|
@@ -6966,6 +6968,7 @@ var ApolloClient = (function () {
|
|
|
6966
6968
|
this.watchQuery = this.watchQuery.bind(this);
|
|
6967
6969
|
this.query = this.query.bind(this);
|
|
6968
6970
|
this.mutate = this.mutate.bind(this);
|
|
6971
|
+
this.watchFragment = this.watchFragment.bind(this);
|
|
6969
6972
|
this.resetStore = this.resetStore.bind(this);
|
|
6970
6973
|
this.reFetchObservableQueries = this.reFetchObservableQueries.bind(this);
|
|
6971
6974
|
this.version = version;
|
|
@@ -8151,6 +8154,7 @@ var InternalQueryReference = (function () {
|
|
|
8151
8154
|
this.key = {};
|
|
8152
8155
|
this.listeners = new Set();
|
|
8153
8156
|
this.references = 0;
|
|
8157
|
+
this.softReferences = 0;
|
|
8154
8158
|
this.handleNext = this.handleNext.bind(this);
|
|
8155
8159
|
this.handleError = this.handleError.bind(this);
|
|
8156
8160
|
this.dispose = this.dispose.bind(this);
|
|
@@ -8185,16 +8189,17 @@ var InternalQueryReference = (function () {
|
|
|
8185
8189
|
InternalQueryReference.prototype.reinitialize = function () {
|
|
8186
8190
|
var observable = this.observable;
|
|
8187
8191
|
var originalFetchPolicy = this.watchQueryOptions.fetchPolicy;
|
|
8192
|
+
var avoidNetworkRequests = originalFetchPolicy === "no-cache" || originalFetchPolicy === "standby";
|
|
8188
8193
|
try {
|
|
8189
|
-
if (
|
|
8190
|
-
observable.
|
|
8191
|
-
observable.silentSetOptions({ fetchPolicy: "cache-first" });
|
|
8194
|
+
if (avoidNetworkRequests) {
|
|
8195
|
+
observable.silentSetOptions({ fetchPolicy: "standby" });
|
|
8192
8196
|
}
|
|
8193
8197
|
else {
|
|
8194
|
-
observable.
|
|
8198
|
+
observable.resetLastResults();
|
|
8199
|
+
observable.silentSetOptions({ fetchPolicy: "cache-first" });
|
|
8195
8200
|
}
|
|
8196
8201
|
this.subscribeToQuery();
|
|
8197
|
-
if (
|
|
8202
|
+
if (avoidNetworkRequests) {
|
|
8198
8203
|
return;
|
|
8199
8204
|
}
|
|
8200
8205
|
observable.resetDiff();
|
|
@@ -8215,8 +8220,23 @@ var InternalQueryReference = (function () {
|
|
|
8215
8220
|
}
|
|
8216
8221
|
disposed = true;
|
|
8217
8222
|
_this.references--;
|
|
8223
|
+
if (!_this.references) {
|
|
8224
|
+
_this.dispose();
|
|
8225
|
+
}
|
|
8226
|
+
};
|
|
8227
|
+
};
|
|
8228
|
+
InternalQueryReference.prototype.softRetain = function () {
|
|
8229
|
+
var _this = this;
|
|
8230
|
+
this.softReferences++;
|
|
8231
|
+
var disposed = false;
|
|
8232
|
+
return function () {
|
|
8233
|
+
if (disposed) {
|
|
8234
|
+
return;
|
|
8235
|
+
}
|
|
8236
|
+
disposed = true;
|
|
8237
|
+
_this.softReferences--;
|
|
8218
8238
|
setTimeout(function () {
|
|
8219
|
-
if (!_this.references) {
|
|
8239
|
+
if (!_this.softReferences && !_this.references) {
|
|
8220
8240
|
_this.dispose();
|
|
8221
8241
|
}
|
|
8222
8242
|
});
|
|
@@ -8225,7 +8245,8 @@ var InternalQueryReference = (function () {
|
|
|
8225
8245
|
InternalQueryReference.prototype.didChangeOptions = function (watchQueryOptions) {
|
|
8226
8246
|
var _this = this;
|
|
8227
8247
|
return OBSERVED_CHANGED_OPTIONS.some(function (option) {
|
|
8228
|
-
return
|
|
8248
|
+
return option in watchQueryOptions &&
|
|
8249
|
+
!equal.equal(_this.watchQueryOptions[option], watchQueryOptions[option]);
|
|
8229
8250
|
});
|
|
8230
8251
|
};
|
|
8231
8252
|
InternalQueryReference.prototype.applyOptions = function (watchQueryOptions) {
|
|
@@ -8311,12 +8332,12 @@ var InternalQueryReference = (function () {
|
|
|
8311
8332
|
this.promise = this.createPendingPromise();
|
|
8312
8333
|
this.promise.catch(function () { });
|
|
8313
8334
|
returnedPromise
|
|
8314
|
-
.then(function (
|
|
8335
|
+
.then(function () {
|
|
8315
8336
|
setTimeout(function () {
|
|
8316
8337
|
var _a;
|
|
8317
8338
|
if (_this.promise.status === "pending") {
|
|
8318
|
-
_this.result =
|
|
8319
|
-
(_a = _this.resolve) === null || _a === void 0 ? void 0 : _a.call(_this, result);
|
|
8339
|
+
_this.result = _this.observable.getCurrentResult();
|
|
8340
|
+
(_a = _this.resolve) === null || _a === void 0 ? void 0 : _a.call(_this, _this.result);
|
|
8320
8341
|
}
|
|
8321
8342
|
});
|
|
8322
8343
|
})
|
|
@@ -8369,6 +8390,10 @@ var SuspenseCache = (function () {
|
|
|
8369
8390
|
}
|
|
8370
8391
|
return ref.current;
|
|
8371
8392
|
};
|
|
8393
|
+
SuspenseCache.prototype.add = function (cacheKey, queryRef) {
|
|
8394
|
+
var ref = this.queryRefs.lookupArray(cacheKey);
|
|
8395
|
+
ref.current = queryRef;
|
|
8396
|
+
};
|
|
8372
8397
|
return SuspenseCache;
|
|
8373
8398
|
}());
|
|
8374
8399
|
|
|
@@ -8423,6 +8448,12 @@ function _useSuspenseQuery(query, options) {
|
|
|
8423
8448
|
dispose();
|
|
8424
8449
|
};
|
|
8425
8450
|
}, [queryRef]);
|
|
8451
|
+
React__namespace.useEffect(function () {
|
|
8452
|
+
if (queryRef.disposed) {
|
|
8453
|
+
suspenseCache.add(cacheKey, queryRef);
|
|
8454
|
+
queryRef.reinitialize();
|
|
8455
|
+
}
|
|
8456
|
+
});
|
|
8426
8457
|
var skipResult = React__namespace.useMemo(function () {
|
|
8427
8458
|
var error = toApolloError(queryRef.result);
|
|
8428
8459
|
return {
|
|
@@ -8530,6 +8561,11 @@ function _useBackgroundQuery(query, options) {
|
|
|
8530
8561
|
var promise = queryRef.applyOptions(watchQueryOptions);
|
|
8531
8562
|
updateWrappedQueryRef(wrappedQueryRef, promise);
|
|
8532
8563
|
}
|
|
8564
|
+
React__namespace.useEffect(function () {
|
|
8565
|
+
if (queryRef.disposed) {
|
|
8566
|
+
suspenseCache.add(cacheKey, queryRef);
|
|
8567
|
+
}
|
|
8568
|
+
});
|
|
8533
8569
|
var fetchMore = React__namespace.useCallback(function (options) {
|
|
8534
8570
|
var promise = queryRef.fetchMore(options);
|
|
8535
8571
|
setWrappedQueryRef(wrapQueryRef(queryRef));
|
|
@@ -8540,6 +8576,7 @@ function _useBackgroundQuery(query, options) {
|
|
|
8540
8576
|
setWrappedQueryRef(wrapQueryRef(queryRef));
|
|
8541
8577
|
return promise;
|
|
8542
8578
|
}, [queryRef]);
|
|
8579
|
+
React__namespace.useEffect(function () { return queryRef.softRetain(); }, [queryRef]);
|
|
8543
8580
|
return [
|
|
8544
8581
|
didFetchResult.current ? wrappedQueryRef : void 0,
|
|
8545
8582
|
{ fetchMore: fetchMore, refetch: refetch },
|
|
@@ -8598,6 +8635,12 @@ function useLoadableQuery(query, options) {
|
|
|
8598
8635
|
}
|
|
8599
8636
|
|
|
8600
8637
|
function useQueryRefHandlers(queryRef) {
|
|
8638
|
+
var unwrapped = unwrapQueryRef(queryRef);
|
|
8639
|
+
return wrapHook("useQueryRefHandlers", _useQueryRefHandlers, unwrapped ?
|
|
8640
|
+
unwrapped["observable"]
|
|
8641
|
+
: useApolloClient())(queryRef);
|
|
8642
|
+
}
|
|
8643
|
+
function _useQueryRefHandlers(queryRef) {
|
|
8601
8644
|
var _a = React__namespace.useState(queryRef), previousQueryRef = _a[0], setPreviousQueryRef = _a[1];
|
|
8602
8645
|
var _b = React__namespace.useState(queryRef), wrappedQueryRef = _b[0], setWrappedQueryRef = _b[1];
|
|
8603
8646
|
var internalQueryRef = unwrapQueryRef(queryRef);
|
|
@@ -8622,7 +8665,10 @@ function useQueryRefHandlers(queryRef) {
|
|
|
8622
8665
|
}
|
|
8623
8666
|
|
|
8624
8667
|
function useReadQuery(queryRef) {
|
|
8625
|
-
|
|
8668
|
+
var unwrapped = unwrapQueryRef(queryRef);
|
|
8669
|
+
return wrapHook("useReadQuery", _useReadQuery, unwrapped ?
|
|
8670
|
+
unwrapped["observable"]
|
|
8671
|
+
: useApolloClient())(queryRef);
|
|
8626
8672
|
}
|
|
8627
8673
|
function _useReadQuery(queryRef) {
|
|
8628
8674
|
var internalQueryRef = React__namespace.useMemo(function () { return unwrapQueryRef(queryRef); }, [queryRef]);
|
|
@@ -8631,7 +8677,12 @@ function _useReadQuery(queryRef) {
|
|
|
8631
8677
|
internalQueryRef.reinitialize();
|
|
8632
8678
|
updateWrappedQueryRef(queryRef, internalQueryRef.promise);
|
|
8633
8679
|
}
|
|
8634
|
-
React__namespace.useEffect(function () {
|
|
8680
|
+
React__namespace.useEffect(function () {
|
|
8681
|
+
if (internalQueryRef.disposed) {
|
|
8682
|
+
internalQueryRef.reinitialize();
|
|
8683
|
+
}
|
|
8684
|
+
return internalQueryRef.retain();
|
|
8685
|
+
}, [internalQueryRef]);
|
|
8635
8686
|
var promise = useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
|
|
8636
8687
|
return internalQueryRef.listen(function (promise) {
|
|
8637
8688
|
updateWrappedQueryRef(queryRef, promise);
|