@apollo/client 3.3.7 → 3.3.11
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/LICENSE +1 -1
- package/README.md +1 -0
- package/apollo-client.cjs.js +66 -52
- package/apollo-client.cjs.js.map +1 -1
- package/apollo-client.cjs.min.js +1 -1
- package/cache/cache.cjs.js +27 -24
- package/cache/cache.cjs.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
- package/cache/inmemory/inMemoryCache.js +4 -1
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/reactiveVars.d.ts +1 -0
- package/cache/inmemory/reactiveVars.d.ts.map +1 -1
- package/cache/inmemory/reactiveVars.js +25 -25
- package/cache/inmemory/reactiveVars.js.map +1 -1
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +2 -2
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +1 -0
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js +8 -3
- package/core/QueryInfo.js.map +1 -1
- package/core/core.cjs.js +10 -5
- package/core/core.cjs.js.map +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.d.ts.map +1 -1
- package/invariantErrorCodes.js +1 -1
- package/package.json +9 -10
- package/react/data/MutationData.d.ts +1 -1
- package/react/data/MutationData.d.ts.map +1 -1
- package/react/data/MutationData.js.map +1 -1
- package/react/data/QueryData.d.ts +2 -2
- package/react/data/QueryData.d.ts.map +1 -1
- package/react/data/QueryData.js.map +1 -1
- package/react/hooks/hooks.cjs.js +14 -18
- package/react/hooks/hooks.cjs.js.map +1 -1
- package/react/hooks/useReactiveVar.d.ts.map +1 -1
- package/react/hooks/useReactiveVar.js +3 -0
- package/react/hooks/useReactiveVar.js.map +1 -1
- package/react/hooks/utils/useBaseQuery.d.ts.map +1 -1
- package/react/hooks/utils/useBaseQuery.js +11 -18
- package/react/hooks/utils/useBaseQuery.js.map +1 -1
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/index.d.ts +1 -0
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js +1 -0
- package/utilities/index.js.map +1 -1
- package/utilities/observables/Concast.d.ts +2 -2
- package/utilities/observables/Concast.d.ts.map +1 -1
- package/utilities/observables/Concast.js +5 -5
- package/utilities/observables/Concast.js.map +1 -1
- package/utilities/observables/Observable.d.ts +1 -0
- package/utilities/observables/Observable.d.ts.map +1 -1
- package/utilities/observables/Observable.js.map +1 -1
- package/utilities/observables/subclassing.d.ts +4 -0
- package/utilities/observables/subclassing.d.ts.map +1 -0
- package/utilities/observables/subclassing.js +12 -0
- package/utilities/observables/subclassing.js.map +1 -0
- package/utilities/utilities.cjs.js +16 -5
- package/utilities/utilities.cjs.js.map +1 -1
- package/version.js +1 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2021 Apollo Graph, Inc. (Formerly Meteor Development Group, Inc.)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
package/apollo-client.cjs.js
CHANGED
|
@@ -851,6 +851,17 @@ function asyncMap(observable, mapFn, catchFn) {
|
|
|
851
851
|
});
|
|
852
852
|
}
|
|
853
853
|
|
|
854
|
+
function fixObservableSubclass(subclass) {
|
|
855
|
+
function set(key) {
|
|
856
|
+
Object.defineProperty(subclass, key, { value: Observable });
|
|
857
|
+
}
|
|
858
|
+
if (typeof Symbol === "function" && Symbol.species) {
|
|
859
|
+
set(Symbol.species);
|
|
860
|
+
}
|
|
861
|
+
set("@@species");
|
|
862
|
+
return subclass;
|
|
863
|
+
}
|
|
864
|
+
|
|
854
865
|
function isPromiseLike(value) {
|
|
855
866
|
return value && typeof value.then === "function";
|
|
856
867
|
}
|
|
@@ -914,6 +925,9 @@ var Concast = (function (_super) {
|
|
|
914
925
|
_this.handlers.complete();
|
|
915
926
|
};
|
|
916
927
|
_this.promise.catch(function (_) { });
|
|
928
|
+
if (typeof sources === "function") {
|
|
929
|
+
sources = [new Observable(sources)];
|
|
930
|
+
}
|
|
917
931
|
if (isPromiseLike(sources)) {
|
|
918
932
|
sources.then(function (iterable) { return _this.start(iterable); }, _this.handlers.error);
|
|
919
933
|
}
|
|
@@ -977,11 +991,7 @@ var Concast = (function (_super) {
|
|
|
977
991
|
};
|
|
978
992
|
return Concast;
|
|
979
993
|
}(Observable));
|
|
980
|
-
|
|
981
|
-
Object.defineProperty(Concast, Symbol.species, {
|
|
982
|
-
value: Observable,
|
|
983
|
-
});
|
|
984
|
-
}
|
|
994
|
+
fixObservableSubclass(Concast);
|
|
985
995
|
|
|
986
996
|
function isNonEmptyArray(value) {
|
|
987
997
|
return Array.isArray(value) && value.length > 0;
|
|
@@ -1217,7 +1227,7 @@ var concat = ApolloLink.concat;
|
|
|
1217
1227
|
|
|
1218
1228
|
var execute = ApolloLink.execute;
|
|
1219
1229
|
|
|
1220
|
-
var version = '3.3.
|
|
1230
|
+
var version = '3.3.11';
|
|
1221
1231
|
|
|
1222
1232
|
var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
1223
1233
|
function parseAndCheckHttpResponse(operations) {
|
|
@@ -1947,7 +1957,6 @@ var ObservableQuery = (function (_super) {
|
|
|
1947
1957
|
this.reobserver.stop();
|
|
1948
1958
|
delete this.reobserver;
|
|
1949
1959
|
}
|
|
1950
|
-
delete this.options.context;
|
|
1951
1960
|
this.subscriptions.forEach(function (sub) { return sub.unsubscribe(); });
|
|
1952
1961
|
this.subscriptions.clear();
|
|
1953
1962
|
this.queryManager.stopQuery(this.queryId);
|
|
@@ -1956,6 +1965,7 @@ var ObservableQuery = (function (_super) {
|
|
|
1956
1965
|
};
|
|
1957
1966
|
return ObservableQuery;
|
|
1958
1967
|
}(Observable));
|
|
1968
|
+
fixObservableSubclass(ObservableQuery);
|
|
1959
1969
|
function defaultSubscriptionObserverErrorCallback(error) {
|
|
1960
1970
|
process.env.NODE_ENV === "production" || tsInvariant.invariant.error('Unhandled error', error.message, error.stack);
|
|
1961
1971
|
}
|
|
@@ -2960,7 +2970,6 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
|
|
|
2960
2970
|
: "") + "define a custom merge function for the " + typeDotName + " field, so InMemoryCache can safely merge these objects:\n\n existing: " + JSON.stringify(existing).slice(0, 1000) + "\n incoming: " + JSON.stringify(incoming).slice(0, 1000) + "\n\nFor more information about these options, please refer to the documentation:\n\n * Ensuring entity objects have IDs: https://go.apollo.dev/c/generating-unique-identifiers\n * Defining custom merge functions: https://go.apollo.dev/c/merging-non-normalized-objects\n");
|
|
2961
2971
|
}
|
|
2962
2972
|
|
|
2963
|
-
var varDep = optimism.dep();
|
|
2964
2973
|
var cacheSlot = new context.Slot();
|
|
2965
2974
|
function consumeAndIterate(set, callback) {
|
|
2966
2975
|
if (set.size) {
|
|
@@ -2970,13 +2979,22 @@ function consumeAndIterate(set, callback) {
|
|
|
2970
2979
|
items_1.forEach(callback);
|
|
2971
2980
|
}
|
|
2972
2981
|
}
|
|
2973
|
-
var
|
|
2974
|
-
function
|
|
2975
|
-
var
|
|
2976
|
-
if (
|
|
2977
|
-
|
|
2978
|
-
|
|
2982
|
+
var cacheInfoMap = new WeakMap();
|
|
2983
|
+
function getCacheInfo(cache) {
|
|
2984
|
+
var info = cacheInfoMap.get(cache);
|
|
2985
|
+
if (!info) {
|
|
2986
|
+
cacheInfoMap.set(cache, info = {
|
|
2987
|
+
vars: new Set,
|
|
2988
|
+
dep: optimism.dep(),
|
|
2989
|
+
});
|
|
2979
2990
|
}
|
|
2991
|
+
return info;
|
|
2992
|
+
}
|
|
2993
|
+
function forgetCache(cache) {
|
|
2994
|
+
getCacheInfo(cache).vars.forEach(function (rv) { return rv.forgetCache(cache); });
|
|
2995
|
+
}
|
|
2996
|
+
function recallCache(cache) {
|
|
2997
|
+
getCacheInfo(cache).vars.forEach(function (rv) { return rv.attachCache(cache); });
|
|
2980
2998
|
}
|
|
2981
2999
|
function makeVar(value) {
|
|
2982
3000
|
var caches = new Set();
|
|
@@ -2985,16 +3003,19 @@ function makeVar(value) {
|
|
|
2985
3003
|
if (arguments.length > 0) {
|
|
2986
3004
|
if (value !== newValue) {
|
|
2987
3005
|
value = newValue;
|
|
2988
|
-
|
|
2989
|
-
|
|
3006
|
+
caches.forEach(function (cache) {
|
|
3007
|
+
getCacheInfo(cache).dep.dirty(rv);
|
|
3008
|
+
broadcast(cache);
|
|
3009
|
+
});
|
|
2990
3010
|
consumeAndIterate(listeners, function (listener) { return listener(value); });
|
|
2991
3011
|
}
|
|
2992
3012
|
}
|
|
2993
3013
|
else {
|
|
2994
3014
|
var cache = cacheSlot.getValue();
|
|
2995
|
-
if (cache)
|
|
3015
|
+
if (cache) {
|
|
2996
3016
|
attach(cache);
|
|
2997
|
-
|
|
3017
|
+
getCacheInfo(cache).dep(rv);
|
|
3018
|
+
}
|
|
2998
3019
|
}
|
|
2999
3020
|
return value;
|
|
3000
3021
|
};
|
|
@@ -3006,21 +3027,10 @@ function makeVar(value) {
|
|
|
3006
3027
|
};
|
|
3007
3028
|
var attach = rv.attachCache = function (cache) {
|
|
3008
3029
|
caches.add(cache);
|
|
3009
|
-
|
|
3010
|
-
if (!vars)
|
|
3011
|
-
varsByCache.set(cache, vars = new Set);
|
|
3012
|
-
vars.add(rv);
|
|
3030
|
+
getCacheInfo(cache).vars.add(rv);
|
|
3013
3031
|
return rv;
|
|
3014
3032
|
};
|
|
3015
|
-
rv.forgetCache = function (cache) {
|
|
3016
|
-
var deleted = caches.delete(cache);
|
|
3017
|
-
if (deleted) {
|
|
3018
|
-
var vars = varsByCache.get(cache);
|
|
3019
|
-
if (vars)
|
|
3020
|
-
vars.delete(rv);
|
|
3021
|
-
}
|
|
3022
|
-
return deleted;
|
|
3023
|
-
};
|
|
3033
|
+
rv.forgetCache = function (cache) { return caches.delete(cache); };
|
|
3024
3034
|
return rv;
|
|
3025
3035
|
}
|
|
3026
3036
|
function broadcast(cache) {
|
|
@@ -3609,6 +3619,9 @@ var InMemoryCache = (function (_super) {
|
|
|
3609
3619
|
};
|
|
3610
3620
|
InMemoryCache.prototype.watch = function (watch) {
|
|
3611
3621
|
var _this = this;
|
|
3622
|
+
if (!this.watches.size) {
|
|
3623
|
+
recallCache(this);
|
|
3624
|
+
}
|
|
3612
3625
|
this.watches.add(watch);
|
|
3613
3626
|
if (watch.immediate) {
|
|
3614
3627
|
this.maybeBroadcastWatch(watch);
|
|
@@ -4050,6 +4063,11 @@ var QueryInfo = (function () {
|
|
|
4050
4063
|
}
|
|
4051
4064
|
return this;
|
|
4052
4065
|
};
|
|
4066
|
+
QueryInfo.prototype.reset = function () {
|
|
4067
|
+
cancelNotifyTimeout(this);
|
|
4068
|
+
this.diff = null;
|
|
4069
|
+
this.dirty = false;
|
|
4070
|
+
};
|
|
4053
4071
|
QueryInfo.prototype.getDiff = function (variables) {
|
|
4054
4072
|
if (variables === void 0) { variables = this.variables; }
|
|
4055
4073
|
if (this.diff && equality.equal(variables, this.variables)) {
|
|
@@ -4161,11 +4179,11 @@ var QueryInfo = (function () {
|
|
|
4161
4179
|
QueryInfo.prototype.markResult = function (result, options, allowCacheWrite) {
|
|
4162
4180
|
var _this = this;
|
|
4163
4181
|
this.graphQLErrors = isNonEmptyArray(result.errors) ? result.errors : [];
|
|
4164
|
-
|
|
4182
|
+
this.reset();
|
|
4165
4183
|
if (options.fetchPolicy === 'no-cache') {
|
|
4166
4184
|
this.diff = { result: result.data, complete: true };
|
|
4167
4185
|
}
|
|
4168
|
-
else if (allowCacheWrite) {
|
|
4186
|
+
else if (!this.stopped && allowCacheWrite) {
|
|
4169
4187
|
if (shouldWriteResult(result, options.errorPolicy)) {
|
|
4170
4188
|
this.cache.performTransaction(function (cache) {
|
|
4171
4189
|
if (_this.shouldWrite(result, options.variables)) {
|
|
@@ -4213,7 +4231,7 @@ var QueryInfo = (function () {
|
|
|
4213
4231
|
QueryInfo.prototype.markError = function (error) {
|
|
4214
4232
|
this.networkStatus = exports.NetworkStatus.error;
|
|
4215
4233
|
this.lastWrite = void 0;
|
|
4216
|
-
|
|
4234
|
+
this.reset();
|
|
4217
4235
|
if (error.graphQLErrors) {
|
|
4218
4236
|
this.graphQLErrors = error.graphQLErrors;
|
|
4219
4237
|
}
|
|
@@ -5818,24 +5836,20 @@ function useBaseQuery(query, options, lazy) {
|
|
|
5818
5836
|
var _a = React.useReducer(function (x) { return x + 1; }, 0), tick = _a[0], forceUpdate = _a[1];
|
|
5819
5837
|
var updatedOptions = options ? tslib.__assign(tslib.__assign({}, options), { query: query }) : { query: query };
|
|
5820
5838
|
var queryDataRef = React.useRef();
|
|
5821
|
-
var queryData = queryDataRef.current ||
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
Promise.resolve().then(forceUpdate);
|
|
5828
|
-
}
|
|
5829
|
-
else {
|
|
5830
|
-
forceUpdate();
|
|
5831
|
-
}
|
|
5839
|
+
var queryData = queryDataRef.current || (queryDataRef.current = new QueryData({
|
|
5840
|
+
options: updatedOptions,
|
|
5841
|
+
context: context,
|
|
5842
|
+
onNewData: function () {
|
|
5843
|
+
if (!queryData.ssrInitiated()) {
|
|
5844
|
+
Promise.resolve().then(function () { return queryDataRef.current && forceUpdate(); });
|
|
5832
5845
|
}
|
|
5833
|
-
|
|
5846
|
+
else {
|
|
5847
|
+
forceUpdate();
|
|
5848
|
+
}
|
|
5849
|
+
}
|
|
5850
|
+
}));
|
|
5834
5851
|
queryData.setOptions(updatedOptions);
|
|
5835
5852
|
queryData.context = context;
|
|
5836
|
-
if (queryData.ssrInitiated() && !queryDataRef.current) {
|
|
5837
|
-
queryDataRef.current = queryData;
|
|
5838
|
-
}
|
|
5839
5853
|
var memo = {
|
|
5840
5854
|
options: tslib.__assign(tslib.__assign({}, updatedOptions), { onError: undefined, onCompleted: undefined }),
|
|
5841
5855
|
context: context,
|
|
@@ -5846,9 +5860,6 @@ function useBaseQuery(query, options, lazy) {
|
|
|
5846
5860
|
? result[1]
|
|
5847
5861
|
: result;
|
|
5848
5862
|
React.useEffect(function () {
|
|
5849
|
-
if (!queryDataRef.current) {
|
|
5850
|
-
queryDataRef.current = queryData;
|
|
5851
|
-
}
|
|
5852
5863
|
return function () { return queryData.cleanup(); };
|
|
5853
5864
|
}, []);
|
|
5854
5865
|
React.useEffect(function () { return queryData.afterExecute({ lazy: lazy }); }, [
|
|
@@ -5923,6 +5934,9 @@ function useReactiveVar(rv) {
|
|
|
5923
5934
|
var value = rv();
|
|
5924
5935
|
var _a = React.useState(value), setValue = _a[1];
|
|
5925
5936
|
React.useEffect(function () { return rv.onNextChange(setValue); }, [value]);
|
|
5937
|
+
React.useEffect(function () {
|
|
5938
|
+
setValue(rv());
|
|
5939
|
+
}, []);
|
|
5926
5940
|
return value;
|
|
5927
5941
|
}
|
|
5928
5942
|
|