@apollo/client 3.6.3 → 3.6.6
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 +123 -48
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +9 -10
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +2288 -0
- package/cache/inmemory/readFromStore.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.js +10 -11
- package/cache/inmemory/readFromStore.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/core.cjs +2 -2
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +2141 -0
- package/errors/errors.cjs.native.js +48 -0
- package/invariantErrorCodes.js +1 -1
- package/link/batch/batch.cjs.native.js +161 -0
- package/link/batch-http/batch-http.cjs.native.js +127 -0
- package/link/context/context.cjs.native.js +38 -0
- package/link/core/core.cjs.native.js +121 -0
- package/link/error/error.cjs.native.js +90 -0
- package/link/http/http.cjs.native.js +320 -0
- package/link/persisted-queries/persisted-queries.cjs.native.js +174 -0
- package/link/retry/retry.cjs.native.js +170 -0
- package/link/schema/schema.cjs.native.js +56 -0
- package/link/subscriptions/subscriptions.cjs.native.js +45 -0
- package/link/utils/utils.cjs.native.js +115 -0
- package/link/ws/ws.cjs.native.js +28 -0
- package/main.cjs.native.js +16 -0
- package/package.json +16 -17
- package/react/components/components.cjs.native.js +79 -0
- package/react/context/context.cjs.native.js +67 -0
- package/react/hoc/hoc.cjs.native.js +325 -0
- package/react/hooks/hooks.cjs +130 -43
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +623 -0
- package/react/hooks/useLazyQuery.d.ts.map +1 -1
- package/react/hooks/useLazyQuery.js +5 -1
- package/react/hooks/useLazyQuery.js.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 +22 -6
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts.map +1 -1
- package/react/hooks/useSubscription.js +17 -7
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSyncExternalStore.d.ts +4 -0
- package/react/hooks/useSyncExternalStore.d.ts.map +1 -0
- package/react/hooks/useSyncExternalStore.js +48 -0
- package/react/hooks/useSyncExternalStore.js.map +1 -0
- package/react/parser/parser.cjs.native.js +103 -0
- package/react/react.cjs.native.js +22 -0
- package/react/ssr/ssr.cjs.native.js +150 -0
- package/testing/core/core.cjs.native.js +288 -0
- package/testing/testing.cjs.native.js +58 -0
- package/utilities/common/canUse.d.ts +2 -0
- package/utilities/common/canUse.d.ts.map +1 -1
- package/utilities/common/canUse.js +6 -2
- package/utilities/common/canUse.js.map +1 -1
- package/utilities/common/mergeDeep.d.ts.map +1 -1
- package/utilities/common/mergeDeep.js +8 -11
- package/utilities/common/mergeDeep.js.map +1 -1
- package/utilities/globals/globals.cjs.native.js +56 -0
- package/utilities/observables/Concast.d.ts.map +1 -1
- package/utilities/observables/Concast.js +5 -2
- package/utilities/observables/Concast.js.map +1 -1
- package/utilities/policies/pagination.d.ts.map +1 -1
- package/utilities/policies/pagination.js +9 -7
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/utilities.cjs +29 -22
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +1281 -0
- package/version.js +1 -1
package/apollo-client.cjs
CHANGED
|
@@ -13,7 +13,6 @@ var context = require('@wry/context');
|
|
|
13
13
|
var trie = require('@wry/trie');
|
|
14
14
|
var graphqlTag = require('graphql-tag');
|
|
15
15
|
var React = require('react');
|
|
16
|
-
var index_js = require('use-sync-external-store/shim/index.js');
|
|
17
16
|
|
|
18
17
|
function _interopNamespace(e) {
|
|
19
18
|
if (e && e.__esModule) return e;
|
|
@@ -762,18 +761,15 @@ var DeepMerger = (function () {
|
|
|
762
761
|
};
|
|
763
762
|
DeepMerger.prototype.shallowCopyForMerge = function (value) {
|
|
764
763
|
if (isNonNullObject(value)) {
|
|
765
|
-
if (this.pastCopies.has(value)) {
|
|
766
|
-
if (
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
else {
|
|
774
|
-
value = tslib.__assign({ __proto__: Object.getPrototypeOf(value) }, value);
|
|
764
|
+
if (!this.pastCopies.has(value)) {
|
|
765
|
+
if (Array.isArray(value)) {
|
|
766
|
+
value = value.slice(0);
|
|
767
|
+
}
|
|
768
|
+
else {
|
|
769
|
+
value = tslib.__assign({ __proto__: Object.getPrototypeOf(value) }, value);
|
|
770
|
+
}
|
|
771
|
+
this.pastCopies.add(value);
|
|
775
772
|
}
|
|
776
|
-
this.pastCopies.add(value);
|
|
777
773
|
}
|
|
778
774
|
return value;
|
|
779
775
|
};
|
|
@@ -899,11 +895,14 @@ function asyncMap(observable, mapFn, catchFn) {
|
|
|
899
895
|
});
|
|
900
896
|
}
|
|
901
897
|
|
|
902
|
-
var canUseWeakMap = typeof WeakMap === 'function' &&
|
|
903
|
-
navigator.product
|
|
898
|
+
var canUseWeakMap = typeof WeakMap === 'function' &&
|
|
899
|
+
maybe(function () { return navigator.product; }) !== 'ReactNative';
|
|
904
900
|
var canUseWeakSet = typeof WeakSet === 'function';
|
|
905
901
|
var canUseSymbol = typeof Symbol === 'function' &&
|
|
906
902
|
typeof Symbol.for === 'function';
|
|
903
|
+
var canUseDOM = typeof maybe(function () { return window.document.createElement; }) === "function";
|
|
904
|
+
var usingJSDOM = maybe(function () { return navigator.userAgent.indexOf("jsdom") >= 0; }) || false;
|
|
905
|
+
var canUseLayoutEffect = canUseDOM && !usingJSDOM;
|
|
907
906
|
|
|
908
907
|
function fixObservableSubclass(subclass) {
|
|
909
908
|
function set(key) {
|
|
@@ -951,9 +950,12 @@ var Concast = (function (_super) {
|
|
|
951
950
|
}
|
|
952
951
|
},
|
|
953
952
|
complete: function () {
|
|
954
|
-
|
|
953
|
+
var sub = _this.sub;
|
|
954
|
+
if (sub !== null) {
|
|
955
955
|
var value = _this.sources.shift();
|
|
956
956
|
if (!value) {
|
|
957
|
+
if (sub)
|
|
958
|
+
setTimeout(function () { return sub.unsubscribe(); });
|
|
957
959
|
_this.sub = null;
|
|
958
960
|
if (_this.latest &&
|
|
959
961
|
_this.latest[0] === "next") {
|
|
@@ -1021,7 +1023,7 @@ var Concast = (function (_super) {
|
|
|
1021
1023
|
if (this.observers.delete(observer) &&
|
|
1022
1024
|
--this.addCount < 1 &&
|
|
1023
1025
|
!quietly) {
|
|
1024
|
-
this.handlers.
|
|
1026
|
+
this.handlers.complete();
|
|
1025
1027
|
}
|
|
1026
1028
|
};
|
|
1027
1029
|
Concast.prototype.cleanup = function (callback) {
|
|
@@ -1298,7 +1300,7 @@ var concat = ApolloLink.concat;
|
|
|
1298
1300
|
|
|
1299
1301
|
var execute = ApolloLink.execute;
|
|
1300
1302
|
|
|
1301
|
-
var version = '3.6.
|
|
1303
|
+
var version = '3.6.6';
|
|
1302
1304
|
|
|
1303
1305
|
var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
1304
1306
|
function parseAndCheckHttpResponse(operations) {
|
|
@@ -2391,7 +2393,6 @@ var StoreReader = (function () {
|
|
|
2391
2393
|
var policies = this.config.cache.policies;
|
|
2392
2394
|
variables = tslib.__assign(tslib.__assign({}, getDefaultValues(getQueryDefinition(query))), variables);
|
|
2393
2395
|
var rootRef = makeReference(rootId);
|
|
2394
|
-
var merger = new DeepMerger;
|
|
2395
2396
|
var execResult = this.executeSelectionSet({
|
|
2396
2397
|
selectionSet: getMainDefinition(query).selectionSet,
|
|
2397
2398
|
objectOrReference: rootRef,
|
|
@@ -2404,9 +2405,6 @@ var StoreReader = (function () {
|
|
|
2404
2405
|
varString: canonicalStringify(variables),
|
|
2405
2406
|
canonizeResults: canonizeResults,
|
|
2406
2407
|
fragmentMap: createFragmentMap(getFragmentDefinitions(query)),
|
|
2407
|
-
merge: function (a, b) {
|
|
2408
|
-
return merger.merge(a, b);
|
|
2409
|
-
},
|
|
2410
2408
|
},
|
|
2411
2409
|
});
|
|
2412
2410
|
var missing;
|
|
@@ -2445,17 +2443,18 @@ var StoreReader = (function () {
|
|
|
2445
2443
|
}
|
|
2446
2444
|
var variables = context.variables, policies = context.policies, store = context.store;
|
|
2447
2445
|
var typename = store.getFieldValue(objectOrReference, "__typename");
|
|
2448
|
-
var
|
|
2446
|
+
var objectsToMerge = [];
|
|
2449
2447
|
var missing;
|
|
2448
|
+
var missingMerger = new DeepMerger();
|
|
2450
2449
|
if (this.config.addTypename &&
|
|
2451
2450
|
typeof typename === "string" &&
|
|
2452
2451
|
!policies.rootIdsByTypename[typename]) {
|
|
2453
|
-
|
|
2452
|
+
objectsToMerge.push({ __typename: typename });
|
|
2454
2453
|
}
|
|
2455
2454
|
function handleMissing(result, resultName) {
|
|
2456
2455
|
var _a;
|
|
2457
2456
|
if (result.missing) {
|
|
2458
|
-
missing =
|
|
2457
|
+
missing = missingMerger.merge(missing, (_a = {}, _a[resultName] = result.missing, _a));
|
|
2459
2458
|
}
|
|
2460
2459
|
return result.result;
|
|
2461
2460
|
}
|
|
@@ -2474,7 +2473,7 @@ var StoreReader = (function () {
|
|
|
2474
2473
|
var resultName = resultKeyNameFromField(selection);
|
|
2475
2474
|
if (fieldValue === void 0) {
|
|
2476
2475
|
if (!addTypenameToDocument.added(selection)) {
|
|
2477
|
-
missing =
|
|
2476
|
+
missing = missingMerger.merge(missing, (_a = {},
|
|
2478
2477
|
_a[resultName] = "Can't find field '".concat(selection.name.value, "' on ").concat(isReference(objectOrReference)
|
|
2479
2478
|
? objectOrReference.__ref + " object"
|
|
2480
2479
|
: "object " + JSON.stringify(objectOrReference, null, 2)),
|
|
@@ -2503,7 +2502,7 @@ var StoreReader = (function () {
|
|
|
2503
2502
|
}), resultName);
|
|
2504
2503
|
}
|
|
2505
2504
|
if (fieldValue !== void 0) {
|
|
2506
|
-
|
|
2505
|
+
objectsToMerge.push((_b = {}, _b[resultName] = fieldValue, _b));
|
|
2507
2506
|
}
|
|
2508
2507
|
}
|
|
2509
2508
|
else {
|
|
@@ -2513,6 +2512,7 @@ var StoreReader = (function () {
|
|
|
2513
2512
|
}
|
|
2514
2513
|
}
|
|
2515
2514
|
});
|
|
2515
|
+
var result = mergeDeepArray(objectsToMerge);
|
|
2516
2516
|
var finalResult = { result: result, missing: missing };
|
|
2517
2517
|
var frozen = context.canonizeResults
|
|
2518
2518
|
? this.canon.admit(finalResult)
|
|
@@ -2526,10 +2526,11 @@ var StoreReader = (function () {
|
|
|
2526
2526
|
var _this = this;
|
|
2527
2527
|
var field = _a.field, array = _a.array, enclosingRef = _a.enclosingRef, context = _a.context;
|
|
2528
2528
|
var missing;
|
|
2529
|
+
var missingMerger = new DeepMerger();
|
|
2529
2530
|
function handleMissing(childResult, i) {
|
|
2530
2531
|
var _a;
|
|
2531
2532
|
if (childResult.missing) {
|
|
2532
|
-
missing =
|
|
2533
|
+
missing = missingMerger.merge(missing, (_a = {}, _a[i] = childResult.missing, _a));
|
|
2533
2534
|
}
|
|
2534
2535
|
return childResult.result;
|
|
2535
2536
|
}
|
|
@@ -4302,7 +4303,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4302
4303
|
newNetworkStatus === exports.NetworkStatus.poll;
|
|
4303
4304
|
var oldVariables = this.options.variables;
|
|
4304
4305
|
var oldFetchPolicy = this.options.fetchPolicy;
|
|
4305
|
-
var mergedOptions =
|
|
4306
|
+
var mergedOptions = compact(this.options, newOptions || {});
|
|
4306
4307
|
var options = useDisposableConcast
|
|
4307
4308
|
? mergedOptions
|
|
4308
4309
|
: assign(this.options, mergedOptions);
|
|
@@ -6036,6 +6037,51 @@ function useApolloClient(override) {
|
|
|
6036
6037
|
return client;
|
|
6037
6038
|
}
|
|
6038
6039
|
|
|
6040
|
+
var didWarnUncachedGetSnapshot = false;
|
|
6041
|
+
var uSESKey = "useSyncExternalStore";
|
|
6042
|
+
var realHook = React__namespace[uSESKey];
|
|
6043
|
+
var useSyncExternalStore = realHook || (function (subscribe, getSnapshot, getServerSnapshot) {
|
|
6044
|
+
var value = getSnapshot();
|
|
6045
|
+
if (__DEV__ &&
|
|
6046
|
+
!didWarnUncachedGetSnapshot &&
|
|
6047
|
+
value !== getSnapshot()) {
|
|
6048
|
+
didWarnUncachedGetSnapshot = true;
|
|
6049
|
+
__DEV__ && tsInvariant.invariant.error('The result of getSnapshot should be cached to avoid an infinite loop');
|
|
6050
|
+
}
|
|
6051
|
+
var _a = React__namespace.useState({ inst: { value: value, getSnapshot: getSnapshot } }), inst = _a[0].inst, forceUpdate = _a[1];
|
|
6052
|
+
if (canUseLayoutEffect) {
|
|
6053
|
+
React__namespace.useLayoutEffect(function () {
|
|
6054
|
+
Object.assign(inst, { value: value, getSnapshot: getSnapshot });
|
|
6055
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
6056
|
+
forceUpdate({ inst: inst });
|
|
6057
|
+
}
|
|
6058
|
+
}, [subscribe, value, getSnapshot]);
|
|
6059
|
+
}
|
|
6060
|
+
else {
|
|
6061
|
+
Object.assign(inst, { value: value, getSnapshot: getSnapshot });
|
|
6062
|
+
}
|
|
6063
|
+
React__namespace.useEffect(function () {
|
|
6064
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
6065
|
+
forceUpdate({ inst: inst });
|
|
6066
|
+
}
|
|
6067
|
+
return subscribe(function handleStoreChange() {
|
|
6068
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
6069
|
+
forceUpdate({ inst: inst });
|
|
6070
|
+
}
|
|
6071
|
+
});
|
|
6072
|
+
}, [subscribe]);
|
|
6073
|
+
return value;
|
|
6074
|
+
});
|
|
6075
|
+
function checkIfSnapshotChanged(_a) {
|
|
6076
|
+
var value = _a.value, getSnapshot = _a.getSnapshot;
|
|
6077
|
+
try {
|
|
6078
|
+
return value !== getSnapshot();
|
|
6079
|
+
}
|
|
6080
|
+
catch (_b) {
|
|
6081
|
+
return true;
|
|
6082
|
+
}
|
|
6083
|
+
}
|
|
6084
|
+
|
|
6039
6085
|
exports.DocumentType = void 0;
|
|
6040
6086
|
(function (DocumentType) {
|
|
6041
6087
|
DocumentType[DocumentType["Query"] = 0] = "Query";
|
|
@@ -6139,7 +6185,7 @@ function useInternalState(client, query) {
|
|
|
6139
6185
|
if (!stateRef.current ||
|
|
6140
6186
|
client !== stateRef.current.client ||
|
|
6141
6187
|
query !== stateRef.current.query) {
|
|
6142
|
-
stateRef.current = new InternalState(client, query);
|
|
6188
|
+
stateRef.current = new InternalState(client, query, stateRef.current);
|
|
6143
6189
|
}
|
|
6144
6190
|
var state = stateRef.current;
|
|
6145
6191
|
var _a = React.useState(0); _a[0]; var setTick = _a[1];
|
|
@@ -6149,7 +6195,7 @@ function useInternalState(client, query) {
|
|
|
6149
6195
|
return state;
|
|
6150
6196
|
}
|
|
6151
6197
|
var InternalState = (function () {
|
|
6152
|
-
function InternalState(client, query) {
|
|
6198
|
+
function InternalState(client, query, previous) {
|
|
6153
6199
|
this.client = client;
|
|
6154
6200
|
this.query = query;
|
|
6155
6201
|
this.asyncResolveFns = new Set();
|
|
@@ -6168,6 +6214,11 @@ var InternalState = (function () {
|
|
|
6168
6214
|
});
|
|
6169
6215
|
this.toQueryResultCache = new (canUseWeakMap ? WeakMap : Map)();
|
|
6170
6216
|
verifyDocumentType(query, exports.DocumentType.Query);
|
|
6217
|
+
var previousResult = previous && previous.result;
|
|
6218
|
+
var previousData = previousResult && previousResult.data;
|
|
6219
|
+
if (previousData) {
|
|
6220
|
+
this.previousData = previousData;
|
|
6221
|
+
}
|
|
6171
6222
|
}
|
|
6172
6223
|
InternalState.prototype.forceUpdate = function () {
|
|
6173
6224
|
__DEV__ && tsInvariant.invariant.warn("Calling default no-op implementation of InternalState#forceUpdate");
|
|
@@ -6185,7 +6236,7 @@ var InternalState = (function () {
|
|
|
6185
6236
|
this.renderPromises = React.useContext(getApolloContext()).renderPromises;
|
|
6186
6237
|
this.useOptions(options);
|
|
6187
6238
|
var obsQuery = this.useObservableQuery();
|
|
6188
|
-
var result =
|
|
6239
|
+
var result = useSyncExternalStore(React.useCallback(function () {
|
|
6189
6240
|
if (_this.renderPromises) {
|
|
6190
6241
|
return function () { };
|
|
6191
6242
|
}
|
|
@@ -6249,7 +6300,7 @@ var InternalState = (function () {
|
|
|
6249
6300
|
this.watchQueryOptions = watchQueryOptions;
|
|
6250
6301
|
if (currentWatchQueryOptions && this.observable) {
|
|
6251
6302
|
this.optionsToIgnoreOnce.delete(currentWatchQueryOptions);
|
|
6252
|
-
this.observable.reobserve(
|
|
6303
|
+
this.observable.reobserve(this.getObsQueryOptions());
|
|
6253
6304
|
this.previousData = ((_a = this.result) === null || _a === void 0 ? void 0 : _a.data) || this.previousData;
|
|
6254
6305
|
this.result = void 0;
|
|
6255
6306
|
}
|
|
@@ -6270,6 +6321,17 @@ var InternalState = (function () {
|
|
|
6270
6321
|
this.result = void 0;
|
|
6271
6322
|
}
|
|
6272
6323
|
};
|
|
6324
|
+
InternalState.prototype.getObsQueryOptions = function () {
|
|
6325
|
+
var toMerge = [];
|
|
6326
|
+
var globalDefaults = this.client.defaultOptions.watchQuery;
|
|
6327
|
+
if (globalDefaults)
|
|
6328
|
+
toMerge.push(globalDefaults);
|
|
6329
|
+
if (this.queryHookOptions.defaultOptions) {
|
|
6330
|
+
toMerge.push(this.queryHookOptions.defaultOptions);
|
|
6331
|
+
}
|
|
6332
|
+
toMerge.push(compact(this.observable && this.observable.options, this.watchQueryOptions));
|
|
6333
|
+
return toMerge.reduce(mergeOptions);
|
|
6334
|
+
};
|
|
6273
6335
|
InternalState.prototype.createWatchQueryOptions = function (_a) {
|
|
6274
6336
|
var _b;
|
|
6275
6337
|
if (_a === void 0) { _a = {}; }
|
|
@@ -6310,7 +6372,7 @@ var InternalState = (function () {
|
|
|
6310
6372
|
this.renderPromises
|
|
6311
6373
|
&& this.renderPromises.getSSRObservable(this.watchQueryOptions)
|
|
6312
6374
|
|| this.observable
|
|
6313
|
-
|| this.client.watchQuery(
|
|
6375
|
+
|| this.client.watchQuery(this.getObsQueryOptions());
|
|
6314
6376
|
this.obsQueryFields = React.useMemo(function () { return ({
|
|
6315
6377
|
refetch: obsQuery.refetch.bind(obsQuery),
|
|
6316
6378
|
reobserve: obsQuery.reobserve.bind(obsQuery),
|
|
@@ -6393,7 +6455,10 @@ var EAGER_METHODS = [
|
|
|
6393
6455
|
function useLazyQuery(query, options) {
|
|
6394
6456
|
var internalState = useInternalState(useApolloClient(options && options.client), query);
|
|
6395
6457
|
var execOptionsRef = React.useRef();
|
|
6396
|
-
var
|
|
6458
|
+
var merged = execOptionsRef.current
|
|
6459
|
+
? mergeOptions(options, execOptionsRef.current)
|
|
6460
|
+
: options;
|
|
6461
|
+
var useQueryResult = internalState.useQuery(tslib.__assign(tslib.__assign({}, merged), { skip: !execOptionsRef.current }));
|
|
6397
6462
|
var initialFetchPolicy = useQueryResult.observable.options.initialFetchPolicy ||
|
|
6398
6463
|
internalState.getDefaultFetchPolicy();
|
|
6399
6464
|
var result = Object.assign(useQueryResult, {
|
|
@@ -6466,7 +6531,7 @@ function useMutation(mutation, options) {
|
|
|
6466
6531
|
var mutationId = ++ref.current.mutationId;
|
|
6467
6532
|
var clientOptions = mergeOptions(baseOptions, executeOptions);
|
|
6468
6533
|
return client.mutate(clientOptions).then(function (response) {
|
|
6469
|
-
var _a, _b;
|
|
6534
|
+
var _a, _b, _c;
|
|
6470
6535
|
var data = response.data, errors = response.errors;
|
|
6471
6536
|
var error = errors && errors.length > 0
|
|
6472
6537
|
? new ApolloError({ graphQLErrors: errors })
|
|
@@ -6484,11 +6549,11 @@ function useMutation(mutation, options) {
|
|
|
6484
6549
|
setResult(ref.current.result = result_1);
|
|
6485
6550
|
}
|
|
6486
6551
|
}
|
|
6487
|
-
(_a =
|
|
6488
|
-
(
|
|
6552
|
+
(_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onCompleted) === null || _b === void 0 ? void 0 : _b.call(_a, response.data);
|
|
6553
|
+
(_c = executeOptions.onCompleted) === null || _c === void 0 ? void 0 : _c.call(executeOptions, response.data);
|
|
6489
6554
|
return response;
|
|
6490
6555
|
}).catch(function (error) {
|
|
6491
|
-
var _a, _b;
|
|
6556
|
+
var _a, _b, _c, _d;
|
|
6492
6557
|
if (mutationId === ref.current.mutationId &&
|
|
6493
6558
|
ref.current.isMounted) {
|
|
6494
6559
|
var result_2 = {
|
|
@@ -6502,9 +6567,9 @@ function useMutation(mutation, options) {
|
|
|
6502
6567
|
setResult(ref.current.result = result_2);
|
|
6503
6568
|
}
|
|
6504
6569
|
}
|
|
6505
|
-
if (
|
|
6506
|
-
(
|
|
6507
|
-
(
|
|
6570
|
+
if (((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError) || clientOptions.onError) {
|
|
6571
|
+
(_c = (_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.onError) === null || _c === void 0 ? void 0 : _c.call(_b, error);
|
|
6572
|
+
(_d = executeOptions.onError) === null || _d === void 0 ? void 0 : _d.call(executeOptions, error);
|
|
6508
6573
|
return { data: void 0, errors: error };
|
|
6509
6574
|
}
|
|
6510
6575
|
throw error;
|
|
@@ -6542,6 +6607,12 @@ function useSubscription(subscription, options) {
|
|
|
6542
6607
|
context: options === null || options === void 0 ? void 0 : options.context,
|
|
6543
6608
|
});
|
|
6544
6609
|
}), observable = _b[0], setObservable = _b[1];
|
|
6610
|
+
var canResetObservableRef = React.useRef(false);
|
|
6611
|
+
React.useEffect(function () {
|
|
6612
|
+
return function () {
|
|
6613
|
+
canResetObservableRef.current = true;
|
|
6614
|
+
};
|
|
6615
|
+
}, []);
|
|
6545
6616
|
var ref = React.useRef({ client: client, subscription: subscription, options: options });
|
|
6546
6617
|
React.useEffect(function () {
|
|
6547
6618
|
var _a, _b, _c, _d;
|
|
@@ -6550,7 +6621,7 @@ function useSubscription(subscription, options) {
|
|
|
6550
6621
|
shouldResubscribe = !!shouldResubscribe(options);
|
|
6551
6622
|
}
|
|
6552
6623
|
if (options === null || options === void 0 ? void 0 : options.skip) {
|
|
6553
|
-
if (!(options === null || options === void 0 ? void 0 : options.skip) !== !((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.skip)) {
|
|
6624
|
+
if (!(options === null || options === void 0 ? void 0 : options.skip) !== !((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.skip) || canResetObservableRef.current) {
|
|
6554
6625
|
setResult({
|
|
6555
6626
|
loading: false,
|
|
6556
6627
|
data: void 0,
|
|
@@ -6558,13 +6629,16 @@ function useSubscription(subscription, options) {
|
|
|
6558
6629
|
variables: options === null || options === void 0 ? void 0 : options.variables,
|
|
6559
6630
|
});
|
|
6560
6631
|
setObservable(null);
|
|
6632
|
+
canResetObservableRef.current = false;
|
|
6561
6633
|
}
|
|
6562
6634
|
}
|
|
6563
|
-
else if (shouldResubscribe !== false &&
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6635
|
+
else if ((shouldResubscribe !== false &&
|
|
6636
|
+
(client !== ref.current.client ||
|
|
6637
|
+
subscription !== ref.current.subscription ||
|
|
6638
|
+
(options === null || options === void 0 ? void 0 : options.fetchPolicy) !== ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.fetchPolicy) ||
|
|
6639
|
+
!(options === null || options === void 0 ? void 0 : options.skip) !== !((_c = ref.current.options) === null || _c === void 0 ? void 0 : _c.skip) ||
|
|
6640
|
+
!equality.equal(options === null || options === void 0 ? void 0 : options.variables, (_d = ref.current.options) === null || _d === void 0 ? void 0 : _d.variables))) ||
|
|
6641
|
+
canResetObservableRef.current) {
|
|
6568
6642
|
setResult({
|
|
6569
6643
|
loading: true,
|
|
6570
6644
|
data: void 0,
|
|
@@ -6577,9 +6651,10 @@ function useSubscription(subscription, options) {
|
|
|
6577
6651
|
fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
|
|
6578
6652
|
context: options === null || options === void 0 ? void 0 : options.context,
|
|
6579
6653
|
}));
|
|
6654
|
+
canResetObservableRef.current = false;
|
|
6580
6655
|
}
|
|
6581
6656
|
Object.assign(ref.current, { client: client, subscription: subscription, options: options });
|
|
6582
|
-
}, [client, subscription, options]);
|
|
6657
|
+
}, [client, subscription, options, canResetObservableRef.current]);
|
|
6583
6658
|
React.useEffect(function () {
|
|
6584
6659
|
if (!observable) {
|
|
6585
6660
|
return;
|