@apollo/client 3.11.4 → 3.11.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 +16 -0
- package/apollo-client.cjs +19 -29
- 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 +4 -4
- package/react/hooks/hooks.cjs +18 -28
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +18 -28
- package/react/hooks/internal/index.d.ts +0 -1
- package/react/hooks/internal/index.js +0 -1
- package/react/hooks/internal/index.js.map +1 -1
- package/react/hooks/useFragment.js +22 -16
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +1 -1
- package/react/hooks/useSubscription.js +5 -4
- package/react/hooks/useSubscription.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/react/types/types.d.ts +1 -1
- package/react/types/types.js.map +1 -1
- package/utilities/caching/sizes.d.ts +2 -2
- package/utilities/caching/sizes.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/react/hooks/internal/useLazyRef.d.ts +0 -3
- package/react/hooks/internal/useLazyRef.js +0 -10
- package/react/hooks/internal/useLazyRef.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @apollo/client
|
|
2
2
|
|
|
3
|
+
## 3.11.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#12049](https://github.com/apollographql/apollo-client/pull/12049) [`9c26892`](https://github.com/apollographql/apollo-client/commit/9c268927b1f8e5921b9440a53c9979a37f594e75) Thanks [@phryneas](https://github.com/phryneas) and [@maciesielka](https://github.com/maciesielka)! - Fix a bug where `useFragment` did not re-render as expected
|
|
8
|
+
|
|
9
|
+
- [#12044](https://github.com/apollographql/apollo-client/pull/12044) [`04462a2`](https://github.com/apollographql/apollo-client/commit/04462a274ad39b392142385a2f052abbf3014749) Thanks [@DoctorJohn](https://github.com/DoctorJohn)! - Cache the `useSubscription` hook's `restart` function definition between re-renders.
|
|
10
|
+
|
|
11
|
+
## 3.11.5
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#12027](https://github.com/apollographql/apollo-client/pull/12027) [`eb3e21b`](https://github.com/apollographql/apollo-client/commit/eb3e21b9f7fa6a3161705c2c7270129c17b65095) Thanks [@JavaScriptBach](https://github.com/JavaScriptBach)! - Type `MutationResult.reset` as an arrow function
|
|
16
|
+
|
|
17
|
+
- [#12020](https://github.com/apollographql/apollo-client/pull/12020) [`82d8cb4`](https://github.com/apollographql/apollo-client/commit/82d8cb4255be497748829f12eb25ac87c11ee5e4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Better conform to Rules of React by avoiding write of ref in render for `useFragment`.
|
|
18
|
+
|
|
3
19
|
## 3.11.4
|
|
4
20
|
|
|
5
21
|
### 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.11.
|
|
34
|
+
var version = "3.11.6";
|
|
35
35
|
|
|
36
36
|
function maybe(thunk) {
|
|
37
37
|
try {
|
|
@@ -7481,15 +7481,6 @@ function useRenderGuard() {
|
|
|
7481
7481
|
}, []);
|
|
7482
7482
|
}
|
|
7483
7483
|
|
|
7484
|
-
var INIT = {};
|
|
7485
|
-
function useLazyRef(getInitialValue) {
|
|
7486
|
-
var ref = React__namespace.useRef(INIT);
|
|
7487
|
-
if (ref.current === INIT) {
|
|
7488
|
-
ref.current = getInitialValue();
|
|
7489
|
-
}
|
|
7490
|
-
return ref;
|
|
7491
|
-
}
|
|
7492
|
-
|
|
7493
7484
|
var useKey = "use";
|
|
7494
7485
|
var realHook = React__namespace[useKey];
|
|
7495
7486
|
var __use = realHook ||
|
|
@@ -8145,10 +8136,11 @@ function useSubscription(subscription, options) {
|
|
|
8145
8136
|
observable.__.result
|
|
8146
8137
|
: fallbackResult;
|
|
8147
8138
|
}, function () { return fallbackResult; });
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
|
|
8139
|
+
var restart = React__namespace.useCallback(function () {
|
|
8140
|
+
invariant(!optionsRef.current.skip, 57);
|
|
8141
|
+
setObservable(recreateRef.current());
|
|
8142
|
+
}, [optionsRef, recreateRef]);
|
|
8143
|
+
return React__namespace.useMemo(function () { return (tslib.__assign(tslib.__assign({}, ret), { restart: restart })); }, [ret, restart]);
|
|
8152
8144
|
}
|
|
8153
8145
|
function createSubscription(client, query, variables, fetchPolicy, errorPolicy, context, extensions) {
|
|
8154
8146
|
var options = {
|
|
@@ -8193,25 +8185,23 @@ function useFragment(options) {
|
|
|
8193
8185
|
}
|
|
8194
8186
|
function _useFragment(options) {
|
|
8195
8187
|
var cache = useApolloClient(options.client).cache;
|
|
8196
|
-
var
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
return
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
}, [diffOptions, cache]);
|
|
8207
|
-
var getSnapshot = React__namespace.useCallback(function () { return resultRef.current; }, []);
|
|
8188
|
+
var from = options.from, rest = tslib.__rest(options, ["from"]);
|
|
8189
|
+
var id = React__namespace.useMemo(function () { return (typeof from === "string" ? from : cache.identify(from)); }, [cache, from]);
|
|
8190
|
+
var stableOptions = useDeepMemo(function () { return (tslib.__assign(tslib.__assign({}, rest), { from: id })); }, [rest, id]);
|
|
8191
|
+
var diff = React__namespace.useMemo(function () {
|
|
8192
|
+
var fragment = stableOptions.fragment, fragmentName = stableOptions.fragmentName, from = stableOptions.from, _a = stableOptions.optimistic, optimistic = _a === void 0 ? true : _a;
|
|
8193
|
+
return {
|
|
8194
|
+
result: diffToResult(cache.diff(tslib.__assign(tslib.__assign({}, stableOptions), { returnPartialData: true, id: from, query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic }))),
|
|
8195
|
+
};
|
|
8196
|
+
}, [stableOptions, cache]);
|
|
8197
|
+
var getSnapshot = React__namespace.useCallback(function () { return diff.result; }, [diff]);
|
|
8208
8198
|
return useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
|
|
8209
8199
|
var lastTimeout = 0;
|
|
8210
8200
|
var subscription = cache.watchFragment(stableOptions).subscribe({
|
|
8211
8201
|
next: function (result) {
|
|
8212
|
-
if (equal__default(result,
|
|
8202
|
+
if (equal__default(result, diff.result))
|
|
8213
8203
|
return;
|
|
8214
|
-
|
|
8204
|
+
diff.result = result;
|
|
8215
8205
|
clearTimeout(lastTimeout);
|
|
8216
8206
|
lastTimeout = setTimeout(forceUpdate);
|
|
8217
8207
|
},
|
|
@@ -8220,7 +8210,7 @@ function _useFragment(options) {
|
|
|
8220
8210
|
subscription.unsubscribe();
|
|
8221
8211
|
clearTimeout(lastTimeout);
|
|
8222
8212
|
};
|
|
8223
|
-
}, [cache, stableOptions]), getSnapshot, getSnapshot);
|
|
8213
|
+
}, [cache, stableOptions, diff]), getSnapshot, getSnapshot);
|
|
8224
8214
|
}
|
|
8225
8215
|
function diffToResult(diff) {
|
|
8226
8216
|
var result = {
|