@apollo/client 3.10.4 → 3.10.5
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 +25 -0
- package/apollo-client.cjs +61 -36
- 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/link/batch-http/batch-http.cjs +6 -5
- package/link/batch-http/batch-http.cjs.map +1 -1
- package/link/batch-http/batch-http.cjs.native.js +6 -5
- package/link/batch-http/batchHttpLink.js +15 -10
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/error/error.cjs +3 -2
- package/link/error/error.cjs.map +1 -1
- package/link/error/error.cjs.native.js +3 -2
- package/link/error/index.js +3 -2
- package/link/error/index.js.map +1 -1
- package/package.json +10 -6
- package/react/hooks/hooks.cjs +59 -34
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +59 -34
- package/react/hooks/internal/useRenderGuard.js +37 -12
- package/react/hooks/internal/useRenderGuard.js.map +1 -1
- package/react/hooks/useLazyQuery.js +7 -8
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +1 -1
- package/react/hooks/useLoadableQuery.js +9 -2
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.js +10 -7
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +2 -2
- package/react/hooks/useQuery.js +26 -12
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.js +4 -0
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReadQuery.js +5 -1
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.js +4 -0
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +2 -2
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +4 -0
- package/react/hooks/useSyncExternalStore.js.map +1 -1
- package/react/internal/internal.cjs +1 -1
- package/react/internal/internal.cjs.map +1 -1
- package/react/internal/internal.cjs.native.js +1 -1
- package/testing/core/mocking/mockLink.d.ts +8 -3
- package/testing/core/mocking/mockLink.js.map +1 -1
- 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/version.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @apollo/client
|
|
2
2
|
|
|
3
|
+
## 3.10.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#11888](https://github.com/apollographql/apollo-client/pull/11888) [`7fb7939`](https://github.com/apollographql/apollo-client/commit/7fb7939edb7ca8f4273b75554f96ea9936731458) Thanks [@phryneas](https://github.com/phryneas)! - switch `useRenderGuard` to an approach not accessing React's internals
|
|
8
|
+
|
|
9
|
+
- [#11511](https://github.com/apollographql/apollo-client/pull/11511) [`6536369`](https://github.com/apollographql/apollo-client/commit/6536369cf213469d20d15b779c344268d70fecd5) Thanks [@phryneas](https://github.com/phryneas)! - `useLoadableQuery`: ensure that `loadQuery` is updated if the ApolloClient instance changes
|
|
10
|
+
|
|
11
|
+
- [#11860](https://github.com/apollographql/apollo-client/pull/11860) [`8740f19`](https://github.com/apollographql/apollo-client/commit/8740f198805a99e01136617c4055d611b92cc231) Thanks [@alessbell](https://github.com/alessbell)! - Fixes [#11849](https://github.com/apollographql/apollo-client/issues/11849) by reevaluating `window.fetch` each time `BatchHttpLink` uses it, if not configured via `options.fetch`. Takes the same approach as PR [#8603](https://github.com/apollographql/apollo-client/pull/8603) which fixed the same issue in `HttpLink`.
|
|
12
|
+
|
|
13
|
+
- [#11852](https://github.com/apollographql/apollo-client/pull/11852) [`d502a69`](https://github.com/apollographql/apollo-client/commit/d502a69654d8ffa31e09467da028304a934a9874) Thanks [@phryneas](https://github.com/phryneas)! - Fix a bug where calling the `useMutation` `reset` function would point the hook to an outdated `client` reference.
|
|
14
|
+
|
|
15
|
+
- [#11329](https://github.com/apollographql/apollo-client/pull/11329) [`3d164ea`](https://github.com/apollographql/apollo-client/commit/3d164ea16c17d271f6fa9e5ad8f013623eec23a0) Thanks [@PaLy](https://github.com/PaLy)! - Fix graphQLErrors in Error Link if networkError.result is an empty string
|
|
16
|
+
|
|
17
|
+
- [#11852](https://github.com/apollographql/apollo-client/pull/11852) [`d502a69`](https://github.com/apollographql/apollo-client/commit/d502a69654d8ffa31e09467da028304a934a9874) Thanks [@phryneas](https://github.com/phryneas)! - Prevent writing to a ref in render in `useMutation`.
|
|
18
|
+
As a result, you might encounter problems in the future if you call the mutation's `execute` function during render. Please note that this was never supported behavior, and we strongly recommend against it.
|
|
19
|
+
|
|
20
|
+
- [#11848](https://github.com/apollographql/apollo-client/pull/11848) [`ad63924`](https://github.com/apollographql/apollo-client/commit/ad6392424ddbeb6f91b165c806251490e1cdd69e) Thanks [@phryneas](https://github.com/phryneas)! - Ensure covariant behavior: `MockedResponse<X,Y>` should be assignable to `MockedResponse`
|
|
21
|
+
|
|
22
|
+
- [#11851](https://github.com/apollographql/apollo-client/pull/11851) [`45c47be`](https://github.com/apollographql/apollo-client/commit/45c47be26d4e020cfcff359a5af19ccfc39b930e) Thanks [@phryneas](https://github.com/phryneas)! - Avoid usage of useRef in useInternalState to prevent ref access in render.
|
|
23
|
+
|
|
24
|
+
- [#11877](https://github.com/apollographql/apollo-client/pull/11877) [`634d91a`](https://github.com/apollographql/apollo-client/commit/634d91aeb10ab308b05d5ffb918678806046af09) Thanks [@phryneas](https://github.com/phryneas)! - Add missing name to tuple member (fix TS5084)
|
|
25
|
+
|
|
26
|
+
- [#11851](https://github.com/apollographql/apollo-client/pull/11851) [`45c47be`](https://github.com/apollographql/apollo-client/commit/45c47be26d4e020cfcff359a5af19ccfc39b930e) Thanks [@phryneas](https://github.com/phryneas)! - Fix a bug where `useLazyQuery` would not pick up a client change.
|
|
27
|
+
|
|
3
28
|
## 3.10.4
|
|
4
29
|
|
|
5
30
|
### 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.
|
|
34
|
+
var version = "3.10.5";
|
|
35
35
|
|
|
36
36
|
function maybe(thunk) {
|
|
37
37
|
try {
|
|
@@ -7421,15 +7421,26 @@ function useDeepMemo(memoFn, deps) {
|
|
|
7421
7421
|
return ref.current.value;
|
|
7422
7422
|
}
|
|
7423
7423
|
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
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;
|
|
7427
|
-
}
|
|
7428
|
-
var RenderDispatcher = null;
|
|
7424
|
+
var Ctx;
|
|
7425
|
+
function noop() { }
|
|
7429
7426
|
function useRenderGuard() {
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7427
|
+
if (!Ctx) {
|
|
7428
|
+
Ctx = React__namespace.createContext(null);
|
|
7429
|
+
}
|
|
7430
|
+
return React__namespace.useCallback(
|
|
7431
|
+
function () {
|
|
7432
|
+
var orig = console.error;
|
|
7433
|
+
try {
|
|
7434
|
+
console.error = noop;
|
|
7435
|
+
React__namespace["useContext" ](Ctx);
|
|
7436
|
+
return true;
|
|
7437
|
+
}
|
|
7438
|
+
catch (e) {
|
|
7439
|
+
return false;
|
|
7440
|
+
}
|
|
7441
|
+
finally {
|
|
7442
|
+
console.error = orig;
|
|
7443
|
+
}
|
|
7433
7444
|
}, []);
|
|
7434
7445
|
}
|
|
7435
7446
|
|
|
@@ -7474,14 +7485,16 @@ function _useQuery(query, options) {
|
|
|
7474
7485
|
return useInternalState(useApolloClient(options.client), query).useQuery(options);
|
|
7475
7486
|
}
|
|
7476
7487
|
function useInternalState(client, query) {
|
|
7477
|
-
var
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
}
|
|
7483
|
-
var state =
|
|
7484
|
-
|
|
7488
|
+
var forceUpdateState = React__namespace.useReducer(function (tick) { return tick + 1; }, 0)[1];
|
|
7489
|
+
function createInternalState(previous) {
|
|
7490
|
+
return Object.assign(new InternalState(client, query, previous), {
|
|
7491
|
+
forceUpdateState: forceUpdateState,
|
|
7492
|
+
});
|
|
7493
|
+
}
|
|
7494
|
+
var _a = React__namespace.useState(createInternalState), state = _a[0], updateState = _a[1];
|
|
7495
|
+
if (client !== state.client || query !== state.query) {
|
|
7496
|
+
updateState((state = createInternalState(state)));
|
|
7497
|
+
}
|
|
7485
7498
|
return state;
|
|
7486
7499
|
}
|
|
7487
7500
|
var InternalState = (function () {
|
|
@@ -7544,7 +7557,8 @@ var InternalState = (function () {
|
|
|
7544
7557
|
this.renderPromises = React__namespace.useContext(getApolloContext()).renderPromises;
|
|
7545
7558
|
this.useOptions(options);
|
|
7546
7559
|
var obsQuery = this.useObservableQuery();
|
|
7547
|
-
var result = useSyncExternalStore(
|
|
7560
|
+
var result = useSyncExternalStore(
|
|
7561
|
+
React__namespace.useCallback(function (handleStoreChange) {
|
|
7548
7562
|
if (_this.renderPromises) {
|
|
7549
7563
|
return function () { };
|
|
7550
7564
|
}
|
|
@@ -7779,17 +7793,15 @@ function useLazyQuery(query, options) {
|
|
|
7779
7793
|
var useQueryResult = internalState.useQuery(tslib.__assign(tslib.__assign({}, merged), { skip: !execOptionsRef.current }));
|
|
7780
7794
|
var initialFetchPolicy = useQueryResult.observable.options.initialFetchPolicy ||
|
|
7781
7795
|
internalState.getDefaultFetchPolicy();
|
|
7782
|
-
var
|
|
7783
|
-
called: !!execOptionsRef.current,
|
|
7784
|
-
});
|
|
7796
|
+
var forceUpdateState = internalState.forceUpdateState, obsQueryFields = internalState.obsQueryFields;
|
|
7785
7797
|
var eagerMethods = React__namespace.useMemo(function () {
|
|
7786
7798
|
var eagerMethods = {};
|
|
7787
7799
|
var _loop_1 = function (key) {
|
|
7788
|
-
var method =
|
|
7800
|
+
var method = obsQueryFields[key];
|
|
7789
7801
|
eagerMethods[key] = function () {
|
|
7790
7802
|
if (!execOptionsRef.current) {
|
|
7791
7803
|
execOptionsRef.current = Object.create(null);
|
|
7792
|
-
|
|
7804
|
+
forceUpdateState();
|
|
7793
7805
|
}
|
|
7794
7806
|
return method.apply(this, arguments);
|
|
7795
7807
|
};
|
|
@@ -7799,8 +7811,9 @@ function useLazyQuery(query, options) {
|
|
|
7799
7811
|
_loop_1(key);
|
|
7800
7812
|
}
|
|
7801
7813
|
return eagerMethods;
|
|
7802
|
-
}, []);
|
|
7803
|
-
|
|
7814
|
+
}, [forceUpdateState, obsQueryFields]);
|
|
7815
|
+
var called = !!execOptionsRef.current;
|
|
7816
|
+
var result = React__namespace.useMemo(function () { return (tslib.__assign(tslib.__assign(tslib.__assign({}, useQueryResult), eagerMethods), { called: called })); }, [useQueryResult, eagerMethods, called]);
|
|
7804
7817
|
var execute = React__namespace.useCallback(function (executeOptions) {
|
|
7805
7818
|
execOptionsRef.current =
|
|
7806
7819
|
executeOptions ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
|
|
@@ -7812,7 +7825,7 @@ function useLazyQuery(query, options) {
|
|
|
7812
7825
|
.then(function (queryResult) { return Object.assign(queryResult, eagerMethods); });
|
|
7813
7826
|
promise.catch(function () { });
|
|
7814
7827
|
return promise;
|
|
7815
|
-
}, []);
|
|
7828
|
+
}, [eagerMethods, initialFetchPolicy, internalState]);
|
|
7816
7829
|
return [execute, result];
|
|
7817
7830
|
}
|
|
7818
7831
|
|
|
@@ -7832,9 +7845,9 @@ function useMutation(mutation, options) {
|
|
|
7832
7845
|
mutation: mutation,
|
|
7833
7846
|
options: options,
|
|
7834
7847
|
});
|
|
7835
|
-
{
|
|
7848
|
+
React__namespace.useLayoutEffect(function () {
|
|
7836
7849
|
Object.assign(ref.current, { client: client, options: options, mutation: mutation });
|
|
7837
|
-
}
|
|
7850
|
+
});
|
|
7838
7851
|
var execute = React__namespace.useCallback(function (executeOptions) {
|
|
7839
7852
|
if (executeOptions === void 0) { executeOptions = {}; }
|
|
7840
7853
|
var _a = ref.current, options = _a.options, mutation = _a.mutation;
|
|
@@ -7908,15 +7921,20 @@ function useMutation(mutation, options) {
|
|
|
7908
7921
|
}, []);
|
|
7909
7922
|
var reset = React__namespace.useCallback(function () {
|
|
7910
7923
|
if (ref.current.isMounted) {
|
|
7911
|
-
var result_3 = {
|
|
7924
|
+
var result_3 = {
|
|
7925
|
+
called: false,
|
|
7926
|
+
loading: false,
|
|
7927
|
+
client: ref.current.client,
|
|
7928
|
+
};
|
|
7912
7929
|
Object.assign(ref.current, { mutationId: 0, result: result_3 });
|
|
7913
7930
|
setResult(result_3);
|
|
7914
7931
|
}
|
|
7915
7932
|
}, []);
|
|
7916
7933
|
React__namespace.useEffect(function () {
|
|
7917
|
-
|
|
7934
|
+
var current = ref.current;
|
|
7935
|
+
current.isMounted = true;
|
|
7918
7936
|
return function () {
|
|
7919
|
-
|
|
7937
|
+
current.isMounted = false;
|
|
7920
7938
|
};
|
|
7921
7939
|
}, []);
|
|
7922
7940
|
return [execute, tslib.__assign({ reset: reset }, result)];
|
|
@@ -8469,11 +8487,11 @@ function _useSuspenseQuery(query, options) {
|
|
|
8469
8487
|
};
|
|
8470
8488
|
}, [queryRef.result]);
|
|
8471
8489
|
var result = fetchPolicy === "standby" ? skipResult : __use(promise);
|
|
8472
|
-
var fetchMore = React__namespace.useCallback(
|
|
8490
|
+
var fetchMore = React__namespace.useCallback(function (options) {
|
|
8473
8491
|
var promise = queryRef.fetchMore(options);
|
|
8474
8492
|
setPromise([queryRef.key, queryRef.promise]);
|
|
8475
8493
|
return promise;
|
|
8476
|
-
}
|
|
8494
|
+
}, [queryRef]);
|
|
8477
8495
|
var refetch = React__namespace.useCallback(function (variables) {
|
|
8478
8496
|
var promise = queryRef.refetch(variables);
|
|
8479
8497
|
setPromise([queryRef.key, queryRef.promise]);
|
|
@@ -8636,10 +8654,17 @@ function useLoadableQuery(query, options) {
|
|
|
8636
8654
|
return client.watchQuery(tslib.__assign(tslib.__assign({}, watchQueryOptions), { variables: variables }));
|
|
8637
8655
|
});
|
|
8638
8656
|
setQueryRef(wrapQueryRef(queryRef));
|
|
8639
|
-
}, [
|
|
8657
|
+
}, [
|
|
8658
|
+
query,
|
|
8659
|
+
queryKey,
|
|
8660
|
+
suspenseCache,
|
|
8661
|
+
watchQueryOptions,
|
|
8662
|
+
calledDuringRender,
|
|
8663
|
+
client,
|
|
8664
|
+
]);
|
|
8640
8665
|
var reset = React__namespace.useCallback(function () {
|
|
8641
8666
|
setQueryRef(null);
|
|
8642
|
-
}, [
|
|
8667
|
+
}, []);
|
|
8643
8668
|
return [loadQuery, queryRef, { fetchMore: fetchMore, refetch: refetch, reset: reset }];
|
|
8644
8669
|
}
|
|
8645
8670
|
|
|
@@ -8694,7 +8719,7 @@ function _useReadQuery(queryRef) {
|
|
|
8694
8719
|
updateWrappedQueryRef(queryRef, promise);
|
|
8695
8720
|
forceUpdate();
|
|
8696
8721
|
});
|
|
8697
|
-
}, [internalQueryRef]), getPromise, getPromise);
|
|
8722
|
+
}, [internalQueryRef, queryRef]), getPromise, getPromise);
|
|
8698
8723
|
var result = __use(promise);
|
|
8699
8724
|
return React__namespace.useMemo(function () {
|
|
8700
8725
|
return {
|