@apollo/client 3.11.4 → 3.11.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 +8 -0
- package/apollo-client.cjs +13 -24
- 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 +12 -23
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +12 -23
- 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 +21 -15
- package/react/hooks/useFragment.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,13 @@
|
|
|
1
1
|
# @apollo/client
|
|
2
2
|
|
|
3
|
+
## 3.11.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#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
|
|
8
|
+
|
|
9
|
+
- [#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`.
|
|
10
|
+
|
|
3
11
|
## 3.11.4
|
|
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.5";
|
|
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 ||
|
|
@@ -8193,23 +8184,20 @@ function useFragment(options) {
|
|
|
8193
8184
|
}
|
|
8194
8185
|
function _useFragment(options) {
|
|
8195
8186
|
var cache = useApolloClient(options.client).cache;
|
|
8196
|
-
var
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
}, [
|
|
8200
|
-
var
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
React__namespace.
|
|
8205
|
-
resultRef.current = diffToResult(cache.diff(diffOptions));
|
|
8206
|
-
}, [diffOptions, cache]);
|
|
8207
|
-
var getSnapshot = React__namespace.useCallback(function () { return resultRef.current; }, []);
|
|
8187
|
+
var from = options.from, rest = tslib.__rest(options, ["from"]);
|
|
8188
|
+
var id = React__namespace.useMemo(function () { return (typeof from === "string" ? from : cache.identify(from)); }, [cache, from]);
|
|
8189
|
+
var resultRef = React__namespace.useRef();
|
|
8190
|
+
var stableOptions = useDeepMemo(function () { return (tslib.__assign(tslib.__assign({}, rest), { from: id })); }, [rest, id]);
|
|
8191
|
+
var currentDiff = 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 diffToResult(cache.diff(tslib.__assign(tslib.__assign({}, stableOptions), { returnPartialData: true, id: from, query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic })));
|
|
8194
|
+
}, [stableOptions, cache]);
|
|
8195
|
+
var getSnapshot = React__namespace.useCallback(function () { return resultRef.current || currentDiff; }, [currentDiff]);
|
|
8208
8196
|
return useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
|
|
8209
8197
|
var lastTimeout = 0;
|
|
8210
8198
|
var subscription = cache.watchFragment(stableOptions).subscribe({
|
|
8211
8199
|
next: function (result) {
|
|
8212
|
-
if (equal__default(result,
|
|
8200
|
+
if (equal__default(result, currentDiff))
|
|
8213
8201
|
return;
|
|
8214
8202
|
resultRef.current = result;
|
|
8215
8203
|
clearTimeout(lastTimeout);
|
|
@@ -8217,10 +8205,11 @@ function _useFragment(options) {
|
|
|
8217
8205
|
},
|
|
8218
8206
|
});
|
|
8219
8207
|
return function () {
|
|
8208
|
+
resultRef.current = void 0;
|
|
8220
8209
|
subscription.unsubscribe();
|
|
8221
8210
|
clearTimeout(lastTimeout);
|
|
8222
8211
|
};
|
|
8223
|
-
}, [cache, stableOptions]), getSnapshot, getSnapshot);
|
|
8212
|
+
}, [cache, stableOptions, currentDiff]), getSnapshot, getSnapshot);
|
|
8224
8213
|
}
|
|
8225
8214
|
function diffToResult(diff) {
|
|
8226
8215
|
var result = {
|