@apollo/client 4.2.7 → 4.2.9
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/CHANGELOG.md +14 -0
- package/README.md +3 -7
- package/__cjs/cache/inmemory/readFromStore.cjs +1 -4
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/core/ApolloClient.cjs +21 -22
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.cjs +42 -4
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/QueryManager.cjs +12 -0
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/types.d.cts +2 -0
- package/__cjs/version.cjs +1 -1
- package/cache/inmemory/readFromStore.js +2 -5
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/core/ApolloClient.js +21 -22
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.js +42 -4
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.js +12 -0
- package/core/QueryManager.js.map +1 -1
- package/core/types.d.ts +2 -0
- package/core/types.js.map +1 -1
- package/package.json +1 -1
- package/version.js +1 -1
|
@@ -1262,13 +1262,49 @@ class ObservableQuery {
|
|
|
1262
1262
|
});
|
|
1263
1263
|
}
|
|
1264
1264
|
operator = (0, internal_1.filterMap)((notification) => {
|
|
1265
|
-
const { query,
|
|
1265
|
+
const { query, meta } = notification;
|
|
1266
1266
|
if (notification.source === "setResult") {
|
|
1267
|
-
return {
|
|
1267
|
+
return {
|
|
1268
|
+
query,
|
|
1269
|
+
variables: this.variables,
|
|
1270
|
+
result: notification.value,
|
|
1271
|
+
meta,
|
|
1272
|
+
};
|
|
1268
1273
|
}
|
|
1269
|
-
if (notification.kind === "C"
|
|
1274
|
+
if (notification.kind === "C") {
|
|
1275
|
+
return;
|
|
1276
|
+
}
|
|
1277
|
+
const resolvedVariables = "resolvedVariables" in notification ?
|
|
1278
|
+
notification.resolvedVariables
|
|
1279
|
+
: undefined;
|
|
1280
|
+
// Usually we prefer to drop notifications that don't match this query
|
|
1281
|
+
// but this breaks when used with `@export` queries that resolve variables
|
|
1282
|
+
// after the request is initiated. `notification.resolvedVariables` gives us
|
|
1283
|
+
// the variables the query actually resolved with during evaluation in
|
|
1284
|
+
// QueryManager (which is the variables value after `@export` variables have
|
|
1285
|
+
// been applied), but we need to update this query with those resolved
|
|
1286
|
+
// variables maybe in the middle of a request (updating is handled below).
|
|
1287
|
+
// When we update this.variables to the resolved variables, this causes
|
|
1288
|
+
// isEqualQuery(notification, this) to fail for future notifications since
|
|
1289
|
+
// the notification.variables holds the stale variables value. In this case,
|
|
1290
|
+
// we want to allow the notification through only if the current variables
|
|
1291
|
+
// value matches the resolved variables.
|
|
1292
|
+
//
|
|
1293
|
+
// Note: the check for matching resolved variables typically kicks in for
|
|
1294
|
+
// multi-emission fetches (such as defer, or cache-and-network, etc).
|
|
1295
|
+
if (notification.query !== this.query) {
|
|
1270
1296
|
return;
|
|
1271
1297
|
}
|
|
1298
|
+
if (!(0, equality_1.equal)(resolvedVariables, this.variables)) {
|
|
1299
|
+
if (!(0, equality_1.equal)(notification.variables, this.variables)) {
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
if (resolvedVariables) {
|
|
1303
|
+
this.options.variables = resolvedVariables;
|
|
1304
|
+
this.resubscribeCache();
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
const variables = this.variables;
|
|
1272
1308
|
let result;
|
|
1273
1309
|
const previous = this.subject.getValue();
|
|
1274
1310
|
if (notification.source === "cache") {
|
|
@@ -1289,7 +1325,9 @@ class ObservableQuery {
|
|
|
1289
1325
|
result =
|
|
1290
1326
|
notification.kind === "E" ?
|
|
1291
1327
|
{
|
|
1292
|
-
...(isEqualQuery(previous, notification)
|
|
1328
|
+
...((isEqualQuery(previous, notification) ||
|
|
1329
|
+
(resolvedVariables &&
|
|
1330
|
+
(0, equality_1.equal)(resolvedVariables, previous.variables))) ?
|
|
1293
1331
|
previous.result
|
|
1294
1332
|
: { data: undefined, dataState: "empty", partial: true }),
|
|
1295
1333
|
error: notification.error,
|