@apollo/client 3.11.5 → 3.11.7
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 +14 -0
- package/apollo-client.cjs +18 -14
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +4 -1
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +4 -1
- package/cache/core/cache.js +10 -1
- package/cache/core/cache.js.map +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,19 @@
|
|
|
1
1
|
# @apollo/client
|
|
2
2
|
|
|
3
|
+
## 3.11.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#12052](https://github.com/apollographql/apollo-client/pull/12052) [`e471cef`](https://github.com/apollographql/apollo-client/commit/e471cef875eadef04f8ee18ef431ee70e7b9bcab) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fixes a regression from where passing an invalid identifier to `from` in `useFragment` would result in the warning `TypeError: Cannot read properties of undefined (reading '__typename')`.
|
|
8
|
+
|
|
9
|
+
## 3.11.6
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#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
|
|
14
|
+
|
|
15
|
+
- [#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.
|
|
16
|
+
|
|
3
17
|
## 3.11.5
|
|
4
18
|
|
|
5
19
|
### 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.7";
|
|
35
35
|
|
|
36
36
|
function maybe(thunk) {
|
|
37
37
|
try {
|
|
@@ -2504,7 +2504,10 @@ var ApolloCache = (function () {
|
|
|
2504
2504
|
var _this = this;
|
|
2505
2505
|
var fragment = options.fragment, fragmentName = options.fragmentName, from = options.from, _a = options.optimistic, optimistic = _a === void 0 ? true : _a, otherOptions = tslib.__rest(options, ["fragment", "fragmentName", "from", "optimistic"]);
|
|
2506
2506
|
var query = this.getFragmentDoc(fragment, fragmentName);
|
|
2507
|
-
var diffOptions = tslib.__assign(tslib.__assign({}, otherOptions), { returnPartialData: true, id:
|
|
2507
|
+
var diffOptions = tslib.__assign(tslib.__assign({}, otherOptions), { returnPartialData: true, id:
|
|
2508
|
+
typeof from === "undefined" || typeof from === "string" ?
|
|
2509
|
+
from
|
|
2510
|
+
: this.identify(from), query: query, optimistic: optimistic });
|
|
2508
2511
|
var latestDiff;
|
|
2509
2512
|
return new zenObservableTs.Observable(function (observer) {
|
|
2510
2513
|
return _this.watch(tslib.__assign(tslib.__assign({}, diffOptions), { immediate: true, callback: function (diff) {
|
|
@@ -8136,10 +8139,11 @@ function useSubscription(subscription, options) {
|
|
|
8136
8139
|
observable.__.result
|
|
8137
8140
|
: fallbackResult;
|
|
8138
8141
|
}, function () { return fallbackResult; });
|
|
8139
|
-
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
|
|
8142
|
+
var restart = React__namespace.useCallback(function () {
|
|
8143
|
+
invariant(!optionsRef.current.skip, 57);
|
|
8144
|
+
setObservable(recreateRef.current());
|
|
8145
|
+
}, [optionsRef, recreateRef]);
|
|
8146
|
+
return React__namespace.useMemo(function () { return (tslib.__assign(tslib.__assign({}, ret), { restart: restart })); }, [ret, restart]);
|
|
8143
8147
|
}
|
|
8144
8148
|
function createSubscription(client, query, variables, fetchPolicy, errorPolicy, context, extensions) {
|
|
8145
8149
|
var options = {
|
|
@@ -8186,30 +8190,30 @@ function _useFragment(options) {
|
|
|
8186
8190
|
var cache = useApolloClient(options.client).cache;
|
|
8187
8191
|
var from = options.from, rest = tslib.__rest(options, ["from"]);
|
|
8188
8192
|
var id = React__namespace.useMemo(function () { return (typeof from === "string" ? from : cache.identify(from)); }, [cache, from]);
|
|
8189
|
-
var resultRef = React__namespace.useRef();
|
|
8190
8193
|
var stableOptions = useDeepMemo(function () { return (tslib.__assign(tslib.__assign({}, rest), { from: id })); }, [rest, id]);
|
|
8191
|
-
var
|
|
8194
|
+
var diff = React__namespace.useMemo(function () {
|
|
8192
8195
|
var fragment = stableOptions.fragment, fragmentName = stableOptions.fragmentName, from = stableOptions.from, _a = stableOptions.optimistic, optimistic = _a === void 0 ? true : _a;
|
|
8193
|
-
return
|
|
8196
|
+
return {
|
|
8197
|
+
result: diffToResult(cache.diff(tslib.__assign(tslib.__assign({}, stableOptions), { returnPartialData: true, id: from, query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic }))),
|
|
8198
|
+
};
|
|
8194
8199
|
}, [stableOptions, cache]);
|
|
8195
|
-
var getSnapshot = React__namespace.useCallback(function () { return
|
|
8200
|
+
var getSnapshot = React__namespace.useCallback(function () { return diff.result; }, [diff]);
|
|
8196
8201
|
return useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
|
|
8197
8202
|
var lastTimeout = 0;
|
|
8198
8203
|
var subscription = cache.watchFragment(stableOptions).subscribe({
|
|
8199
8204
|
next: function (result) {
|
|
8200
|
-
if (equal__default(result,
|
|
8205
|
+
if (equal__default(result, diff.result))
|
|
8201
8206
|
return;
|
|
8202
|
-
|
|
8207
|
+
diff.result = result;
|
|
8203
8208
|
clearTimeout(lastTimeout);
|
|
8204
8209
|
lastTimeout = setTimeout(forceUpdate);
|
|
8205
8210
|
},
|
|
8206
8211
|
});
|
|
8207
8212
|
return function () {
|
|
8208
|
-
resultRef.current = void 0;
|
|
8209
8213
|
subscription.unsubscribe();
|
|
8210
8214
|
clearTimeout(lastTimeout);
|
|
8211
8215
|
};
|
|
8212
|
-
}, [cache, stableOptions,
|
|
8216
|
+
}, [cache, stableOptions, diff]), getSnapshot, getSnapshot);
|
|
8213
8217
|
}
|
|
8214
8218
|
function diffToResult(diff) {
|
|
8215
8219
|
var result = {
|