@apollo/client 3.9.5 → 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 +27 -19
- package/apollo-client.cjs +75 -50
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +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 +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/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,13 @@
|
|
|
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
|
+
|
|
3
11
|
## 3.9.5
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -127,6 +135,25 @@
|
|
|
127
135
|
|
|
128
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.
|
|
129
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
|
+
|
|
130
157
|
#### Testing utility improvements
|
|
131
158
|
|
|
132
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
|
|
@@ -193,25 +220,6 @@
|
|
|
193
220
|
|
|
194
221
|
The `IGNORE` sentinel can be destructured from the second parameter in the callback function signature passed to `optimisticResponse`.
|
|
195
222
|
|
|
196
|
-
```tsx
|
|
197
|
-
const preloadQuery = createQueryPreloader(client);
|
|
198
|
-
const queryRef = preloadQuery(QUERY, { variables, ...otherOptions });
|
|
199
|
-
|
|
200
|
-
function App() {
|
|
201
|
-
return {
|
|
202
|
-
<Suspense fallback={<div>Loading</div>}>
|
|
203
|
-
<MyQuery />
|
|
204
|
-
</Suspense>
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function MyQuery() {
|
|
209
|
-
const { data } = useReadQuery(queryRef);
|
|
210
|
-
|
|
211
|
-
// do something with data
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
|
|
215
223
|
#### Network adapters for multipart subscriptions usage with Relay and urql
|
|
216
224
|
|
|
217
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 {
|
|
@@ -7371,9 +7371,64 @@ function verifyDocumentType(document, type) {
|
|
|
7371
7371
|
);
|
|
7372
7372
|
}
|
|
7373
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
|
+
|
|
7374
7426
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
7375
7427
|
function useQuery(query, options) {
|
|
7376
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) {
|
|
7377
7432
|
return useInternalState(useApolloClient(options.client), query).useQuery(options);
|
|
7378
7433
|
}
|
|
7379
7434
|
function useInternalState(client, query) {
|
|
@@ -7978,51 +8033,10 @@ function useReactiveVar(rv) {
|
|
|
7978
8033
|
}, [rv]), rv, rv);
|
|
7979
8034
|
}
|
|
7980
8035
|
|
|
7981
|
-
function useDeepMemo(memoFn, deps) {
|
|
7982
|
-
var ref = React__namespace.useRef();
|
|
7983
|
-
if (!ref.current || !equal.equal(ref.current.deps, deps)) {
|
|
7984
|
-
ref.current = { value: memoFn(), deps: deps };
|
|
7985
|
-
}
|
|
7986
|
-
return ref.current.value;
|
|
7987
|
-
}
|
|
7988
|
-
|
|
7989
|
-
function getRenderDispatcher() {
|
|
7990
|
-
var _a, _b;
|
|
7991
|
-
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;
|
|
7992
|
-
}
|
|
7993
|
-
var RenderDispatcher = null;
|
|
7994
|
-
function useRenderGuard() {
|
|
7995
|
-
RenderDispatcher = getRenderDispatcher();
|
|
7996
|
-
return React__namespace.useCallback(function () {
|
|
7997
|
-
return (RenderDispatcher !== null && RenderDispatcher === getRenderDispatcher());
|
|
7998
|
-
}, []);
|
|
7999
|
-
}
|
|
8000
|
-
|
|
8001
|
-
var INIT = {};
|
|
8002
|
-
function useLazyRef(getInitialValue) {
|
|
8003
|
-
var ref = React__namespace.useRef(INIT);
|
|
8004
|
-
if (ref.current === INIT) {
|
|
8005
|
-
ref.current = getInitialValue();
|
|
8006
|
-
}
|
|
8007
|
-
return ref;
|
|
8008
|
-
}
|
|
8009
|
-
|
|
8010
|
-
var useKey = "use";
|
|
8011
|
-
var realHook = React__namespace[useKey];
|
|
8012
|
-
var __use = realHook ||
|
|
8013
|
-
function __use(promise) {
|
|
8014
|
-
var statefulPromise = wrapPromiseWithState(promise);
|
|
8015
|
-
switch (statefulPromise.status) {
|
|
8016
|
-
case "pending":
|
|
8017
|
-
throw statefulPromise;
|
|
8018
|
-
case "rejected":
|
|
8019
|
-
throw statefulPromise.reason;
|
|
8020
|
-
case "fulfilled":
|
|
8021
|
-
return statefulPromise.value;
|
|
8022
|
-
}
|
|
8023
|
-
};
|
|
8024
|
-
|
|
8025
8036
|
function useFragment(options) {
|
|
8037
|
+
return wrapHook("useFragment", _useFragment, useApolloClient(options.client))(options);
|
|
8038
|
+
}
|
|
8039
|
+
function _useFragment(options) {
|
|
8026
8040
|
var cache = useApolloClient(options.client).cache;
|
|
8027
8041
|
var diffOptions = useDeepMemo(function () {
|
|
8028
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"]);
|
|
@@ -8259,11 +8273,13 @@ var InternalQueryReference = (function () {
|
|
|
8259
8273
|
this.promise.catch(function () { });
|
|
8260
8274
|
returnedPromise
|
|
8261
8275
|
.then(function (result) {
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
_this.
|
|
8265
|
-
|
|
8266
|
-
|
|
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
|
+
});
|
|
8267
8283
|
})
|
|
8268
8284
|
.catch(function () { });
|
|
8269
8285
|
return returnedPromise;
|
|
@@ -8330,6 +8346,9 @@ var skipToken = Symbol.for("apollo.skipToken");
|
|
|
8330
8346
|
|
|
8331
8347
|
function useSuspenseQuery(query, options) {
|
|
8332
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) {
|
|
8333
8352
|
var client = useApolloClient(options.client);
|
|
8334
8353
|
var suspenseCache = getSuspenseCache(client);
|
|
8335
8354
|
var watchQueryOptions = useWatchQueryOptions({
|
|
@@ -8447,6 +8466,9 @@ function useWatchQueryOptions(_a) {
|
|
|
8447
8466
|
|
|
8448
8467
|
function useBackgroundQuery(query, options) {
|
|
8449
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) {
|
|
8450
8472
|
var client = useApolloClient(options.client);
|
|
8451
8473
|
var suspenseCache = getSuspenseCache(client);
|
|
8452
8474
|
var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
|
|
@@ -8561,6 +8583,9 @@ function useQueryRefHandlers(queryRef) {
|
|
|
8561
8583
|
}
|
|
8562
8584
|
|
|
8563
8585
|
function useReadQuery(queryRef) {
|
|
8586
|
+
return wrapHook("useReadQuery", _useReadQuery, unwrapQueryRef(queryRef)["observable"])(queryRef);
|
|
8587
|
+
}
|
|
8588
|
+
function _useReadQuery(queryRef) {
|
|
8564
8589
|
var internalQueryRef = React__namespace.useMemo(function () { return unwrapQueryRef(queryRef); }, [queryRef]);
|
|
8565
8590
|
var getPromise = React__namespace.useCallback(function () { return getWrappedPromise(queryRef); }, [queryRef]);
|
|
8566
8591
|
if (internalQueryRef.disposed) {
|