@apollo/client 3.7.0-alpha.2 → 3.7.0-alpha.5
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 +126 -58
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs.native.js +2289 -0
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +1 -1
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +4 -3
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +5 -4
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +2142 -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/http/selectHttpOptionsAndBody.d.ts.map +1 -1
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- 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 +13 -14
- 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 +131 -54
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +604 -0
- package/react/hooks/useLazyQuery.d.ts.map +1 -1
- package/react/hooks/useLazyQuery.js +5 -17
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useQuery.d.ts +3 -0
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +29 -9
- 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/globals/globals.cjs.native.js +56 -0
- package/utilities/observables/Concast.d.ts +5 -3
- package/utilities/observables/Concast.d.ts.map +1 -1
- package/utilities/observables/Concast.js +22 -21
- 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 +38 -30
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +1282 -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;
|
|
@@ -899,11 +898,14 @@ function asyncMap(observable, mapFn, catchFn) {
|
|
|
899
898
|
});
|
|
900
899
|
}
|
|
901
900
|
|
|
902
|
-
var canUseWeakMap = typeof WeakMap === 'function' &&
|
|
903
|
-
navigator.product
|
|
901
|
+
var canUseWeakMap = typeof WeakMap === 'function' &&
|
|
902
|
+
maybe(function () { return navigator.product; }) !== 'ReactNative';
|
|
904
903
|
var canUseWeakSet = typeof WeakSet === 'function';
|
|
905
904
|
var canUseSymbol = typeof Symbol === 'function' &&
|
|
906
905
|
typeof Symbol.for === 'function';
|
|
906
|
+
var canUseDOM = typeof maybe(function () { return window.document.createElement; }) === "function";
|
|
907
|
+
var usingJSDOM = maybe(function () { return navigator.userAgent.indexOf("jsdom") >= 0; }) || false;
|
|
908
|
+
var canUseLayoutEffect = canUseDOM && !usingJSDOM;
|
|
907
909
|
|
|
908
910
|
function fixObservableSubclass(subclass) {
|
|
909
911
|
function set(key) {
|
|
@@ -927,7 +929,6 @@ var Concast = (function (_super) {
|
|
|
927
929
|
return function () { return _this.removeObserver(observer); };
|
|
928
930
|
}) || this;
|
|
929
931
|
_this.observers = new Set();
|
|
930
|
-
_this.addCount = 0;
|
|
931
932
|
_this.promise = new Promise(function (resolve, reject) {
|
|
932
933
|
_this.resolve = resolve;
|
|
933
934
|
_this.reject = reject;
|
|
@@ -936,6 +937,7 @@ var Concast = (function (_super) {
|
|
|
936
937
|
next: function (result) {
|
|
937
938
|
if (_this.sub !== null) {
|
|
938
939
|
_this.latest = ["next", result];
|
|
940
|
+
_this.notify("next", result);
|
|
939
941
|
iterateObserversSafely(_this.observers, "next", result);
|
|
940
942
|
}
|
|
941
943
|
},
|
|
@@ -947,13 +949,17 @@ var Concast = (function (_super) {
|
|
|
947
949
|
_this.sub = null;
|
|
948
950
|
_this.latest = ["error", error];
|
|
949
951
|
_this.reject(error);
|
|
952
|
+
_this.notify("error", error);
|
|
950
953
|
iterateObserversSafely(_this.observers, "error", error);
|
|
951
954
|
}
|
|
952
955
|
},
|
|
953
956
|
complete: function () {
|
|
954
|
-
|
|
957
|
+
var sub = _this.sub;
|
|
958
|
+
if (sub !== null) {
|
|
955
959
|
var value = _this.sources.shift();
|
|
956
960
|
if (!value) {
|
|
961
|
+
if (sub)
|
|
962
|
+
setTimeout(function () { return sub.unsubscribe(); });
|
|
957
963
|
_this.sub = null;
|
|
958
964
|
if (_this.latest &&
|
|
959
965
|
_this.latest[0] === "next") {
|
|
@@ -962,6 +968,7 @@ var Concast = (function (_super) {
|
|
|
962
968
|
else {
|
|
963
969
|
_this.resolve();
|
|
964
970
|
}
|
|
971
|
+
_this.notify("complete");
|
|
965
972
|
iterateObserversSafely(_this.observers, "complete");
|
|
966
973
|
}
|
|
967
974
|
else if (isPromiseLike(value)) {
|
|
@@ -973,6 +980,7 @@ var Concast = (function (_super) {
|
|
|
973
980
|
}
|
|
974
981
|
},
|
|
975
982
|
};
|
|
983
|
+
_this.nextResultListeners = new Set();
|
|
976
984
|
_this.cancel = function (reason) {
|
|
977
985
|
_this.reject(reason);
|
|
978
986
|
_this.sources = [];
|
|
@@ -1014,34 +1022,29 @@ var Concast = (function (_super) {
|
|
|
1014
1022
|
if (!this.observers.has(observer)) {
|
|
1015
1023
|
this.deliverLastMessage(observer);
|
|
1016
1024
|
this.observers.add(observer);
|
|
1017
|
-
++this.addCount;
|
|
1018
1025
|
}
|
|
1019
1026
|
};
|
|
1020
|
-
Concast.prototype.removeObserver = function (observer
|
|
1027
|
+
Concast.prototype.removeObserver = function (observer) {
|
|
1021
1028
|
if (this.observers.delete(observer) &&
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
this.handlers.error(new Error("Observable cancelled prematurely"));
|
|
1029
|
+
this.observers.size < 1) {
|
|
1030
|
+
this.handlers.complete();
|
|
1025
1031
|
}
|
|
1026
1032
|
};
|
|
1027
|
-
Concast.prototype.
|
|
1028
|
-
var
|
|
1033
|
+
Concast.prototype.notify = function (method, arg) {
|
|
1034
|
+
var nextResultListeners = this.nextResultListeners;
|
|
1035
|
+
if (nextResultListeners.size) {
|
|
1036
|
+
this.nextResultListeners = new Set;
|
|
1037
|
+
nextResultListeners.forEach(function (listener) { return listener(method, arg); });
|
|
1038
|
+
}
|
|
1039
|
+
};
|
|
1040
|
+
Concast.prototype.beforeNext = function (callback) {
|
|
1029
1041
|
var called = false;
|
|
1030
|
-
|
|
1042
|
+
this.nextResultListeners.add(function (method, arg) {
|
|
1031
1043
|
if (!called) {
|
|
1032
1044
|
called = true;
|
|
1033
|
-
|
|
1034
|
-
callback();
|
|
1045
|
+
callback(method, arg);
|
|
1035
1046
|
}
|
|
1036
|
-
};
|
|
1037
|
-
var observer = {
|
|
1038
|
-
next: once,
|
|
1039
|
-
error: once,
|
|
1040
|
-
complete: once,
|
|
1041
|
-
};
|
|
1042
|
-
var count = this.addCount;
|
|
1043
|
-
this.addObserver(observer);
|
|
1044
|
-
this.addCount = count;
|
|
1047
|
+
});
|
|
1045
1048
|
};
|
|
1046
1049
|
return Concast;
|
|
1047
1050
|
}(zenObservableTs.Observable));
|
|
@@ -1298,7 +1301,7 @@ var concat = ApolloLink.concat;
|
|
|
1298
1301
|
|
|
1299
1302
|
var execute = ApolloLink.execute;
|
|
1300
1303
|
|
|
1301
|
-
var version = '3.7.0-alpha.
|
|
1304
|
+
var version = '3.7.0-alpha.5';
|
|
1302
1305
|
|
|
1303
1306
|
var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
1304
1307
|
function parseAndCheckHttpResponse(operations) {
|
|
@@ -4330,7 +4333,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4330
4333
|
};
|
|
4331
4334
|
if (!useDisposableConcast) {
|
|
4332
4335
|
if (this.concast && this.observer) {
|
|
4333
|
-
this.concast.removeObserver(this.observer
|
|
4336
|
+
this.concast.removeObserver(this.observer);
|
|
4334
4337
|
}
|
|
4335
4338
|
this.concast = concast;
|
|
4336
4339
|
this.observer = observer;
|
|
@@ -5475,7 +5478,7 @@ var QueryManager = (function () {
|
|
|
5475
5478
|
execute(link, operation)
|
|
5476
5479
|
]);
|
|
5477
5480
|
byVariables_1.set(varJson_1, observable = concast);
|
|
5478
|
-
concast.
|
|
5481
|
+
concast.beforeNext(function () {
|
|
5479
5482
|
if (byVariables_1.delete(varJson_1) &&
|
|
5480
5483
|
byVariables_1.size < 1) {
|
|
5481
5484
|
inFlightLinkObservables_1.delete(serverQuery);
|
|
@@ -5510,6 +5513,7 @@ var QueryManager = (function () {
|
|
|
5510
5513
|
};
|
|
5511
5514
|
QueryManager.prototype.getResultsFromLink = function (queryInfo, cacheWriteBehavior, options) {
|
|
5512
5515
|
var requestId = queryInfo.lastRequestId = this.generateRequestId();
|
|
5516
|
+
options = cloneDeep(options);
|
|
5513
5517
|
return asyncMap(this.getObservableFromLink(queryInfo.document, options.context, options.variables), function (result) {
|
|
5514
5518
|
var hasErrors = isNonEmptyArray(result.errors);
|
|
5515
5519
|
if (requestId >= queryInfo.lastRequestId) {
|
|
@@ -5568,7 +5572,7 @@ var QueryManager = (function () {
|
|
|
5568
5572
|
var concast = new Concast(this.transform(normalized.query).hasClientExports
|
|
5569
5573
|
? this.localState.addExportedVariables(normalized.query, normalized.variables, normalized.context).then(fromVariables)
|
|
5570
5574
|
: fromVariables(normalized.variables));
|
|
5571
|
-
concast.
|
|
5575
|
+
concast.beforeNext(function () {
|
|
5572
5576
|
_this.fetchCancelFns.delete(queryId);
|
|
5573
5577
|
if (queryInfo.observableQuery) {
|
|
5574
5578
|
queryInfo.observableQuery["applyNextFetchPolicy"]("after-fetch", options);
|
|
@@ -6036,6 +6040,51 @@ function useApolloClient(override) {
|
|
|
6036
6040
|
return client;
|
|
6037
6041
|
}
|
|
6038
6042
|
|
|
6043
|
+
var didWarnUncachedGetSnapshot = false;
|
|
6044
|
+
var uSESKey = "useSyncExternalStore";
|
|
6045
|
+
var realHook = React__namespace[uSESKey];
|
|
6046
|
+
var useSyncExternalStore = realHook || (function (subscribe, getSnapshot, getServerSnapshot) {
|
|
6047
|
+
var value = getSnapshot();
|
|
6048
|
+
if (__DEV__ &&
|
|
6049
|
+
!didWarnUncachedGetSnapshot &&
|
|
6050
|
+
value !== getSnapshot()) {
|
|
6051
|
+
didWarnUncachedGetSnapshot = true;
|
|
6052
|
+
__DEV__ && tsInvariant.invariant.error('The result of getSnapshot should be cached to avoid an infinite loop');
|
|
6053
|
+
}
|
|
6054
|
+
var _a = React__namespace.useState({ inst: { value: value, getSnapshot: getSnapshot } }), inst = _a[0].inst, forceUpdate = _a[1];
|
|
6055
|
+
if (canUseLayoutEffect) {
|
|
6056
|
+
React__namespace.useLayoutEffect(function () {
|
|
6057
|
+
Object.assign(inst, { value: value, getSnapshot: getSnapshot });
|
|
6058
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
6059
|
+
forceUpdate({ inst: inst });
|
|
6060
|
+
}
|
|
6061
|
+
}, [subscribe, value, getSnapshot]);
|
|
6062
|
+
}
|
|
6063
|
+
else {
|
|
6064
|
+
Object.assign(inst, { value: value, getSnapshot: getSnapshot });
|
|
6065
|
+
}
|
|
6066
|
+
React__namespace.useEffect(function () {
|
|
6067
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
6068
|
+
forceUpdate({ inst: inst });
|
|
6069
|
+
}
|
|
6070
|
+
return subscribe(function handleStoreChange() {
|
|
6071
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
6072
|
+
forceUpdate({ inst: inst });
|
|
6073
|
+
}
|
|
6074
|
+
});
|
|
6075
|
+
}, [subscribe]);
|
|
6076
|
+
return value;
|
|
6077
|
+
});
|
|
6078
|
+
function checkIfSnapshotChanged(_a) {
|
|
6079
|
+
var value = _a.value, getSnapshot = _a.getSnapshot;
|
|
6080
|
+
try {
|
|
6081
|
+
return value !== getSnapshot();
|
|
6082
|
+
}
|
|
6083
|
+
catch (_b) {
|
|
6084
|
+
return true;
|
|
6085
|
+
}
|
|
6086
|
+
}
|
|
6087
|
+
|
|
6039
6088
|
exports.DocumentType = void 0;
|
|
6040
6089
|
(function (DocumentType) {
|
|
6041
6090
|
DocumentType[DocumentType["Query"] = 0] = "Query";
|
|
@@ -6152,6 +6201,8 @@ var InternalState = (function () {
|
|
|
6152
6201
|
function InternalState(client, query) {
|
|
6153
6202
|
this.client = client;
|
|
6154
6203
|
this.query = query;
|
|
6204
|
+
this.asyncResolveFns = new Set();
|
|
6205
|
+
this.optionsToIgnoreOnce = new (canUseWeakSet ? WeakSet : Set)();
|
|
6155
6206
|
this.ssrDisabledResult = maybeDeepFreeze({
|
|
6156
6207
|
loading: true,
|
|
6157
6208
|
data: void 0,
|
|
@@ -6168,13 +6219,22 @@ var InternalState = (function () {
|
|
|
6168
6219
|
verifyDocumentType(query, exports.DocumentType.Query);
|
|
6169
6220
|
}
|
|
6170
6221
|
InternalState.prototype.forceUpdate = function () {
|
|
6222
|
+
__DEV__ && tsInvariant.invariant.warn("Calling default no-op implementation of InternalState#forceUpdate");
|
|
6223
|
+
};
|
|
6224
|
+
InternalState.prototype.asyncUpdate = function () {
|
|
6225
|
+
var _this = this;
|
|
6226
|
+
return new Promise(function (resolve) {
|
|
6227
|
+
_this.asyncResolveFns.add(resolve);
|
|
6228
|
+
_this.optionsToIgnoreOnce.add(_this.watchQueryOptions);
|
|
6229
|
+
_this.forceUpdate();
|
|
6230
|
+
});
|
|
6171
6231
|
};
|
|
6172
6232
|
InternalState.prototype.useQuery = function (options) {
|
|
6173
6233
|
var _this = this;
|
|
6174
6234
|
this.renderPromises = React.useContext(getApolloContext()).renderPromises;
|
|
6175
6235
|
this.useOptions(options);
|
|
6176
6236
|
var obsQuery = this.useObservableQuery();
|
|
6177
|
-
var result =
|
|
6237
|
+
var result = useSyncExternalStore(React.useCallback(function () {
|
|
6178
6238
|
if (_this.renderPromises) {
|
|
6179
6239
|
return function () { };
|
|
6180
6240
|
}
|
|
@@ -6222,15 +6282,22 @@ var InternalState = (function () {
|
|
|
6222
6282
|
this.client.disableNetworkFetches,
|
|
6223
6283
|
]), function () { return _this.getCurrentResult(); }, function () { return _this.getCurrentResult(); });
|
|
6224
6284
|
this.unsafeHandlePartialRefetch(result);
|
|
6225
|
-
|
|
6285
|
+
var queryResult = this.toQueryResult(result);
|
|
6286
|
+
if (!queryResult.loading && this.asyncResolveFns.size) {
|
|
6287
|
+
this.asyncResolveFns.forEach(function (resolve) { return resolve(queryResult); });
|
|
6288
|
+
this.asyncResolveFns.clear();
|
|
6289
|
+
}
|
|
6290
|
+
return queryResult;
|
|
6226
6291
|
};
|
|
6227
6292
|
InternalState.prototype.useOptions = function (options) {
|
|
6228
6293
|
var _a;
|
|
6229
6294
|
var watchQueryOptions = this.createWatchQueryOptions(this.queryHookOptions = options);
|
|
6230
6295
|
var currentWatchQueryOptions = this.watchQueryOptions;
|
|
6231
|
-
if (
|
|
6296
|
+
if (this.optionsToIgnoreOnce.has(currentWatchQueryOptions) ||
|
|
6297
|
+
!equality.equal(watchQueryOptions, currentWatchQueryOptions)) {
|
|
6232
6298
|
this.watchQueryOptions = watchQueryOptions;
|
|
6233
6299
|
if (currentWatchQueryOptions && this.observable) {
|
|
6300
|
+
this.optionsToIgnoreOnce.delete(currentWatchQueryOptions);
|
|
6234
6301
|
this.observable.reobserve(watchQueryOptions);
|
|
6235
6302
|
this.previousData = ((_a = this.result) === null || _a === void 0 ? void 0 : _a.data) || this.previousData;
|
|
6236
6303
|
this.result = void 0;
|
|
@@ -6239,7 +6306,8 @@ var InternalState = (function () {
|
|
|
6239
6306
|
this.onCompleted = options.onCompleted || InternalState.prototype.onCompleted;
|
|
6240
6307
|
this.onError = options.onError || InternalState.prototype.onError;
|
|
6241
6308
|
if ((this.renderPromises || this.client.disableNetworkFetches) &&
|
|
6242
|
-
this.queryHookOptions.ssr === false
|
|
6309
|
+
this.queryHookOptions.ssr === false &&
|
|
6310
|
+
!this.queryHookOptions.skip) {
|
|
6243
6311
|
this.result = this.ssrDisabledResult;
|
|
6244
6312
|
}
|
|
6245
6313
|
else if (this.queryHookOptions.skip ||
|
|
@@ -6301,11 +6369,11 @@ var InternalState = (function () {
|
|
|
6301
6369
|
stopPolling: obsQuery.stopPolling.bind(obsQuery),
|
|
6302
6370
|
subscribeToMore: obsQuery.subscribeToMore.bind(obsQuery),
|
|
6303
6371
|
}); }, [obsQuery]);
|
|
6304
|
-
|
|
6372
|
+
var ssrAllowed = !(this.queryHookOptions.ssr === false ||
|
|
6373
|
+
this.queryHookOptions.skip);
|
|
6374
|
+
if (this.renderPromises && ssrAllowed) {
|
|
6305
6375
|
this.renderPromises.registerSSRObservable(obsQuery);
|
|
6306
|
-
|
|
6307
|
-
this.queryHookOptions.skip);
|
|
6308
|
-
if (ssrAllowed && obsQuery.getCurrentResult().loading) {
|
|
6376
|
+
if (obsQuery.getCurrentResult().loading) {
|
|
6309
6377
|
this.renderPromises.addObservableQueryPromise(obsQuery);
|
|
6310
6378
|
}
|
|
6311
6379
|
}
|
|
@@ -6400,22 +6468,12 @@ function useLazyQuery(query, options) {
|
|
|
6400
6468
|
}, []);
|
|
6401
6469
|
Object.assign(result, eagerMethods);
|
|
6402
6470
|
var execute = React.useCallback(function (executeOptions) {
|
|
6403
|
-
|
|
6471
|
+
execOptionsRef.current = executeOptions ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
|
|
6404
6472
|
fetchPolicy: initialFetchPolicy,
|
|
6405
|
-
}
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
var _a = result.observable.options.errorPolicy, errorPolicy = _a === void 0 ? "none" : _a;
|
|
6410
|
-
if (errorPolicy === "none") {
|
|
6411
|
-
throw apolloQueryResult.error || new ApolloError({
|
|
6412
|
-
graphQLErrors: apolloQueryResult.errors,
|
|
6413
|
-
});
|
|
6414
|
-
}
|
|
6415
|
-
}
|
|
6416
|
-
return internalState.toQueryResult(apolloQueryResult);
|
|
6417
|
-
}).then(function (queryResult) { return Object.assign(queryResult, eagerMethods); });
|
|
6418
|
-
internalState.forceUpdate();
|
|
6473
|
+
};
|
|
6474
|
+
var promise = internalState
|
|
6475
|
+
.asyncUpdate()
|
|
6476
|
+
.then(function (queryResult) { return Object.assign(queryResult, eagerMethods); });
|
|
6419
6477
|
promise.catch(function () { });
|
|
6420
6478
|
return promise;
|
|
6421
6479
|
}, []);
|
|
@@ -6533,6 +6591,12 @@ function useSubscription(subscription, options) {
|
|
|
6533
6591
|
context: options === null || options === void 0 ? void 0 : options.context,
|
|
6534
6592
|
});
|
|
6535
6593
|
}), observable = _b[0], setObservable = _b[1];
|
|
6594
|
+
var canResetObservableRef = React.useRef(false);
|
|
6595
|
+
React.useEffect(function () {
|
|
6596
|
+
return function () {
|
|
6597
|
+
canResetObservableRef.current = true;
|
|
6598
|
+
};
|
|
6599
|
+
}, []);
|
|
6536
6600
|
var ref = React.useRef({ client: client, subscription: subscription, options: options });
|
|
6537
6601
|
React.useEffect(function () {
|
|
6538
6602
|
var _a, _b, _c, _d;
|
|
@@ -6541,7 +6605,7 @@ function useSubscription(subscription, options) {
|
|
|
6541
6605
|
shouldResubscribe = !!shouldResubscribe(options);
|
|
6542
6606
|
}
|
|
6543
6607
|
if (options === null || options === void 0 ? void 0 : options.skip) {
|
|
6544
|
-
if (!(options === null || options === void 0 ? void 0 : options.skip) !== !((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.skip)) {
|
|
6608
|
+
if (!(options === null || options === void 0 ? void 0 : options.skip) !== !((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.skip) || canResetObservableRef.current) {
|
|
6545
6609
|
setResult({
|
|
6546
6610
|
loading: false,
|
|
6547
6611
|
data: void 0,
|
|
@@ -6549,13 +6613,16 @@ function useSubscription(subscription, options) {
|
|
|
6549
6613
|
variables: options === null || options === void 0 ? void 0 : options.variables,
|
|
6550
6614
|
});
|
|
6551
6615
|
setObservable(null);
|
|
6616
|
+
canResetObservableRef.current = false;
|
|
6552
6617
|
}
|
|
6553
6618
|
}
|
|
6554
|
-
else if (shouldResubscribe !== false &&
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
|
|
6558
|
-
|
|
6619
|
+
else if ((shouldResubscribe !== false &&
|
|
6620
|
+
(client !== ref.current.client ||
|
|
6621
|
+
subscription !== ref.current.subscription ||
|
|
6622
|
+
(options === null || options === void 0 ? void 0 : options.fetchPolicy) !== ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.fetchPolicy) ||
|
|
6623
|
+
!(options === null || options === void 0 ? void 0 : options.skip) !== !((_c = ref.current.options) === null || _c === void 0 ? void 0 : _c.skip) ||
|
|
6624
|
+
!equality.equal(options === null || options === void 0 ? void 0 : options.variables, (_d = ref.current.options) === null || _d === void 0 ? void 0 : _d.variables))) ||
|
|
6625
|
+
canResetObservableRef.current) {
|
|
6559
6626
|
setResult({
|
|
6560
6627
|
loading: true,
|
|
6561
6628
|
data: void 0,
|
|
@@ -6568,9 +6635,10 @@ function useSubscription(subscription, options) {
|
|
|
6568
6635
|
fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
|
|
6569
6636
|
context: options === null || options === void 0 ? void 0 : options.context,
|
|
6570
6637
|
}));
|
|
6638
|
+
canResetObservableRef.current = false;
|
|
6571
6639
|
}
|
|
6572
6640
|
Object.assign(ref.current, { client: client, subscription: subscription, options: options });
|
|
6573
|
-
}, [client, subscription, options]);
|
|
6641
|
+
}, [client, subscription, options, canResetObservableRef.current]);
|
|
6574
6642
|
React.useEffect(function () {
|
|
6575
6643
|
if (!observable) {
|
|
6576
6644
|
return;
|