@apollo/client 3.5.3 → 3.6.0-beta.2
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 +95 -133
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/core/core.cjs +5 -5
- package/core/core.cjs.map +1 -1
- package/invariantErrorCodes.js +1 -1
- package/main.cjs +4 -4
- package/package.json +15 -10
- package/react/components/components.cjs +3 -3
- package/react/context/context.cjs +3 -3
- package/react/hoc/hoc.cjs +4 -4
- package/react/hooks/hooks.cjs +89 -127
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/useLazyQuery.d.ts.map +1 -1
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts.map +1 -1
- package/react/hooks/useMutation.js +7 -4
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +82 -123
- package/react/hooks/useQuery.js.map +1 -1
- package/react/react.cjs +2 -2
- package/react/ssr/RenderPromises.d.ts +2 -2
- package/react/ssr/RenderPromises.d.ts.map +1 -1
- package/react/ssr/RenderPromises.js +5 -7
- package/react/ssr/RenderPromises.js.map +1 -1
- package/react/ssr/ssr.cjs +8 -10
- package/react/ssr/ssr.cjs.map +1 -1
- package/testing/testing.cjs +5 -5
- package/utilities/globals/fix-graphql.js +1 -1
- package/version.js +1 -1
package/invariantErrorCodes.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// consult the @apollo/client/invariantErrorCodes.js file specific to
|
|
6
6
|
// your @apollo/client version. This file is not meant to be imported.
|
|
7
7
|
{
|
|
8
|
-
"@apollo/client version": "3.
|
|
8
|
+
"@apollo/client version": "3.6.0-beta.2",
|
|
9
9
|
|
|
10
10
|
1: {
|
|
11
11
|
file: "@apollo/client/cache/inmemory/entityStore.js",
|
package/main.cjs
CHANGED
|
@@ -7,10 +7,10 @@ var react = require('./react');
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
for (var k in core) {
|
|
11
11
|
if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = core[k];
|
|
12
|
-
}
|
|
13
|
-
|
|
12
|
+
}
|
|
13
|
+
for (var k in react) {
|
|
14
14
|
if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = react[k];
|
|
15
|
-
}
|
|
15
|
+
}
|
|
16
16
|
//# sourceMappingURL=main.cjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apollo/client",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0-beta.2",
|
|
4
4
|
"description": "A fully-featured caching GraphQL client.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"keywords": [
|
|
@@ -30,8 +30,9 @@
|
|
|
30
30
|
"homepage": "https://www.apollographql.com/docs/react/",
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
33
|
-
"react": "^16.8.0 || ^17.0.0",
|
|
34
|
-
"subscriptions-transport-ws": "^0.9.0 || ^0.11.0"
|
|
33
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0-beta",
|
|
34
|
+
"subscriptions-transport-ws": "^0.9.0 || ^0.11.0",
|
|
35
|
+
"use-sync-external-store": "^1.0.0-beta-4ff5f5719-20211115"
|
|
35
36
|
},
|
|
36
37
|
"peerDependenciesMeta": {
|
|
37
38
|
"react": {
|
|
@@ -39,6 +40,9 @@
|
|
|
39
40
|
},
|
|
40
41
|
"subscriptions-transport-ws": {
|
|
41
42
|
"optional": true
|
|
43
|
+
},
|
|
44
|
+
"use-sync-external-store": {
|
|
45
|
+
"optional": true
|
|
42
46
|
}
|
|
43
47
|
},
|
|
44
48
|
"dependencies": {
|
|
@@ -56,20 +60,21 @@
|
|
|
56
60
|
"zen-observable-ts": "^1.2.0"
|
|
57
61
|
},
|
|
58
62
|
"devDependencies": {
|
|
59
|
-
"@babel/parser": "7.16.
|
|
63
|
+
"@babel/parser": "7.16.4",
|
|
60
64
|
"@graphql-tools/schema": "8.3.1",
|
|
61
65
|
"@rollup/plugin-node-resolve": "11.2.1",
|
|
62
|
-
"@testing-library/react": "
|
|
66
|
+
"@testing-library/react": "12.1.2",
|
|
63
67
|
"@testing-library/react-hooks": "7.0.2",
|
|
64
68
|
"@types/fast-json-stable-stringify": "2.0.0",
|
|
65
69
|
"@types/fetch-mock": "7.3.5",
|
|
66
70
|
"@types/glob": "7.2.0",
|
|
67
71
|
"@types/hoist-non-react-statics": "3.3.1",
|
|
68
|
-
"@types/jest": "27.0.
|
|
69
|
-
"@types/lodash": "4.14.
|
|
70
|
-
"@types/node": "16.11.
|
|
72
|
+
"@types/jest": "27.0.3",
|
|
73
|
+
"@types/lodash": "4.14.177",
|
|
74
|
+
"@types/node": "16.11.9",
|
|
71
75
|
"@types/react": "17.0.34",
|
|
72
76
|
"@types/react-dom": "17.0.2",
|
|
77
|
+
"@types/use-sync-external-store": "^0.0.3",
|
|
73
78
|
"bundlesize": "0.18.1",
|
|
74
79
|
"cross-fetch": "3.1.4",
|
|
75
80
|
"crypto-hash": "1.3.0",
|
|
@@ -85,11 +90,11 @@
|
|
|
85
90
|
"recast": "0.20.5",
|
|
86
91
|
"resolve": "1.20.0",
|
|
87
92
|
"rimraf": "3.0.2",
|
|
88
|
-
"rollup": "2.
|
|
93
|
+
"rollup": "2.60.0",
|
|
89
94
|
"rollup-plugin-terser": "7.0.2",
|
|
90
95
|
"rxjs": "6.6.7",
|
|
91
96
|
"subscriptions-transport-ws": "0.11.0",
|
|
92
|
-
"terser": "5.
|
|
97
|
+
"terser": "5.10.0",
|
|
93
98
|
"ts-jest": "27.0.7",
|
|
94
99
|
"ts-node": "10.4.0",
|
|
95
100
|
"typescript": "4.4.4",
|
|
@@ -10,11 +10,11 @@ function _interopNamespace(e) {
|
|
|
10
10
|
if (e && e.__esModule) return e;
|
|
11
11
|
var n = Object.create(null);
|
|
12
12
|
if (e) {
|
|
13
|
-
|
|
13
|
+
for (var k in e) {
|
|
14
14
|
n[k] = e[k];
|
|
15
|
-
}
|
|
15
|
+
}
|
|
16
16
|
}
|
|
17
|
-
n[
|
|
17
|
+
n["default"] = e;
|
|
18
18
|
return Object.freeze(n);
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -10,11 +10,11 @@ function _interopNamespace(e) {
|
|
|
10
10
|
if (e && e.__esModule) return e;
|
|
11
11
|
var n = Object.create(null);
|
|
12
12
|
if (e) {
|
|
13
|
-
|
|
13
|
+
for (var k in e) {
|
|
14
14
|
n[k] = e[k];
|
|
15
|
-
}
|
|
15
|
+
}
|
|
16
16
|
}
|
|
17
|
-
n[
|
|
17
|
+
n["default"] = e;
|
|
18
18
|
return Object.freeze(n);
|
|
19
19
|
}
|
|
20
20
|
|
package/react/hoc/hoc.cjs
CHANGED
|
@@ -10,17 +10,17 @@ var hoistNonReactStatics = require('hoist-non-react-statics');
|
|
|
10
10
|
var components = require('../components');
|
|
11
11
|
var context = require('../context');
|
|
12
12
|
|
|
13
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e[
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
14
14
|
|
|
15
15
|
function _interopNamespace(e) {
|
|
16
16
|
if (e && e.__esModule) return e;
|
|
17
17
|
var n = Object.create(null);
|
|
18
18
|
if (e) {
|
|
19
|
-
|
|
19
|
+
for (var k in e) {
|
|
20
20
|
n[k] = e[k];
|
|
21
|
-
}
|
|
21
|
+
}
|
|
22
22
|
}
|
|
23
|
-
n[
|
|
23
|
+
n["default"] = e;
|
|
24
24
|
return Object.freeze(n);
|
|
25
25
|
}
|
|
26
26
|
|
package/react/hooks/hooks.cjs
CHANGED
|
@@ -6,6 +6,7 @@ var globals = require('../../utilities/globals');
|
|
|
6
6
|
var react = require('react');
|
|
7
7
|
var context = require('../context');
|
|
8
8
|
var tslib = require('tslib');
|
|
9
|
+
var shim = require('use-sync-external-store/shim');
|
|
9
10
|
var equality = require('@wry/equality');
|
|
10
11
|
var errors = require('../../errors');
|
|
11
12
|
var core = require('../../core');
|
|
@@ -25,6 +26,12 @@ function useQuery(query, options) {
|
|
|
25
26
|
var context$1 = react.useContext(context.getApolloContext());
|
|
26
27
|
var client = useApolloClient(options === null || options === void 0 ? void 0 : options.client);
|
|
27
28
|
parser.verifyDocumentType(query, parser.DocumentType.Query);
|
|
29
|
+
var ref = react.useRef({
|
|
30
|
+
client: client,
|
|
31
|
+
query: query,
|
|
32
|
+
options: options,
|
|
33
|
+
watchQueryOptions: createWatchQueryOptions(query, options),
|
|
34
|
+
});
|
|
28
35
|
var _b = react.useState(function () {
|
|
29
36
|
var watchQueryOptions = createWatchQueryOptions(query, options);
|
|
30
37
|
var obsQuery = null;
|
|
@@ -64,114 +71,96 @@ function useQuery(query, options) {
|
|
|
64
71
|
}
|
|
65
72
|
return obsQuery;
|
|
66
73
|
}), obsQuery = _b[0], setObsQuery = _b[1];
|
|
67
|
-
var _c = react.useState(function () {
|
|
68
|
-
var _a, _b;
|
|
69
|
-
var result = obsQuery.getCurrentResult();
|
|
70
|
-
if (!result.loading && options) {
|
|
71
|
-
if (result.error) {
|
|
72
|
-
(_a = options.onError) === null || _a === void 0 ? void 0 : _a.call(options, result.error);
|
|
73
|
-
}
|
|
74
|
-
else if (result.data) {
|
|
75
|
-
(_b = options.onCompleted) === null || _b === void 0 ? void 0 : _b.call(options, result.data);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return result;
|
|
79
|
-
}), result = _c[0], setResult = _c[1];
|
|
80
|
-
var ref = react.useRef({
|
|
81
|
-
client: client,
|
|
82
|
-
query: query,
|
|
83
|
-
options: options,
|
|
84
|
-
result: result,
|
|
85
|
-
previousData: void 0,
|
|
86
|
-
watchQueryOptions: createWatchQueryOptions(query, options),
|
|
87
|
-
});
|
|
88
74
|
react.useEffect(function () {
|
|
89
|
-
var _a, _b;
|
|
90
75
|
var watchQueryOptions = createWatchQueryOptions(query, options);
|
|
91
|
-
var nextResult;
|
|
92
76
|
if (ref.current.client !== client || !equality.equal(ref.current.query, query)) {
|
|
93
77
|
var obsQuery_1 = client.watchQuery(watchQueryOptions);
|
|
94
78
|
setObsQuery(obsQuery_1);
|
|
95
|
-
nextResult = obsQuery_1.getCurrentResult();
|
|
96
79
|
}
|
|
97
80
|
else if (!equality.equal(ref.current.watchQueryOptions, watchQueryOptions)) {
|
|
98
|
-
obsQuery.setOptions(watchQueryOptions)
|
|
99
|
-
|
|
100
|
-
ref.current.watchQueryOptions = watchQueryOptions;
|
|
81
|
+
obsQuery.setOptions(watchQueryOptions);
|
|
82
|
+
setObsQuery(obsQuery);
|
|
101
83
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
84
|
+
Object.assign(ref.current, {
|
|
85
|
+
client: client,
|
|
86
|
+
query: query,
|
|
87
|
+
options: options,
|
|
88
|
+
watchQueryOptions: watchQueryOptions,
|
|
89
|
+
});
|
|
90
|
+
}, [obsQuery, client, query, options]);
|
|
91
|
+
var _c = react.useMemo(function () {
|
|
92
|
+
var previousResult;
|
|
93
|
+
var subscribe = function (forceUpdate) {
|
|
94
|
+
var subscription = obsQuery.subscribe(forceUpdate, onError);
|
|
95
|
+
function onError(error) {
|
|
96
|
+
forceUpdate();
|
|
97
|
+
subscription.unsubscribe();
|
|
98
|
+
var last = obsQuery["last"];
|
|
99
|
+
obsQuery.resetLastResults();
|
|
100
|
+
obsQuery.subscribe(forceUpdate, onError);
|
|
101
|
+
obsQuery["last"] = last;
|
|
102
|
+
if (!error.hasOwnProperty('graphQLErrors')) {
|
|
103
|
+
throw error;
|
|
116
104
|
}
|
|
117
105
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
var subscription = obsQuery.subscribe(onNext, onError);
|
|
126
|
-
function onNext() {
|
|
127
|
-
var _a, _b;
|
|
128
|
-
var previousResult = ref.current.result;
|
|
106
|
+
return function () {
|
|
107
|
+
subscription.unsubscribe();
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
var getSnapshot = function () {
|
|
129
111
|
var result = obsQuery.getCurrentResult();
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
previousResult.networkStatus === result.networkStatus &&
|
|
133
|
-
equality.equal(previousResult.data, result.data)) {
|
|
134
|
-
return;
|
|
112
|
+
if (result.errors && result.errors.length) {
|
|
113
|
+
result = tslib.__assign(tslib.__assign({}, result), { error: result.error || new errors.ApolloError({ graphQLErrors: result.errors }) });
|
|
135
114
|
}
|
|
136
|
-
if (previousResult
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
115
|
+
if (!previousResult ||
|
|
116
|
+
previousResult.loading !== result.loading ||
|
|
117
|
+
previousResult.networkStatus !== result.networkStatus ||
|
|
118
|
+
!equality.equal(previousResult.data, result.data) ||
|
|
119
|
+
!equality.equal(previousResult.error, result.error)) {
|
|
120
|
+
if (previousResult) {
|
|
121
|
+
result = tslib.__assign(tslib.__assign({}, result), { previousData: previousResult.data || previousResult.previousData });
|
|
122
|
+
}
|
|
123
|
+
previousResult = result;
|
|
142
124
|
}
|
|
125
|
+
return previousResult;
|
|
126
|
+
};
|
|
127
|
+
return [subscribe, getSnapshot];
|
|
128
|
+
}, [obsQuery]), subscribe = _c[0], getSnapshot = _c[1];
|
|
129
|
+
var obsQueryMethods = react.useMemo(function () { return ({
|
|
130
|
+
refetch: obsQuery.refetch.bind(obsQuery),
|
|
131
|
+
fetchMore: obsQuery.fetchMore.bind(obsQuery),
|
|
132
|
+
updateQuery: obsQuery.updateQuery.bind(obsQuery),
|
|
133
|
+
startPolling: obsQuery.startPolling.bind(obsQuery),
|
|
134
|
+
stopPolling: obsQuery.stopPolling.bind(obsQuery),
|
|
135
|
+
subscribeToMore: obsQuery.subscribeToMore.bind(obsQuery),
|
|
136
|
+
}); }, [obsQuery]);
|
|
137
|
+
var result = shim.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
138
|
+
react.useEffect(function () {
|
|
139
|
+
var _a, _b, _c, _d, _e, _f;
|
|
140
|
+
if (((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.skip) ||
|
|
141
|
+
((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.fetchPolicy) === 'standby') {
|
|
142
|
+
return;
|
|
143
143
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
subscription.unsubscribe();
|
|
148
|
-
try {
|
|
149
|
-
obsQuery.resetLastResults();
|
|
150
|
-
subscription = obsQuery.subscribe(onNext, onError);
|
|
151
|
-
}
|
|
152
|
-
finally {
|
|
153
|
-
obsQuery["last"] = last;
|
|
154
|
-
}
|
|
155
|
-
if (!error.hasOwnProperty('graphQLErrors')) {
|
|
156
|
-
throw error;
|
|
144
|
+
if (!result.loading) {
|
|
145
|
+
if (result.error) {
|
|
146
|
+
(_d = (_c = ref.current.options) === null || _c === void 0 ? void 0 : _c.onError) === null || _d === void 0 ? void 0 : _d.call(_c, result.error);
|
|
157
147
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
!equality.equal(error, previousResult.error)) {
|
|
161
|
-
setResult(ref.current.result = {
|
|
162
|
-
data: previousResult.data,
|
|
163
|
-
error: error,
|
|
164
|
-
loading: false,
|
|
165
|
-
networkStatus: core.NetworkStatus.error,
|
|
166
|
-
});
|
|
167
|
-
(_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
|
|
148
|
+
else if (result.data) {
|
|
149
|
+
(_f = (_e = ref.current.options) === null || _e === void 0 ? void 0 : _e.onCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, result.data);
|
|
168
150
|
}
|
|
169
151
|
}
|
|
170
|
-
|
|
171
|
-
}, [obsQuery, context$1.renderPromises, client.disableNetworkFetches]);
|
|
152
|
+
}, [result]);
|
|
172
153
|
var partial;
|
|
173
154
|
(_a = result, partial = _a.partial, result = tslib.__rest(_a, ["partial"]));
|
|
174
|
-
{
|
|
155
|
+
if ((options === null || options === void 0 ? void 0 : options.skip) || (options === null || options === void 0 ? void 0 : options.fetchPolicy) === 'standby') {
|
|
156
|
+
result = {
|
|
157
|
+
loading: false,
|
|
158
|
+
data: void 0,
|
|
159
|
+
error: void 0,
|
|
160
|
+
networkStatus: core.NetworkStatus.ready,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
175
164
|
if (partial &&
|
|
176
165
|
(options === null || options === void 0 ? void 0 : options.partialRefetch) &&
|
|
177
166
|
!result.loading &&
|
|
@@ -180,42 +169,12 @@ function useQuery(query, options) {
|
|
|
180
169
|
result = tslib.__assign(tslib.__assign({}, result), { loading: true, networkStatus: core.NetworkStatus.refetch });
|
|
181
170
|
obsQuery.refetch();
|
|
182
171
|
}
|
|
183
|
-
if (context$1.renderPromises &&
|
|
184
|
-
(
|
|
185
|
-
|
|
186
|
-
result.loading) {
|
|
187
|
-
obsQuery.setOptions(createWatchQueryOptions(query, options)).catch(function () { });
|
|
172
|
+
if (context$1.renderPromises && (options === null || options === void 0 ? void 0 : options.ssr) !== false && result.loading) {
|
|
173
|
+
obsQuery.setOptions(createWatchQueryOptions(query, options))
|
|
174
|
+
.catch(function () { });
|
|
188
175
|
}
|
|
189
176
|
}
|
|
190
|
-
|
|
191
|
-
(options === null || options === void 0 ? void 0 : options.ssr) === false) {
|
|
192
|
-
result = ref.current.result = {
|
|
193
|
-
loading: true,
|
|
194
|
-
data: void 0,
|
|
195
|
-
error: void 0,
|
|
196
|
-
networkStatus: core.NetworkStatus.loading,
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
else if ((options === null || options === void 0 ? void 0 : options.skip) || (options === null || options === void 0 ? void 0 : options.fetchPolicy) === 'standby') {
|
|
200
|
-
result = {
|
|
201
|
-
loading: false,
|
|
202
|
-
data: void 0,
|
|
203
|
-
error: void 0,
|
|
204
|
-
networkStatus: core.NetworkStatus.ready,
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
if (result.errors && result.errors.length) {
|
|
208
|
-
result = tslib.__assign(tslib.__assign({}, result), { error: result.error || new errors.ApolloError({ graphQLErrors: result.errors }) });
|
|
209
|
-
}
|
|
210
|
-
var obsQueryFields = react.useMemo(function () { return ({
|
|
211
|
-
refetch: obsQuery.refetch.bind(obsQuery),
|
|
212
|
-
fetchMore: obsQuery.fetchMore.bind(obsQuery),
|
|
213
|
-
updateQuery: obsQuery.updateQuery.bind(obsQuery),
|
|
214
|
-
startPolling: obsQuery.startPolling.bind(obsQuery),
|
|
215
|
-
stopPolling: obsQuery.stopPolling.bind(obsQuery),
|
|
216
|
-
subscribeToMore: obsQuery.subscribeToMore.bind(obsQuery),
|
|
217
|
-
}); }, [obsQuery]);
|
|
218
|
-
return tslib.__assign(tslib.__assign(tslib.__assign({}, obsQueryFields), { variables: obsQuery.variables, client: client, called: true, previousData: ref.current.previousData }), result);
|
|
177
|
+
return tslib.__assign(tslib.__assign(tslib.__assign({}, obsQueryMethods), { variables: obsQuery.variables, client: client, called: true }), result);
|
|
219
178
|
}
|
|
220
179
|
function createWatchQueryOptions(query, options) {
|
|
221
180
|
var _a;
|
|
@@ -333,13 +292,13 @@ function useMutation(mutation, options) {
|
|
|
333
292
|
var mutationId = ++ref.current.mutationId;
|
|
334
293
|
var clientOptions = core.mergeOptions(baseOptions, executeOptions);
|
|
335
294
|
return client.mutate(clientOptions).then(function (response) {
|
|
336
|
-
var _a;
|
|
295
|
+
var _a, _b;
|
|
337
296
|
var data = response.data, errors$1 = response.errors;
|
|
338
297
|
var error = errors$1 && errors$1.length > 0
|
|
339
298
|
? new errors.ApolloError({ graphQLErrors: errors$1 })
|
|
340
299
|
: void 0;
|
|
341
300
|
if (mutationId === ref.current.mutationId &&
|
|
342
|
-
!
|
|
301
|
+
!clientOptions.ignoreResults) {
|
|
343
302
|
var result_1 = {
|
|
344
303
|
called: true,
|
|
345
304
|
loading: false,
|
|
@@ -352,8 +311,10 @@ function useMutation(mutation, options) {
|
|
|
352
311
|
}
|
|
353
312
|
}
|
|
354
313
|
(_a = baseOptions.onCompleted) === null || _a === void 0 ? void 0 : _a.call(baseOptions, response.data);
|
|
314
|
+
(_b = executeOptions.onCompleted) === null || _b === void 0 ? void 0 : _b.call(executeOptions, response.data);
|
|
355
315
|
return response;
|
|
356
316
|
}).catch(function (error) {
|
|
317
|
+
var _a, _b;
|
|
357
318
|
if (mutationId === ref.current.mutationId &&
|
|
358
319
|
ref.current.isMounted) {
|
|
359
320
|
var result_2 = {
|
|
@@ -367,8 +328,9 @@ function useMutation(mutation, options) {
|
|
|
367
328
|
setResult(ref.current.result = result_2);
|
|
368
329
|
}
|
|
369
330
|
}
|
|
370
|
-
if (baseOptions.onError) {
|
|
371
|
-
baseOptions.onError(error);
|
|
331
|
+
if (baseOptions.onError || clientOptions.onError) {
|
|
332
|
+
(_a = baseOptions.onError) === null || _a === void 0 ? void 0 : _a.call(baseOptions, error);
|
|
333
|
+
(_b = executeOptions.onError) === null || _b === void 0 ? void 0 : _b.call(executeOptions, error);
|
|
372
334
|
return { data: void 0, errors: error };
|
|
373
335
|
}
|
|
374
336
|
throw error;
|