@apollo/client 3.7.0-alpha.6 → 3.7.0-beta.0
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/apollo-client.cjs +45 -3
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +12 -2
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +12 -2
- package/cache/core/types/Cache.d.ts +2 -2
- package/cache/core/types/Cache.d.ts.map +1 -1
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/core/types/common.d.ts +1 -0
- package/cache/core/types/common.d.ts.map +1 -1
- package/cache/core/types/common.js +10 -0
- package/cache/core/types/common.js.map +1 -1
- package/cache/index.d.ts +1 -1
- package/cache/index.d.ts.map +1 -1
- package/cache/index.js.map +1 -1
- package/cache/inmemory/inMemoryCache.js +2 -2
- package/cache/inmemory/inMemoryCache.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/invariantErrorCodes.js +1 -1
- package/package.json +1 -1
- package/react/hooks/hooks.cjs +32 -0
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +32 -0
- package/react/hooks/index.d.ts +1 -0
- package/react/hooks/index.d.ts.map +1 -1
- package/react/hooks/index.js +1 -0
- package/react/hooks/index.js.map +1 -1
- package/react/hooks/useFragment.d.ts +14 -0
- package/react/hooks/useFragment.d.ts.map +1 -0
- package/react/hooks/useFragment.js +37 -0
- package/react/hooks/useFragment.js.map +1 -0
- package/version.js +1 -1
package/apollo-client.cjs
CHANGED
|
@@ -1298,7 +1298,7 @@ var concat = ApolloLink.concat;
|
|
|
1298
1298
|
|
|
1299
1299
|
var execute = ApolloLink.execute;
|
|
1300
1300
|
|
|
1301
|
-
var version = '3.7.0-
|
|
1301
|
+
var version = '3.7.0-beta.0';
|
|
1302
1302
|
|
|
1303
1303
|
var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
1304
1304
|
function parseAndCheckHttpResponse(operations) {
|
|
@@ -1682,10 +1682,20 @@ exports.Cache = void 0;
|
|
|
1682
1682
|
|
|
1683
1683
|
var MissingFieldError = (function () {
|
|
1684
1684
|
function MissingFieldError(message, path, query, variables) {
|
|
1685
|
+
var _a;
|
|
1685
1686
|
this.message = message;
|
|
1686
1687
|
this.path = path;
|
|
1687
1688
|
this.query = query;
|
|
1688
1689
|
this.variables = variables;
|
|
1690
|
+
if (Array.isArray(this.path)) {
|
|
1691
|
+
this.missing = this.message;
|
|
1692
|
+
for (var i = this.path.length - 1; i >= 0; --i) {
|
|
1693
|
+
this.missing = (_a = {}, _a[this.path[i]] = this.missing, _a);
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
else {
|
|
1697
|
+
this.missing = this.path;
|
|
1698
|
+
}
|
|
1689
1699
|
}
|
|
1690
1700
|
return MissingFieldError;
|
|
1691
1701
|
}());
|
|
@@ -3615,8 +3625,8 @@ var InMemoryCache = (function (_super) {
|
|
|
3615
3625
|
makeCacheKey: function (c) {
|
|
3616
3626
|
var store = c.optimistic ? _this.optimisticData : _this.data;
|
|
3617
3627
|
if (supportsResultCaching(store)) {
|
|
3618
|
-
var optimistic = c.optimistic,
|
|
3619
|
-
return store.makeCacheKey(c.query, c.callback, canonicalStringify({ optimistic: optimistic,
|
|
3628
|
+
var optimistic = c.optimistic, id = c.id, variables = c.variables;
|
|
3629
|
+
return store.makeCacheKey(c.query, c.callback, canonicalStringify({ optimistic: optimistic, id: id, variables: variables }));
|
|
3620
3630
|
}
|
|
3621
3631
|
}
|
|
3622
3632
|
});
|
|
@@ -6694,6 +6704,37 @@ function useReactiveVar(rv) {
|
|
|
6694
6704
|
return value;
|
|
6695
6705
|
}
|
|
6696
6706
|
|
|
6707
|
+
function useFragment(options) {
|
|
6708
|
+
var cache = useApolloClient().cache;
|
|
6709
|
+
var fragment = options.fragment, fragmentName = options.fragmentName, from = options.from, _a = options.optimistic, optimistic = _a === void 0 ? true : _a, rest = tslib.__rest(options, ["fragment", "fragmentName", "from", "optimistic"]);
|
|
6710
|
+
var diffOptions = tslib.__assign(tslib.__assign({}, rest), { id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
|
|
6711
|
+
var resultRef = React.useRef();
|
|
6712
|
+
var latestDiff = cache.diff(diffOptions);
|
|
6713
|
+
return useSyncExternalStore(function (forceUpdate) {
|
|
6714
|
+
var immediate = true;
|
|
6715
|
+
return cache.watch(tslib.__assign(tslib.__assign({}, diffOptions), { immediate: immediate, callback: function (diff) {
|
|
6716
|
+
if (!immediate && !equality.equal(diff, latestDiff)) {
|
|
6717
|
+
resultRef.current = diffToResult(latestDiff = diff);
|
|
6718
|
+
forceUpdate();
|
|
6719
|
+
}
|
|
6720
|
+
immediate = false;
|
|
6721
|
+
} }));
|
|
6722
|
+
}, function () {
|
|
6723
|
+
return resultRef.current ||
|
|
6724
|
+
(resultRef.current = diffToResult(latestDiff));
|
|
6725
|
+
});
|
|
6726
|
+
}
|
|
6727
|
+
function diffToResult(diff) {
|
|
6728
|
+
var result = {
|
|
6729
|
+
data: diff.result,
|
|
6730
|
+
complete: !!diff.complete,
|
|
6731
|
+
};
|
|
6732
|
+
if (diff.missing) {
|
|
6733
|
+
result.missing = mergeDeepArray(diff.missing.map(function (error) { return error.missing; }));
|
|
6734
|
+
}
|
|
6735
|
+
return result;
|
|
6736
|
+
}
|
|
6737
|
+
|
|
6697
6738
|
exports.setLogVerbosity = tsInvariant.setVerbosity;
|
|
6698
6739
|
exports.Observable = zenObservableTs.Observable;
|
|
6699
6740
|
exports.disableExperimentalFragmentVariables = graphqlTag.disableExperimentalFragmentVariables;
|
|
@@ -6742,6 +6783,7 @@ exports.split = split;
|
|
|
6742
6783
|
exports.throwServerError = throwServerError;
|
|
6743
6784
|
exports.toPromise = toPromise;
|
|
6744
6785
|
exports.useApolloClient = useApolloClient;
|
|
6786
|
+
exports.useFragment = useFragment;
|
|
6745
6787
|
exports.useLazyQuery = useLazyQuery;
|
|
6746
6788
|
exports.useMutation = useMutation;
|
|
6747
6789
|
exports.useQuery = useQuery;
|