@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
package/core/ObservableQuery.js
CHANGED
|
@@ -1254,13 +1254,49 @@ export class ObservableQuery {
|
|
|
1254
1254
|
});
|
|
1255
1255
|
}
|
|
1256
1256
|
operator = filterMap((notification) => {
|
|
1257
|
-
const { query,
|
|
1257
|
+
const { query, meta } = notification;
|
|
1258
1258
|
if (notification.source === "setResult") {
|
|
1259
|
-
return {
|
|
1259
|
+
return {
|
|
1260
|
+
query,
|
|
1261
|
+
variables: this.variables,
|
|
1262
|
+
result: notification.value,
|
|
1263
|
+
meta,
|
|
1264
|
+
};
|
|
1260
1265
|
}
|
|
1261
|
-
if (notification.kind === "C"
|
|
1266
|
+
if (notification.kind === "C") {
|
|
1267
|
+
return;
|
|
1268
|
+
}
|
|
1269
|
+
const resolvedVariables = "resolvedVariables" in notification ?
|
|
1270
|
+
notification.resolvedVariables
|
|
1271
|
+
: undefined;
|
|
1272
|
+
// Usually we prefer to drop notifications that don't match this query
|
|
1273
|
+
// but this breaks when used with `@export` queries that resolve variables
|
|
1274
|
+
// after the request is initiated. `notification.resolvedVariables` gives us
|
|
1275
|
+
// the variables the query actually resolved with during evaluation in
|
|
1276
|
+
// QueryManager (which is the variables value after `@export` variables have
|
|
1277
|
+
// been applied), but we need to update this query with those resolved
|
|
1278
|
+
// variables maybe in the middle of a request (updating is handled below).
|
|
1279
|
+
// When we update this.variables to the resolved variables, this causes
|
|
1280
|
+
// isEqualQuery(notification, this) to fail for future notifications since
|
|
1281
|
+
// the notification.variables holds the stale variables value. In this case,
|
|
1282
|
+
// we want to allow the notification through only if the current variables
|
|
1283
|
+
// value matches the resolved variables.
|
|
1284
|
+
//
|
|
1285
|
+
// Note: the check for matching resolved variables typically kicks in for
|
|
1286
|
+
// multi-emission fetches (such as defer, or cache-and-network, etc).
|
|
1287
|
+
if (notification.query !== this.query) {
|
|
1262
1288
|
return;
|
|
1263
1289
|
}
|
|
1290
|
+
if (!equal(resolvedVariables, this.variables)) {
|
|
1291
|
+
if (!equal(notification.variables, this.variables)) {
|
|
1292
|
+
return;
|
|
1293
|
+
}
|
|
1294
|
+
if (resolvedVariables) {
|
|
1295
|
+
this.options.variables = resolvedVariables;
|
|
1296
|
+
this.resubscribeCache();
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
const variables = this.variables;
|
|
1264
1300
|
let result;
|
|
1265
1301
|
const previous = this.subject.getValue();
|
|
1266
1302
|
if (notification.source === "cache") {
|
|
@@ -1281,7 +1317,9 @@ export class ObservableQuery {
|
|
|
1281
1317
|
result =
|
|
1282
1318
|
notification.kind === "E" ?
|
|
1283
1319
|
{
|
|
1284
|
-
...(isEqualQuery(previous, notification)
|
|
1320
|
+
...((isEqualQuery(previous, notification) ||
|
|
1321
|
+
(resolvedVariables &&
|
|
1322
|
+
equal(resolvedVariables, previous.variables))) ?
|
|
1285
1323
|
previous.result
|
|
1286
1324
|
: { data: undefined, dataState: "empty", partial: true }),
|
|
1287
1325
|
error: notification.error,
|