@apollo/client 3.6.0-beta.12 → 3.6.0-beta.13
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 +77 -76
- 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/invariantErrorCodes.js +1 -1
- package/package.json +4 -2
- package/react/hooks/hooks.cjs +76 -75
- package/react/hooks/hooks.cjs.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 +78 -77
- package/react/hooks/useQuery.js.map +1 -1
- package/version.js +1 -1
package/apollo-client.cjs
CHANGED
|
@@ -13,6 +13,7 @@ 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');
|
|
16
17
|
|
|
17
18
|
function _interopNamespace(e) {
|
|
18
19
|
if (e && e.__esModule) return e;
|
|
@@ -1291,7 +1292,7 @@ var concat = ApolloLink.concat;
|
|
|
1291
1292
|
|
|
1292
1293
|
var execute = ApolloLink.execute;
|
|
1293
1294
|
|
|
1294
|
-
var version = '3.6.0-beta.
|
|
1295
|
+
var version = '3.6.0-beta.13';
|
|
1295
1296
|
|
|
1296
1297
|
var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
1297
1298
|
function parseAndCheckHttpResponse(operations) {
|
|
@@ -6129,17 +6130,75 @@ var InternalState = (function () {
|
|
|
6129
6130
|
function InternalState(client, query) {
|
|
6130
6131
|
this.client = client;
|
|
6131
6132
|
this.query = query;
|
|
6133
|
+
this.ssrDisabledResult = maybeDeepFreeze({
|
|
6134
|
+
loading: true,
|
|
6135
|
+
data: void 0,
|
|
6136
|
+
error: void 0,
|
|
6137
|
+
networkStatus: exports.NetworkStatus.loading,
|
|
6138
|
+
});
|
|
6139
|
+
this.skipStandbyResult = maybeDeepFreeze({
|
|
6140
|
+
loading: false,
|
|
6141
|
+
data: void 0,
|
|
6142
|
+
error: void 0,
|
|
6143
|
+
networkStatus: exports.NetworkStatus.ready,
|
|
6144
|
+
});
|
|
6132
6145
|
this.toQueryResultCache = new (canUseWeakMap ? WeakMap : Map)();
|
|
6133
6146
|
verifyDocumentType(query, exports.DocumentType.Query);
|
|
6134
6147
|
}
|
|
6135
6148
|
InternalState.prototype.forceUpdate = function () {
|
|
6136
6149
|
};
|
|
6137
6150
|
InternalState.prototype.useQuery = function (options) {
|
|
6151
|
+
var _this = this;
|
|
6138
6152
|
this.renderPromises = React.useContext(getApolloContext()).renderPromises;
|
|
6139
6153
|
this.useOptions(options);
|
|
6140
6154
|
var obsQuery = this.useObservableQuery();
|
|
6141
|
-
|
|
6142
|
-
|
|
6155
|
+
var result = index_js.useSyncExternalStore(React.useCallback(function () {
|
|
6156
|
+
if (_this.renderPromises) {
|
|
6157
|
+
return function () { };
|
|
6158
|
+
}
|
|
6159
|
+
var onNext = function () {
|
|
6160
|
+
var previousResult = _this.result;
|
|
6161
|
+
var result = obsQuery.getCurrentResult();
|
|
6162
|
+
if (previousResult &&
|
|
6163
|
+
previousResult.loading === result.loading &&
|
|
6164
|
+
previousResult.networkStatus === result.networkStatus &&
|
|
6165
|
+
equality.equal(previousResult.data, result.data)) {
|
|
6166
|
+
return;
|
|
6167
|
+
}
|
|
6168
|
+
_this.setResult(result);
|
|
6169
|
+
};
|
|
6170
|
+
var onError = function (error) {
|
|
6171
|
+
var last = obsQuery["last"];
|
|
6172
|
+
subscription.unsubscribe();
|
|
6173
|
+
try {
|
|
6174
|
+
obsQuery.resetLastResults();
|
|
6175
|
+
subscription = obsQuery.subscribe(onNext, onError);
|
|
6176
|
+
}
|
|
6177
|
+
finally {
|
|
6178
|
+
obsQuery["last"] = last;
|
|
6179
|
+
}
|
|
6180
|
+
if (!hasOwnProperty.call(error, 'graphQLErrors')) {
|
|
6181
|
+
throw error;
|
|
6182
|
+
}
|
|
6183
|
+
var previousResult = _this.result;
|
|
6184
|
+
if (!previousResult ||
|
|
6185
|
+
(previousResult && previousResult.loading) ||
|
|
6186
|
+
!equality.equal(error, previousResult.error)) {
|
|
6187
|
+
_this.setResult({
|
|
6188
|
+
data: (previousResult && previousResult.data),
|
|
6189
|
+
error: error,
|
|
6190
|
+
loading: false,
|
|
6191
|
+
networkStatus: exports.NetworkStatus.error,
|
|
6192
|
+
});
|
|
6193
|
+
}
|
|
6194
|
+
};
|
|
6195
|
+
var subscription = obsQuery.subscribe(onNext, onError);
|
|
6196
|
+
return function () { return subscription.unsubscribe(); };
|
|
6197
|
+
}, [
|
|
6198
|
+
obsQuery,
|
|
6199
|
+
this.renderPromises,
|
|
6200
|
+
this.client.disableNetworkFetches,
|
|
6201
|
+
]), function () { return _this.getCurrentResult(); });
|
|
6143
6202
|
this.unsafeHandlePartialRefetch(result);
|
|
6144
6203
|
return this.toQueryResult(result);
|
|
6145
6204
|
};
|
|
@@ -6152,6 +6211,18 @@ var InternalState = (function () {
|
|
|
6152
6211
|
options.skip);
|
|
6153
6212
|
this.onCompleted = options.onCompleted || InternalState.prototype.onCompleted;
|
|
6154
6213
|
this.onError = options.onError || InternalState.prototype.onError;
|
|
6214
|
+
if ((this.renderPromises || this.client.disableNetworkFetches) &&
|
|
6215
|
+
this.queryHookOptions.ssr === false) {
|
|
6216
|
+
this.result = this.ssrDisabledResult;
|
|
6217
|
+
}
|
|
6218
|
+
else if (this.queryHookOptions.skip ||
|
|
6219
|
+
this.watchQueryOptions.fetchPolicy === 'standby') {
|
|
6220
|
+
this.result = this.skipStandbyResult;
|
|
6221
|
+
}
|
|
6222
|
+
else if (this.result === this.ssrDisabledResult ||
|
|
6223
|
+
this.result === this.skipStandbyResult) {
|
|
6224
|
+
this.result = void 0;
|
|
6225
|
+
}
|
|
6155
6226
|
};
|
|
6156
6227
|
InternalState.prototype.createWatchQueryOptions = function (_a) {
|
|
6157
6228
|
if (_a === void 0) { _a = {}; }
|
|
@@ -6256,56 +6327,6 @@ var InternalState = (function () {
|
|
|
6256
6327
|
}, [obsQuery, this.watchQueryOptions]);
|
|
6257
6328
|
return obsQuery;
|
|
6258
6329
|
};
|
|
6259
|
-
InternalState.prototype.useSubscriptionEffect = function (obsQuery) {
|
|
6260
|
-
var _this = this;
|
|
6261
|
-
React.useEffect(function () {
|
|
6262
|
-
if (_this.renderPromises) {
|
|
6263
|
-
return;
|
|
6264
|
-
}
|
|
6265
|
-
var onNext = function () {
|
|
6266
|
-
var previousResult = _this.result;
|
|
6267
|
-
var result = obsQuery.getCurrentResult();
|
|
6268
|
-
if (previousResult &&
|
|
6269
|
-
previousResult.loading === result.loading &&
|
|
6270
|
-
previousResult.networkStatus === result.networkStatus &&
|
|
6271
|
-
equality.equal(previousResult.data, result.data)) {
|
|
6272
|
-
return;
|
|
6273
|
-
}
|
|
6274
|
-
_this.setResult(result);
|
|
6275
|
-
};
|
|
6276
|
-
var onError = function (error) {
|
|
6277
|
-
var last = obsQuery["last"];
|
|
6278
|
-
subscription.unsubscribe();
|
|
6279
|
-
try {
|
|
6280
|
-
obsQuery.resetLastResults();
|
|
6281
|
-
subscription = obsQuery.subscribe(onNext, onError);
|
|
6282
|
-
}
|
|
6283
|
-
finally {
|
|
6284
|
-
obsQuery["last"] = last;
|
|
6285
|
-
}
|
|
6286
|
-
if (!hasOwnProperty.call(error, 'graphQLErrors')) {
|
|
6287
|
-
throw error;
|
|
6288
|
-
}
|
|
6289
|
-
var previousResult = _this.result;
|
|
6290
|
-
if (!previousResult ||
|
|
6291
|
-
(previousResult && previousResult.loading) ||
|
|
6292
|
-
!equality.equal(error, previousResult.error)) {
|
|
6293
|
-
_this.setResult({
|
|
6294
|
-
data: (previousResult && previousResult.data),
|
|
6295
|
-
error: error,
|
|
6296
|
-
loading: false,
|
|
6297
|
-
networkStatus: exports.NetworkStatus.error,
|
|
6298
|
-
});
|
|
6299
|
-
}
|
|
6300
|
-
};
|
|
6301
|
-
var subscription = obsQuery.subscribe(onNext, onError);
|
|
6302
|
-
return function () { return subscription.unsubscribe(); };
|
|
6303
|
-
}, [
|
|
6304
|
-
obsQuery,
|
|
6305
|
-
this.renderPromises,
|
|
6306
|
-
this.client.disableNetworkFetches,
|
|
6307
|
-
]);
|
|
6308
|
-
};
|
|
6309
6330
|
InternalState.prototype.setResult = function (nextResult) {
|
|
6310
6331
|
var previousResult = this.result;
|
|
6311
6332
|
if (previousResult && previousResult.data) {
|
|
@@ -6326,30 +6347,10 @@ var InternalState = (function () {
|
|
|
6326
6347
|
}
|
|
6327
6348
|
};
|
|
6328
6349
|
InternalState.prototype.getCurrentResult = function () {
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
result = this.result = this.observable.getCurrentResult();
|
|
6332
|
-
this.handleErrorOrCompleted(result);
|
|
6350
|
+
if (!this.result) {
|
|
6351
|
+
this.handleErrorOrCompleted(this.result = this.observable.getCurrentResult());
|
|
6333
6352
|
}
|
|
6334
|
-
|
|
6335
|
-
this.queryHookOptions.ssr === false) {
|
|
6336
|
-
result = {
|
|
6337
|
-
loading: true,
|
|
6338
|
-
data: void 0,
|
|
6339
|
-
error: void 0,
|
|
6340
|
-
networkStatus: exports.NetworkStatus.loading,
|
|
6341
|
-
};
|
|
6342
|
-
}
|
|
6343
|
-
else if (this.queryHookOptions.skip ||
|
|
6344
|
-
this.watchQueryOptions.fetchPolicy === 'standby') {
|
|
6345
|
-
result = {
|
|
6346
|
-
loading: false,
|
|
6347
|
-
data: void 0,
|
|
6348
|
-
error: void 0,
|
|
6349
|
-
networkStatus: exports.NetworkStatus.ready,
|
|
6350
|
-
};
|
|
6351
|
-
}
|
|
6352
|
-
return result;
|
|
6353
|
+
return this.result;
|
|
6353
6354
|
};
|
|
6354
6355
|
InternalState.prototype.toQueryResult = function (result) {
|
|
6355
6356
|
var queryResult = this.toQueryResultCache.get(result);
|