@apollo/client 3.9.4 → 3.9.6
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 +41 -19
- package/apollo-client.cjs +82 -50
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/core/QueryInfo.js +17 -0
- package/core/QueryInfo.js.map +1 -1
- package/core/core.cjs +8 -1
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +8 -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 +19 -19
- package/react/hooks/hooks.cjs +67 -44
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +67 -44
- package/react/hooks/internal/index.d.ts +1 -0
- package/react/hooks/internal/index.js +1 -0
- package/react/hooks/internal/index.js.map +1 -1
- package/react/hooks/internal/wrapHook.d.ts +56 -0
- package/react/hooks/internal/wrapHook.js +43 -0
- package/react/hooks/internal/wrapHook.js.map +1 -0
- package/react/hooks/useBackgroundQuery.js +4 -0
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.js +4 -1
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useQuery.js +4 -0
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useReadQuery.js +4 -1
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +4 -1
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/internal/cache/QueryReference.js +17 -5
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/index.d.ts +1 -0
- package/react/internal/index.js.map +1 -1
- package/react/internal/internal.cjs +7 -5
- package/react/internal/internal.cjs.map +1 -1
- package/react/internal/internal.cjs.native.js +7 -5
- package/testing/core/core.cjs +2 -2
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +2 -2
- package/testing/core/mocking/mockLink.d.ts +1 -1
- package/testing/core/mocking/mockLink.js +2 -2
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/internal/scenarios/index.js +1 -1
- package/testing/internal/scenarios/index.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/version.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @apollo/client
|
|
2
2
|
|
|
3
|
+
## 3.9.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#11617](https://github.com/apollographql/apollo-client/pull/11617) [`f1d8bc4`](https://github.com/apollographql/apollo-client/commit/f1d8bc40c3d8e39340f721f4f1c3fd0ed77b8a6b) Thanks [@phryneas](https://github.com/phryneas)! - Allow Apollo Client instance to intercept hook functionality
|
|
8
|
+
|
|
9
|
+
- [#11638](https://github.com/apollographql/apollo-client/pull/11638) [`bf93ada`](https://github.com/apollographql/apollo-client/commit/bf93adaa0321b573db0ea8fc3a5c364e1fdfeef3) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix issue where calling `fetchMore` from a suspense-enabled hook inside `startTransition` caused an unnecessary rerender.
|
|
10
|
+
|
|
11
|
+
## 3.9.5
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#11595](https://github.com/apollographql/apollo-client/pull/11595) [`8c20955`](https://github.com/apollographql/apollo-client/commit/8c20955874562e5b2ab35557325e047b059bc4fc) Thanks [@phryneas](https://github.com/phryneas)! - Bumps the dependency `rehackt` to 0.0.5
|
|
16
|
+
|
|
17
|
+
- [#11592](https://github.com/apollographql/apollo-client/pull/11592) [`1133469`](https://github.com/apollographql/apollo-client/commit/1133469bd91ff76b9815e815a454a79d8e23a9bc) Thanks [@Stephen2](https://github.com/Stephen2)! - Strengthen `MockedResponse.newData` type
|
|
18
|
+
|
|
19
|
+
- [#11579](https://github.com/apollographql/apollo-client/pull/11579) [`1ba2fd9`](https://github.com/apollographql/apollo-client/commit/1ba2fd919f79dfdc7b9d3f7d1a7aa5918e648349) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix issue where partial data is reported to `useQuery` when using `notifyOnNetworkStatusChange` after it errors while another overlapping query succeeds.
|
|
20
|
+
|
|
21
|
+
- [#11579](https://github.com/apollographql/apollo-client/pull/11579) [`1ba2fd9`](https://github.com/apollographql/apollo-client/commit/1ba2fd919f79dfdc7b9d3f7d1a7aa5918e648349) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue where a partial cache write for an errored query would result in automatically refetching that query.
|
|
22
|
+
|
|
23
|
+
- [#11562](https://github.com/apollographql/apollo-client/pull/11562) [`65ab695`](https://github.com/apollographql/apollo-client/commit/65ab695470741e8dcaef1ebd7742c3c397526354) Thanks [@mspiess](https://github.com/mspiess)! - Mocks with an infinite delay no longer require result or error
|
|
24
|
+
|
|
3
25
|
## 3.9.4
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -113,6 +135,25 @@
|
|
|
113
135
|
|
|
114
136
|
- [#11412](https://github.com/apollographql/apollo-client/pull/11412) [`58db5c3`](https://github.com/apollographql/apollo-client/commit/58db5c3295b88162f91019f0898f6baa4b9cced6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add the ability to start preloading a query outside React to begin fetching as early as possible. Call `createQueryPreloader` to create a `preloadQuery` function which can be called to start fetching a query. This returns a `queryRef` which is passed to `useReadQuery` and suspended until the query is done fetching.
|
|
115
137
|
|
|
138
|
+
```tsx
|
|
139
|
+
const preloadQuery = createQueryPreloader(client);
|
|
140
|
+
const queryRef = preloadQuery(QUERY, { variables, ...otherOptions });
|
|
141
|
+
|
|
142
|
+
function App() {
|
|
143
|
+
return {
|
|
144
|
+
<Suspense fallback={<div>Loading</div>}>
|
|
145
|
+
<MyQuery />
|
|
146
|
+
</Suspense>
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function MyQuery() {
|
|
151
|
+
const { data } = useReadQuery(queryRef);
|
|
152
|
+
|
|
153
|
+
// do something with data
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
116
157
|
#### Testing utility improvements
|
|
117
158
|
|
|
118
159
|
- [#11178](https://github.com/apollographql/apollo-client/pull/11178) [`4d64a6f`](https://github.com/apollographql/apollo-client/commit/4d64a6fa2ad5abe6f7f172c164f5e1fc2cb89829) Thanks [@sebakerckhof](https://github.com/sebakerckhof)! - Support re-using of mocks in the MockedProvider
|
|
@@ -179,25 +220,6 @@
|
|
|
179
220
|
|
|
180
221
|
The `IGNORE` sentinel can be destructured from the second parameter in the callback function signature passed to `optimisticResponse`.
|
|
181
222
|
|
|
182
|
-
```tsx
|
|
183
|
-
const preloadQuery = createQueryPreloader(client);
|
|
184
|
-
const queryRef = preloadQuery(QUERY, { variables, ...otherOptions });
|
|
185
|
-
|
|
186
|
-
function App() {
|
|
187
|
-
return {
|
|
188
|
-
<Suspense fallback={<div>Loading</div>}>
|
|
189
|
-
<MyQuery />
|
|
190
|
-
</Suspense>
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function MyQuery() {
|
|
195
|
-
const { data } = useReadQuery(queryRef);
|
|
196
|
-
|
|
197
|
-
// do something with data
|
|
198
|
-
}
|
|
199
|
-
```
|
|
200
|
-
|
|
201
223
|
#### Network adapters for multipart subscriptions usage with Relay and urql
|
|
202
224
|
|
|
203
225
|
- [#11301](https://github.com/apollographql/apollo-client/pull/11301) [`46ab032`](https://github.com/apollographql/apollo-client/commit/46ab032af83a01f184bfcce5edba4b55dbb2962a) Thanks [@alessbell](https://github.com/alessbell)! - Add multipart subscription network adapters for Relay and urql
|
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.6";
|
|
35
35
|
|
|
36
36
|
function maybe(thunk) {
|
|
37
37
|
try {
|
|
@@ -5818,7 +5818,14 @@ var QueryInfo = (function () {
|
|
|
5818
5818
|
};
|
|
5819
5819
|
QueryInfo.prototype.setDiff = function (diff) {
|
|
5820
5820
|
var _this = this;
|
|
5821
|
+
var _a;
|
|
5821
5822
|
var oldDiff = this.lastDiff && this.lastDiff.diff;
|
|
5823
|
+
if (diff &&
|
|
5824
|
+
!diff.complete &&
|
|
5825
|
+
!((_a = this.observableQuery) === null || _a === void 0 ? void 0 : _a.options.returnPartialData) &&
|
|
5826
|
+
!(oldDiff && oldDiff.complete)) {
|
|
5827
|
+
return;
|
|
5828
|
+
}
|
|
5822
5829
|
this.updateLastDiff(diff);
|
|
5823
5830
|
if (!this.dirty && !equal.equal(oldDiff && oldDiff.result, diff && diff.result)) {
|
|
5824
5831
|
this.dirty = true;
|
|
@@ -7364,9 +7371,64 @@ function verifyDocumentType(document, type) {
|
|
|
7364
7371
|
);
|
|
7365
7372
|
}
|
|
7366
7373
|
|
|
7374
|
+
function useDeepMemo(memoFn, deps) {
|
|
7375
|
+
var ref = React__namespace.useRef();
|
|
7376
|
+
if (!ref.current || !equal.equal(ref.current.deps, deps)) {
|
|
7377
|
+
ref.current = { value: memoFn(), deps: deps };
|
|
7378
|
+
}
|
|
7379
|
+
return ref.current.value;
|
|
7380
|
+
}
|
|
7381
|
+
|
|
7382
|
+
function getRenderDispatcher() {
|
|
7383
|
+
var _a, _b;
|
|
7384
|
+
return (_b = (_a = React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _a === void 0 ? void 0 : _a.ReactCurrentDispatcher) === null || _b === void 0 ? void 0 : _b.current;
|
|
7385
|
+
}
|
|
7386
|
+
var RenderDispatcher = null;
|
|
7387
|
+
function useRenderGuard() {
|
|
7388
|
+
RenderDispatcher = getRenderDispatcher();
|
|
7389
|
+
return React__namespace.useCallback(function () {
|
|
7390
|
+
return (RenderDispatcher !== null && RenderDispatcher === getRenderDispatcher());
|
|
7391
|
+
}, []);
|
|
7392
|
+
}
|
|
7393
|
+
|
|
7394
|
+
var INIT = {};
|
|
7395
|
+
function useLazyRef(getInitialValue) {
|
|
7396
|
+
var ref = React__namespace.useRef(INIT);
|
|
7397
|
+
if (ref.current === INIT) {
|
|
7398
|
+
ref.current = getInitialValue();
|
|
7399
|
+
}
|
|
7400
|
+
return ref;
|
|
7401
|
+
}
|
|
7402
|
+
|
|
7403
|
+
var useKey = "use";
|
|
7404
|
+
var realHook = React__namespace[useKey];
|
|
7405
|
+
var __use = realHook ||
|
|
7406
|
+
function __use(promise) {
|
|
7407
|
+
var statefulPromise = wrapPromiseWithState(promise);
|
|
7408
|
+
switch (statefulPromise.status) {
|
|
7409
|
+
case "pending":
|
|
7410
|
+
throw statefulPromise;
|
|
7411
|
+
case "rejected":
|
|
7412
|
+
throw statefulPromise.reason;
|
|
7413
|
+
case "fulfilled":
|
|
7414
|
+
return statefulPromise.value;
|
|
7415
|
+
}
|
|
7416
|
+
};
|
|
7417
|
+
|
|
7418
|
+
var wrapperSymbol = Symbol.for("apollo.hook.wrappers");
|
|
7419
|
+
function wrapHook(hookName, useHook, clientOrObsQuery) {
|
|
7420
|
+
var queryManager = clientOrObsQuery["queryManager"];
|
|
7421
|
+
var wrappers = queryManager && queryManager[wrapperSymbol];
|
|
7422
|
+
var wrapper = wrappers && wrappers[hookName];
|
|
7423
|
+
return wrapper ? wrapper(useHook) : useHook;
|
|
7424
|
+
}
|
|
7425
|
+
|
|
7367
7426
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
7368
7427
|
function useQuery(query, options) {
|
|
7369
7428
|
if (options === void 0) { options = Object.create(null); }
|
|
7429
|
+
return wrapHook("useQuery", _useQuery, useApolloClient(options && options.client))(query, options);
|
|
7430
|
+
}
|
|
7431
|
+
function _useQuery(query, options) {
|
|
7370
7432
|
return useInternalState(useApolloClient(options.client), query).useQuery(options);
|
|
7371
7433
|
}
|
|
7372
7434
|
function useInternalState(client, query) {
|
|
@@ -7971,51 +8033,10 @@ function useReactiveVar(rv) {
|
|
|
7971
8033
|
}, [rv]), rv, rv);
|
|
7972
8034
|
}
|
|
7973
8035
|
|
|
7974
|
-
function useDeepMemo(memoFn, deps) {
|
|
7975
|
-
var ref = React__namespace.useRef();
|
|
7976
|
-
if (!ref.current || !equal.equal(ref.current.deps, deps)) {
|
|
7977
|
-
ref.current = { value: memoFn(), deps: deps };
|
|
7978
|
-
}
|
|
7979
|
-
return ref.current.value;
|
|
7980
|
-
}
|
|
7981
|
-
|
|
7982
|
-
function getRenderDispatcher() {
|
|
7983
|
-
var _a, _b;
|
|
7984
|
-
return (_b = (_a = React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _a === void 0 ? void 0 : _a.ReactCurrentDispatcher) === null || _b === void 0 ? void 0 : _b.current;
|
|
7985
|
-
}
|
|
7986
|
-
var RenderDispatcher = null;
|
|
7987
|
-
function useRenderGuard() {
|
|
7988
|
-
RenderDispatcher = getRenderDispatcher();
|
|
7989
|
-
return React__namespace.useCallback(function () {
|
|
7990
|
-
return (RenderDispatcher !== null && RenderDispatcher === getRenderDispatcher());
|
|
7991
|
-
}, []);
|
|
7992
|
-
}
|
|
7993
|
-
|
|
7994
|
-
var INIT = {};
|
|
7995
|
-
function useLazyRef(getInitialValue) {
|
|
7996
|
-
var ref = React__namespace.useRef(INIT);
|
|
7997
|
-
if (ref.current === INIT) {
|
|
7998
|
-
ref.current = getInitialValue();
|
|
7999
|
-
}
|
|
8000
|
-
return ref;
|
|
8001
|
-
}
|
|
8002
|
-
|
|
8003
|
-
var useKey = "use";
|
|
8004
|
-
var realHook = React__namespace[useKey];
|
|
8005
|
-
var __use = realHook ||
|
|
8006
|
-
function __use(promise) {
|
|
8007
|
-
var statefulPromise = wrapPromiseWithState(promise);
|
|
8008
|
-
switch (statefulPromise.status) {
|
|
8009
|
-
case "pending":
|
|
8010
|
-
throw statefulPromise;
|
|
8011
|
-
case "rejected":
|
|
8012
|
-
throw statefulPromise.reason;
|
|
8013
|
-
case "fulfilled":
|
|
8014
|
-
return statefulPromise.value;
|
|
8015
|
-
}
|
|
8016
|
-
};
|
|
8017
|
-
|
|
8018
8036
|
function useFragment(options) {
|
|
8037
|
+
return wrapHook("useFragment", _useFragment, useApolloClient(options.client))(options);
|
|
8038
|
+
}
|
|
8039
|
+
function _useFragment(options) {
|
|
8019
8040
|
var cache = useApolloClient(options.client).cache;
|
|
8020
8041
|
var diffOptions = useDeepMemo(function () {
|
|
8021
8042
|
var fragment = options.fragment, fragmentName = options.fragmentName, from = options.from, _a = options.optimistic, optimistic = _a === void 0 ? true : _a, rest = tslib.__rest(options, ["fragment", "fragmentName", "from", "optimistic"]);
|
|
@@ -8252,11 +8273,13 @@ var InternalQueryReference = (function () {
|
|
|
8252
8273
|
this.promise.catch(function () { });
|
|
8253
8274
|
returnedPromise
|
|
8254
8275
|
.then(function (result) {
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
_this.
|
|
8258
|
-
|
|
8259
|
-
|
|
8276
|
+
setTimeout(function () {
|
|
8277
|
+
var _a;
|
|
8278
|
+
if (_this.promise.status === "pending") {
|
|
8279
|
+
_this.result = result;
|
|
8280
|
+
(_a = _this.resolve) === null || _a === void 0 ? void 0 : _a.call(_this, result);
|
|
8281
|
+
}
|
|
8282
|
+
});
|
|
8260
8283
|
})
|
|
8261
8284
|
.catch(function () { });
|
|
8262
8285
|
return returnedPromise;
|
|
@@ -8323,6 +8346,9 @@ var skipToken = Symbol.for("apollo.skipToken");
|
|
|
8323
8346
|
|
|
8324
8347
|
function useSuspenseQuery(query, options) {
|
|
8325
8348
|
if (options === void 0) { options = Object.create(null); }
|
|
8349
|
+
return wrapHook("useSuspenseQuery", _useSuspenseQuery, useApolloClient(typeof options === "object" ? options.client : undefined))(query, options);
|
|
8350
|
+
}
|
|
8351
|
+
function _useSuspenseQuery(query, options) {
|
|
8326
8352
|
var client = useApolloClient(options.client);
|
|
8327
8353
|
var suspenseCache = getSuspenseCache(client);
|
|
8328
8354
|
var watchQueryOptions = useWatchQueryOptions({
|
|
@@ -8440,6 +8466,9 @@ function useWatchQueryOptions(_a) {
|
|
|
8440
8466
|
|
|
8441
8467
|
function useBackgroundQuery(query, options) {
|
|
8442
8468
|
if (options === void 0) { options = Object.create(null); }
|
|
8469
|
+
return wrapHook("useBackgroundQuery", _useBackgroundQuery, useApolloClient(typeof options === "object" ? options.client : undefined))(query, options);
|
|
8470
|
+
}
|
|
8471
|
+
function _useBackgroundQuery(query, options) {
|
|
8443
8472
|
var client = useApolloClient(options.client);
|
|
8444
8473
|
var suspenseCache = getSuspenseCache(client);
|
|
8445
8474
|
var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
|
|
@@ -8554,6 +8583,9 @@ function useQueryRefHandlers(queryRef) {
|
|
|
8554
8583
|
}
|
|
8555
8584
|
|
|
8556
8585
|
function useReadQuery(queryRef) {
|
|
8586
|
+
return wrapHook("useReadQuery", _useReadQuery, unwrapQueryRef(queryRef)["observable"])(queryRef);
|
|
8587
|
+
}
|
|
8588
|
+
function _useReadQuery(queryRef) {
|
|
8557
8589
|
var internalQueryRef = React__namespace.useMemo(function () { return unwrapQueryRef(queryRef); }, [queryRef]);
|
|
8558
8590
|
var getPromise = React__namespace.useCallback(function () { return getWrappedPromise(queryRef); }, [queryRef]);
|
|
8559
8591
|
if (internalQueryRef.disposed) {
|