@apollo/client 3.7.3 → 3.7.4
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/README.md +8 -7
- package/apollo-client.cjs +45 -16
- 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/invariantErrorCodes.js +1 -1
- package/package.json +13 -9
- package/react/hooks/hooks.cjs +44 -15
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +44 -15
- package/react/hooks/useLazyQuery.d.ts.map +1 -1
- package/react/hooks/useLazyQuery.js +19 -4
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts.map +1 -1
- package/react/hooks/useMutation.js +7 -7
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +2 -1
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +19 -5
- package/react/hooks/useQuery.js.map +1 -1
- package/testing/core/core.cjs +17 -0
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +17 -0
- package/testing/core/index.d.ts +1 -0
- package/testing/core/index.d.ts.map +1 -1
- package/testing/core/index.js +1 -0
- package/testing/core/index.js.map +1 -1
- package/testing/core/wait.d.ts +3 -0
- package/testing/core/wait.d.ts.map +1 -0
- package/testing/core/wait.js +16 -0
- package/testing/core/wait.js.map +1 -0
- package/version.js +1 -1
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
[](https://badge.fury.io/js/%40apollo%2Fclient)
|
|
6
6
|
[](https://circleci.com/gh/apollographql/apollo-client)
|
|
7
7
|
[](https://community.apollographql.com)
|
|
8
|
+
[](https://discord.gg/graphos)
|
|
8
9
|
|
|
9
10
|
Apollo Client is a fully-featured caching GraphQL client with integrations for React, Angular, and more. It allows you to easily build UI components that fetch data via GraphQL.
|
|
10
11
|
|
|
@@ -21,13 +22,13 @@ Learn how to use Apollo Client with self-paced hands-on training on Odyssey, Apo
|
|
|
21
22
|
|
|
22
23
|
## Maintainers
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
|Name|Username|
|
|
26
|
+
|---|---|
|
|
27
|
+
|Ben Newman|[@benjamn](https://github.com/benjamn)|
|
|
28
|
+
|Alessia Bellisario|[@alessbell](https://github.com/alessbell)|
|
|
29
|
+
|Jeff Auriemma|[@bignimbus](https://github.com/bignimbus)|
|
|
30
|
+
|Hugh Willson|[@hwillson](https://github.com/hwillson)|
|
|
31
|
+
|Jerel Miller|[@jerelmiller](https://github.com/jerelmiller)|
|
|
31
32
|
|
|
32
33
|
## Who is Apollo?
|
|
33
34
|
|
package/apollo-client.cjs
CHANGED
|
@@ -1345,7 +1345,7 @@ var concat = ApolloLink.concat;
|
|
|
1345
1345
|
|
|
1346
1346
|
var execute = ApolloLink.execute;
|
|
1347
1347
|
|
|
1348
|
-
var version = '3.7.
|
|
1348
|
+
var version = '3.7.4';
|
|
1349
1349
|
|
|
1350
1350
|
function isNodeResponse(value) {
|
|
1351
1351
|
return !!value.body;
|
|
@@ -6632,11 +6632,19 @@ var InternalState = (function () {
|
|
|
6632
6632
|
InternalState.prototype.forceUpdate = function () {
|
|
6633
6633
|
__DEV__ && tsInvariant.invariant.warn("Calling default no-op implementation of InternalState#forceUpdate");
|
|
6634
6634
|
};
|
|
6635
|
-
InternalState.prototype.asyncUpdate = function () {
|
|
6635
|
+
InternalState.prototype.asyncUpdate = function (signal) {
|
|
6636
6636
|
var _this = this;
|
|
6637
|
-
return new Promise(function (resolve) {
|
|
6637
|
+
return new Promise(function (resolve, reject) {
|
|
6638
|
+
var watchQueryOptions = _this.watchQueryOptions;
|
|
6639
|
+
var handleAborted = function () {
|
|
6640
|
+
_this.asyncResolveFns.delete(resolve);
|
|
6641
|
+
_this.optionsToIgnoreOnce.delete(watchQueryOptions);
|
|
6642
|
+
signal.removeEventListener('abort', handleAborted);
|
|
6643
|
+
reject(signal.reason);
|
|
6644
|
+
};
|
|
6638
6645
|
_this.asyncResolveFns.add(resolve);
|
|
6639
|
-
_this.optionsToIgnoreOnce.add(
|
|
6646
|
+
_this.optionsToIgnoreOnce.add(watchQueryOptions);
|
|
6647
|
+
signal.addEventListener('abort', handleAborted);
|
|
6640
6648
|
_this.forceUpdate();
|
|
6641
6649
|
});
|
|
6642
6650
|
};
|
|
@@ -6813,9 +6821,10 @@ var InternalState = (function () {
|
|
|
6813
6821
|
InternalState.prototype.handleErrorOrCompleted = function (result) {
|
|
6814
6822
|
var _this = this;
|
|
6815
6823
|
if (!result.loading) {
|
|
6824
|
+
var error_1 = this.toApolloError(result);
|
|
6816
6825
|
Promise.resolve().then(function () {
|
|
6817
|
-
if (
|
|
6818
|
-
_this.onError(
|
|
6826
|
+
if (error_1) {
|
|
6827
|
+
_this.onError(error_1);
|
|
6819
6828
|
}
|
|
6820
6829
|
else if (result.data) {
|
|
6821
6830
|
_this.onCompleted(result.data);
|
|
@@ -6825,6 +6834,11 @@ var InternalState = (function () {
|
|
|
6825
6834
|
});
|
|
6826
6835
|
}
|
|
6827
6836
|
};
|
|
6837
|
+
InternalState.prototype.toApolloError = function (result) {
|
|
6838
|
+
return isNonEmptyArray(result.errors)
|
|
6839
|
+
? new ApolloError({ graphQLErrors: result.errors })
|
|
6840
|
+
: result.error;
|
|
6841
|
+
};
|
|
6828
6842
|
InternalState.prototype.getCurrentResult = function () {
|
|
6829
6843
|
if (!this.result) {
|
|
6830
6844
|
this.handleErrorOrCompleted(this.result = this.observable.getCurrentResult());
|
|
@@ -6867,6 +6881,7 @@ var EAGER_METHODS = [
|
|
|
6867
6881
|
'subscribeToMore',
|
|
6868
6882
|
];
|
|
6869
6883
|
function useLazyQuery(query, options) {
|
|
6884
|
+
var abortControllersRef = React.useRef(new Set());
|
|
6870
6885
|
var internalState = useInternalState(useApolloClient(options && options.client), query);
|
|
6871
6886
|
var execOptionsRef = React.useRef();
|
|
6872
6887
|
var merged = execOptionsRef.current
|
|
@@ -6897,14 +6912,28 @@ function useLazyQuery(query, options) {
|
|
|
6897
6912
|
return eagerMethods;
|
|
6898
6913
|
}, []);
|
|
6899
6914
|
Object.assign(result, eagerMethods);
|
|
6915
|
+
React.useEffect(function () {
|
|
6916
|
+
return function () {
|
|
6917
|
+
abortControllersRef.current.forEach(function (controller) {
|
|
6918
|
+
controller.abort();
|
|
6919
|
+
});
|
|
6920
|
+
};
|
|
6921
|
+
}, []);
|
|
6900
6922
|
var execute = React.useCallback(function (executeOptions) {
|
|
6923
|
+
var controller = new AbortController();
|
|
6924
|
+
abortControllersRef.current.add(controller);
|
|
6901
6925
|
execOptionsRef.current = executeOptions ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
|
|
6902
6926
|
fetchPolicy: initialFetchPolicy,
|
|
6903
6927
|
};
|
|
6904
6928
|
var promise = internalState
|
|
6905
|
-
.asyncUpdate()
|
|
6906
|
-
.then(function (queryResult) {
|
|
6907
|
-
|
|
6929
|
+
.asyncUpdate(controller.signal)
|
|
6930
|
+
.then(function (queryResult) {
|
|
6931
|
+
abortControllersRef.current.delete(controller);
|
|
6932
|
+
return Object.assign(queryResult, eagerMethods);
|
|
6933
|
+
});
|
|
6934
|
+
promise.catch(function () {
|
|
6935
|
+
abortControllersRef.current.delete(controller);
|
|
6936
|
+
});
|
|
6908
6937
|
return promise;
|
|
6909
6938
|
}, []);
|
|
6910
6939
|
return [execute, result];
|
|
@@ -6945,7 +6974,7 @@ function useMutation(mutation, options) {
|
|
|
6945
6974
|
var mutationId = ++ref.current.mutationId;
|
|
6946
6975
|
var clientOptions = mergeOptions(baseOptions, executeOptions);
|
|
6947
6976
|
return client.mutate(clientOptions).then(function (response) {
|
|
6948
|
-
var _a
|
|
6977
|
+
var _a;
|
|
6949
6978
|
var data = response.data, errors = response.errors;
|
|
6950
6979
|
var error = errors && errors.length > 0
|
|
6951
6980
|
? new ApolloError({ graphQLErrors: errors })
|
|
@@ -6963,11 +6992,11 @@ function useMutation(mutation, options) {
|
|
|
6963
6992
|
setResult(ref.current.result = result_1);
|
|
6964
6993
|
}
|
|
6965
6994
|
}
|
|
6966
|
-
|
|
6967
|
-
|
|
6995
|
+
var onCompleted = executeOptions.onCompleted || ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onCompleted);
|
|
6996
|
+
onCompleted === null || onCompleted === void 0 ? void 0 : onCompleted(response.data, clientOptions);
|
|
6968
6997
|
return response;
|
|
6969
6998
|
}).catch(function (error) {
|
|
6970
|
-
var _a
|
|
6999
|
+
var _a;
|
|
6971
7000
|
if (mutationId === ref.current.mutationId &&
|
|
6972
7001
|
ref.current.isMounted) {
|
|
6973
7002
|
var result_2 = {
|
|
@@ -6981,9 +7010,9 @@ function useMutation(mutation, options) {
|
|
|
6981
7010
|
setResult(ref.current.result = result_2);
|
|
6982
7011
|
}
|
|
6983
7012
|
}
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
7013
|
+
var onError = executeOptions.onError || ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError);
|
|
7014
|
+
if (onError) {
|
|
7015
|
+
onError(error, clientOptions);
|
|
6987
7016
|
return { data: void 0, errors: error };
|
|
6988
7017
|
}
|
|
6989
7018
|
throw error;
|