@apollo/client 3.11.5 → 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 +8 -0
- package/apollo-client.cjs +14 -13
- 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 +1 -1
- package/react/hooks/hooks.cjs +13 -12
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +13 -12
- package/react/hooks/useFragment.js +9 -9
- 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/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.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
|
+
|
|
3
11
|
## 3.11.5
|
|
4
12
|
|
|
5
13
|
### 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 {
|
|
@@ -8136,10 +8136,11 @@ function useSubscription(subscription, options) {
|
|
|
8136
8136
|
observable.__.result
|
|
8137
8137
|
: fallbackResult;
|
|
8138
8138
|
}, function () { return fallbackResult; });
|
|
8139
|
-
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
|
|
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]);
|
|
8143
8144
|
}
|
|
8144
8145
|
function createSubscription(client, query, variables, fetchPolicy, errorPolicy, context, extensions) {
|
|
8145
8146
|
var options = {
|
|
@@ -8186,30 +8187,30 @@ function _useFragment(options) {
|
|
|
8186
8187
|
var cache = useApolloClient(options.client).cache;
|
|
8187
8188
|
var from = options.from, rest = tslib.__rest(options, ["from"]);
|
|
8188
8189
|
var id = React__namespace.useMemo(function () { return (typeof from === "string" ? from : cache.identify(from)); }, [cache, from]);
|
|
8189
|
-
var resultRef = React__namespace.useRef();
|
|
8190
8190
|
var stableOptions = useDeepMemo(function () { return (tslib.__assign(tslib.__assign({}, rest), { from: id })); }, [rest, id]);
|
|
8191
|
-
var
|
|
8191
|
+
var diff = React__namespace.useMemo(function () {
|
|
8192
8192
|
var fragment = stableOptions.fragment, fragmentName = stableOptions.fragmentName, from = stableOptions.from, _a = stableOptions.optimistic, optimistic = _a === void 0 ? true : _a;
|
|
8193
|
-
return
|
|
8193
|
+
return {
|
|
8194
|
+
result: diffToResult(cache.diff(tslib.__assign(tslib.__assign({}, stableOptions), { returnPartialData: true, id: from, query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic }))),
|
|
8195
|
+
};
|
|
8194
8196
|
}, [stableOptions, cache]);
|
|
8195
|
-
var getSnapshot = React__namespace.useCallback(function () { return
|
|
8197
|
+
var getSnapshot = React__namespace.useCallback(function () { return diff.result; }, [diff]);
|
|
8196
8198
|
return useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
|
|
8197
8199
|
var lastTimeout = 0;
|
|
8198
8200
|
var subscription = cache.watchFragment(stableOptions).subscribe({
|
|
8199
8201
|
next: function (result) {
|
|
8200
|
-
if (equal__default(result,
|
|
8202
|
+
if (equal__default(result, diff.result))
|
|
8201
8203
|
return;
|
|
8202
|
-
|
|
8204
|
+
diff.result = result;
|
|
8203
8205
|
clearTimeout(lastTimeout);
|
|
8204
8206
|
lastTimeout = setTimeout(forceUpdate);
|
|
8205
8207
|
},
|
|
8206
8208
|
});
|
|
8207
8209
|
return function () {
|
|
8208
|
-
resultRef.current = void 0;
|
|
8209
8210
|
subscription.unsubscribe();
|
|
8210
8211
|
clearTimeout(lastTimeout);
|
|
8211
8212
|
};
|
|
8212
|
-
}, [cache, stableOptions,
|
|
8213
|
+
}, [cache, stableOptions, diff]), getSnapshot, getSnapshot);
|
|
8213
8214
|
}
|
|
8214
8215
|
function diffToResult(diff) {
|
|
8215
8216
|
var result = {
|