@tanstack/query-core 5.0.0-alpha.1 → 5.0.0-alpha.18
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/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js +13 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js.map +1 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js +16 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/build/lib/focusManager.esm.js +31 -15
- package/build/lib/focusManager.esm.js.map +1 -1
- package/build/lib/focusManager.js +31 -15
- package/build/lib/focusManager.js.map +1 -1
- package/build/lib/hydration.d.ts +2 -6
- package/build/lib/hydration.esm.js +9 -20
- package/build/lib/hydration.esm.js.map +1 -1
- package/build/lib/hydration.js +9 -20
- package/build/lib/hydration.js.map +1 -1
- package/build/lib/hydration.mjs +4 -18
- package/build/lib/hydration.mjs.map +1 -1
- package/build/lib/index.d.ts +4 -4
- package/build/lib/index.esm.js +1 -1
- package/build/lib/index.js +1 -0
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs +1 -1
- package/build/lib/infiniteQueryBehavior.d.ts +2 -2
- package/build/lib/infiniteQueryBehavior.esm.js +52 -48
- package/build/lib/infiniteQueryBehavior.esm.js.map +1 -1
- package/build/lib/infiniteQueryBehavior.js +52 -48
- package/build/lib/infiniteQueryBehavior.js.map +1 -1
- package/build/lib/infiniteQueryBehavior.mjs +48 -45
- package/build/lib/infiniteQueryBehavior.mjs.map +1 -1
- package/build/lib/infiniteQueryObserver.d.ts +7 -7
- package/build/lib/infiniteQueryObserver.esm.js +7 -8
- package/build/lib/infiniteQueryObserver.esm.js.map +1 -1
- package/build/lib/infiniteQueryObserver.js +7 -8
- package/build/lib/infiniteQueryObserver.js.map +1 -1
- package/build/lib/infiniteQueryObserver.mjs +4 -6
- package/build/lib/infiniteQueryObserver.mjs.map +1 -1
- package/build/lib/mutation.d.ts +5 -4
- package/build/lib/mutation.esm.js +138 -99
- package/build/lib/mutation.esm.js.map +1 -1
- package/build/lib/mutation.js +138 -99
- package/build/lib/mutation.js.map +1 -1
- package/build/lib/mutation.mjs +16 -2
- package/build/lib/mutation.mjs.map +1 -1
- package/build/lib/mutationCache.d.ts +5 -4
- package/build/lib/mutationCache.esm.js +34 -20
- package/build/lib/mutationCache.esm.js.map +1 -1
- package/build/lib/mutationCache.js +34 -20
- package/build/lib/mutationCache.js.map +1 -1
- package/build/lib/mutationCache.mjs +5 -4
- package/build/lib/mutationCache.mjs.map +1 -1
- package/build/lib/mutationObserver.d.ts +2 -2
- package/build/lib/mutationObserver.esm.js +81 -50
- package/build/lib/mutationObserver.esm.js.map +1 -1
- package/build/lib/mutationObserver.js +81 -50
- package/build/lib/mutationObserver.js.map +1 -1
- package/build/lib/mutationObserver.mjs +1 -0
- package/build/lib/mutationObserver.mjs.map +1 -1
- package/build/lib/onlineManager.esm.js +29 -14
- package/build/lib/onlineManager.esm.js.map +1 -1
- package/build/lib/onlineManager.js +29 -14
- package/build/lib/onlineManager.js.map +1 -1
- package/build/lib/queriesObserver.esm.js +94 -69
- package/build/lib/queriesObserver.esm.js.map +1 -1
- package/build/lib/queriesObserver.js +94 -69
- package/build/lib/queriesObserver.js.map +1 -1
- package/build/lib/queriesObserver.mjs +1 -5
- package/build/lib/queriesObserver.mjs.map +1 -1
- package/build/lib/query.d.ts +8 -7
- package/build/lib/query.esm.js +210 -159
- package/build/lib/query.esm.js.map +1 -1
- package/build/lib/query.js +210 -159
- package/build/lib/query.js.map +1 -1
- package/build/lib/query.mjs +2 -0
- package/build/lib/query.mjs.map +1 -1
- package/build/lib/queryCache.d.ts +5 -4
- package/build/lib/queryCache.esm.js +21 -13
- package/build/lib/queryCache.esm.js.map +1 -1
- package/build/lib/queryCache.js +21 -13
- package/build/lib/queryCache.js.map +1 -1
- package/build/lib/queryCache.mjs +5 -4
- package/build/lib/queryCache.mjs.map +1 -1
- package/build/lib/queryClient.d.ts +7 -7
- package/build/lib/queryClient.esm.js +107 -66
- package/build/lib/queryClient.esm.js.map +1 -1
- package/build/lib/queryClient.js +107 -66
- package/build/lib/queryClient.js.map +1 -1
- package/build/lib/queryClient.mjs +5 -4
- package/build/lib/queryClient.mjs.map +1 -1
- package/build/lib/queryObserver.d.ts +2 -2
- package/build/lib/queryObserver.esm.js +308 -207
- package/build/lib/queryObserver.esm.js.map +1 -1
- package/build/lib/queryObserver.js +307 -206
- package/build/lib/queryObserver.js.map +1 -1
- package/build/lib/queryObserver.mjs.map +1 -1
- package/build/lib/removable.esm.js +13 -6
- package/build/lib/removable.esm.js.map +1 -1
- package/build/lib/removable.js +13 -6
- package/build/lib/removable.js.map +1 -1
- package/build/lib/retryer.d.ts +5 -5
- package/build/lib/retryer.esm.js +15 -14
- package/build/lib/retryer.esm.js.map +1 -1
- package/build/lib/retryer.js +15 -14
- package/build/lib/retryer.js.map +1 -1
- package/build/lib/retryer.mjs.map +1 -1
- package/build/lib/tests/utils.d.ts +4 -5
- package/build/lib/types.d.ts +42 -40
- package/build/lib/utils.esm.js +1 -1
- package/build/lib/utils.esm.js.map +1 -1
- package/build/lib/utils.js +1 -1
- package/build/lib/utils.js.map +1 -1
- package/build/umd/index.development.js +92 -88
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/hydration.ts +18 -37
- package/src/index.ts +9 -5
- package/src/infiniteQueryBehavior.ts +52 -60
- package/src/infiniteQueryObserver.ts +17 -12
- package/src/mutation.ts +34 -7
- package/src/mutationCache.ts +15 -8
- package/src/mutationObserver.ts +3 -2
- package/src/queriesObserver.ts +3 -7
- package/src/query.ts +24 -9
- package/src/queryCache.ts +16 -10
- package/src/queryClient.ts +9 -11
- package/src/queryObserver.ts +2 -2
- package/src/retryer.ts +5 -5
- package/src/tests/focusManager.test.tsx +12 -14
- package/src/tests/hydration.test.tsx +22 -17
- package/src/tests/infiniteQueryBehavior.test.tsx +16 -9
- package/src/tests/infiniteQueryObserver.test.tsx +62 -1
- package/src/tests/mutationCache.test.tsx +61 -16
- package/src/tests/mutationObserver.test.tsx +3 -2
- package/src/tests/mutations.test.tsx +41 -9
- package/src/tests/notifyManager.test.tsx +7 -6
- package/src/tests/onlineManager.test.tsx +12 -17
- package/src/tests/queriesObserver.test.tsx +18 -17
- package/src/tests/query.test.tsx +18 -17
- package/src/tests/queryCache.test.tsx +28 -15
- package/src/tests/queryClient.test.tsx +49 -48
- package/src/tests/queryObserver.test.tsx +10 -9
- package/src/tests/utils.test.tsx +2 -1
- package/src/tests/utils.ts +5 -4
- package/src/types.ts +53 -37
|
@@ -889,6 +889,7 @@
|
|
|
889
889
|
if (!isCancelledError(error)) {
|
|
890
890
|
// Notify cache callback
|
|
891
891
|
this.#cache.config.onError?.(error, this);
|
|
892
|
+
this.#cache.config.onSettled?.(this.state.data, error, this);
|
|
892
893
|
}
|
|
893
894
|
if (!this.isFetchingOptimistic) {
|
|
894
895
|
// Schedule query gc after fetching
|
|
@@ -913,6 +914,7 @@
|
|
|
913
914
|
|
|
914
915
|
// Notify cache callback
|
|
915
916
|
this.#cache.config.onSuccess?.(data, this);
|
|
917
|
+
this.#cache.config.onSettled?.(data, this.state.error, this);
|
|
916
918
|
if (!this.isFetchingOptimistic) {
|
|
917
919
|
// Schedule query gc after fetching
|
|
918
920
|
this.scheduleGc();
|
|
@@ -1114,10 +1116,11 @@
|
|
|
1114
1116
|
return [...this.#queries.values()];
|
|
1115
1117
|
}
|
|
1116
1118
|
find(filters) {
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1119
|
+
const defaultedFilters = {
|
|
1120
|
+
exact: true,
|
|
1121
|
+
...filters
|
|
1122
|
+
};
|
|
1123
|
+
return this.getAll().find(query => matchQuery(defaultedFilters, query));
|
|
1121
1124
|
}
|
|
1122
1125
|
findAll(filters = {}) {
|
|
1123
1126
|
const queries = this.getAll();
|
|
@@ -1152,18 +1155,26 @@
|
|
|
1152
1155
|
|
|
1153
1156
|
class Mutation extends Removable {
|
|
1154
1157
|
#observers;
|
|
1158
|
+
#defaultOptions;
|
|
1155
1159
|
#mutationCache;
|
|
1156
1160
|
#retryer;
|
|
1157
1161
|
constructor(config) {
|
|
1158
1162
|
super();
|
|
1159
|
-
this.options = config.options;
|
|
1160
1163
|
this.mutationId = config.mutationId;
|
|
1164
|
+
this.#defaultOptions = config.defaultOptions;
|
|
1161
1165
|
this.#mutationCache = config.mutationCache;
|
|
1162
1166
|
this.#observers = [];
|
|
1163
1167
|
this.state = config.state || getDefaultState();
|
|
1164
|
-
this.
|
|
1168
|
+
this.setOptions(config.options);
|
|
1165
1169
|
this.scheduleGc();
|
|
1166
1170
|
}
|
|
1171
|
+
setOptions(options) {
|
|
1172
|
+
this.options = {
|
|
1173
|
+
...this.#defaultOptions,
|
|
1174
|
+
...options
|
|
1175
|
+
};
|
|
1176
|
+
this.updateGcTime(this.options.gcTime);
|
|
1177
|
+
}
|
|
1167
1178
|
get meta() {
|
|
1168
1179
|
return this.options.meta;
|
|
1169
1180
|
}
|
|
@@ -1258,6 +1269,9 @@
|
|
|
1258
1269
|
// Notify cache callback
|
|
1259
1270
|
await this.#mutationCache.config.onSuccess?.(data, variables, this.state.context, this);
|
|
1260
1271
|
await this.options.onSuccess?.(data, variables, this.state.context);
|
|
1272
|
+
|
|
1273
|
+
// Notify cache callback
|
|
1274
|
+
await this.#mutationCache.config.onSettled?.(data, null, this.state.variables, this.state.context, this);
|
|
1261
1275
|
await this.options.onSettled?.(data, null, variables, this.state.context);
|
|
1262
1276
|
this.#dispatch({
|
|
1263
1277
|
type: 'success',
|
|
@@ -1269,6 +1283,9 @@
|
|
|
1269
1283
|
// Notify cache callback
|
|
1270
1284
|
await this.#mutationCache.config.onError?.(error, variables, this.state.context, this);
|
|
1271
1285
|
await this.options.onError?.(error, variables, this.state.context);
|
|
1286
|
+
|
|
1287
|
+
// Notify cache callback
|
|
1288
|
+
await this.#mutationCache.config.onSettled?.(undefined, error, this.state.variables, this.state.context, this);
|
|
1272
1289
|
await this.options.onSettled?.(undefined, error, variables, this.state.context);
|
|
1273
1290
|
throw error;
|
|
1274
1291
|
} finally {
|
|
@@ -1409,10 +1426,11 @@
|
|
|
1409
1426
|
return this.#mutations;
|
|
1410
1427
|
}
|
|
1411
1428
|
find(filters) {
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1429
|
+
const defaultedFilters = {
|
|
1430
|
+
exact: true,
|
|
1431
|
+
...filters
|
|
1432
|
+
};
|
|
1433
|
+
return this.#mutations.find(mutation => matchMutation(defaultedFilters, mutation));
|
|
1416
1434
|
}
|
|
1417
1435
|
findAll(filters = {}) {
|
|
1418
1436
|
return this.#mutations.filter(mutation => matchMutation(filters, mutation));
|
|
@@ -1438,12 +1456,15 @@
|
|
|
1438
1456
|
function infiniteQueryBehavior() {
|
|
1439
1457
|
return {
|
|
1440
1458
|
onFetch: context => {
|
|
1441
|
-
context.fetchFn = () => {
|
|
1459
|
+
context.fetchFn = async () => {
|
|
1442
1460
|
const options = context.options;
|
|
1443
1461
|
const direction = context.fetchOptions?.meta?.fetchMore?.direction;
|
|
1444
1462
|
const oldPages = context.state.data?.pages || [];
|
|
1445
1463
|
const oldPageParams = context.state.data?.pageParams || [];
|
|
1446
|
-
|
|
1464
|
+
const empty = {
|
|
1465
|
+
pages: [],
|
|
1466
|
+
pageParams: []
|
|
1467
|
+
};
|
|
1447
1468
|
let cancelled = false;
|
|
1448
1469
|
const addSignalProperty = object => {
|
|
1449
1470
|
Object.defineProperty(object, 'signal', {
|
|
@@ -1463,95 +1484,95 @@
|
|
|
1463
1484
|
|
|
1464
1485
|
// Get query function
|
|
1465
1486
|
const queryFn = context.options.queryFn || (() => Promise.reject(new Error('Missing queryFn')));
|
|
1466
|
-
const buildNewPages = (pages, param, page, previous) => {
|
|
1467
|
-
const {
|
|
1468
|
-
maxPages
|
|
1469
|
-
} = context.options;
|
|
1470
|
-
if (previous) {
|
|
1471
|
-
newPageParams = addToStart(newPageParams, param, maxPages);
|
|
1472
|
-
return addToStart(pages, page, maxPages);
|
|
1473
|
-
}
|
|
1474
|
-
newPageParams = addToEnd(newPageParams, param, maxPages);
|
|
1475
|
-
return addToEnd(pages, page, maxPages);
|
|
1476
|
-
};
|
|
1477
1487
|
|
|
1478
1488
|
// Create function to fetch a page
|
|
1479
|
-
const fetchPage = (
|
|
1489
|
+
const fetchPage = async (data, param, previous) => {
|
|
1480
1490
|
if (cancelled) {
|
|
1481
1491
|
return Promise.reject();
|
|
1482
1492
|
}
|
|
1483
|
-
if (typeof param === 'undefined' && pages.length) {
|
|
1484
|
-
return Promise.resolve(
|
|
1493
|
+
if (typeof param === 'undefined' && data.pages.length) {
|
|
1494
|
+
return Promise.resolve(data);
|
|
1485
1495
|
}
|
|
1486
1496
|
const queryFnContext = {
|
|
1487
1497
|
queryKey: context.queryKey,
|
|
1488
1498
|
pageParam: param,
|
|
1499
|
+
direction: previous ? 'backward' : 'forward',
|
|
1489
1500
|
meta: context.options.meta
|
|
1490
1501
|
};
|
|
1491
1502
|
addSignalProperty(queryFnContext);
|
|
1492
|
-
const
|
|
1493
|
-
const
|
|
1494
|
-
|
|
1503
|
+
const page = await queryFn(queryFnContext);
|
|
1504
|
+
const {
|
|
1505
|
+
maxPages
|
|
1506
|
+
} = context.options;
|
|
1507
|
+
const addTo = previous ? addToStart : addToEnd;
|
|
1508
|
+
return {
|
|
1509
|
+
pages: addTo(data.pages, page, maxPages),
|
|
1510
|
+
pageParams: addTo(data.pageParams, param, maxPages)
|
|
1511
|
+
};
|
|
1495
1512
|
};
|
|
1496
|
-
let
|
|
1513
|
+
let result;
|
|
1497
1514
|
|
|
1498
1515
|
// Fetch first page?
|
|
1499
1516
|
if (!oldPages.length) {
|
|
1500
|
-
|
|
1517
|
+
result = await fetchPage(empty, options.defaultPageParam);
|
|
1501
1518
|
}
|
|
1502
1519
|
|
|
1503
1520
|
// fetch next / previous page?
|
|
1504
1521
|
else if (direction) {
|
|
1505
1522
|
const previous = direction === 'backward';
|
|
1506
|
-
const
|
|
1507
|
-
|
|
1523
|
+
const pageParamFn = previous ? getPreviousPageParam : getNextPageParam;
|
|
1524
|
+
const oldData = {
|
|
1525
|
+
pages: oldPages,
|
|
1526
|
+
pageParams: oldPageParams
|
|
1527
|
+
};
|
|
1528
|
+
const param = pageParamFn(options, oldData);
|
|
1529
|
+
result = await fetchPage(oldData, param, previous);
|
|
1508
1530
|
}
|
|
1509
1531
|
|
|
1510
1532
|
// Refetch pages
|
|
1511
1533
|
else {
|
|
1512
|
-
newPageParams = [];
|
|
1513
|
-
|
|
1514
1534
|
// Fetch first page
|
|
1515
|
-
|
|
1535
|
+
result = await fetchPage(empty, oldPageParams[0]);
|
|
1516
1536
|
|
|
1517
1537
|
// Fetch remaining pages
|
|
1518
1538
|
for (let i = 1; i < oldPages.length; i++) {
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
return fetchPage(pages, param);
|
|
1522
|
-
});
|
|
1539
|
+
const param = getNextPageParam(options, result);
|
|
1540
|
+
result = await fetchPage(result, param);
|
|
1523
1541
|
}
|
|
1524
1542
|
}
|
|
1525
|
-
|
|
1526
|
-
pages,
|
|
1527
|
-
pageParams: newPageParams
|
|
1528
|
-
}));
|
|
1529
|
-
return finalPromise;
|
|
1543
|
+
return result;
|
|
1530
1544
|
};
|
|
1531
1545
|
}
|
|
1532
1546
|
};
|
|
1533
1547
|
}
|
|
1534
|
-
function getNextPageParam(options,
|
|
1535
|
-
|
|
1548
|
+
function getNextPageParam(options, {
|
|
1549
|
+
pages,
|
|
1550
|
+
pageParams
|
|
1551
|
+
}) {
|
|
1552
|
+
const lastIndex = pages.length - 1;
|
|
1553
|
+
return options.getNextPageParam(pages[lastIndex], pages, pageParams[lastIndex], pageParams);
|
|
1536
1554
|
}
|
|
1537
|
-
function getPreviousPageParam(options,
|
|
1538
|
-
|
|
1555
|
+
function getPreviousPageParam(options, {
|
|
1556
|
+
pages,
|
|
1557
|
+
pageParams
|
|
1558
|
+
}) {
|
|
1559
|
+
return options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams);
|
|
1539
1560
|
}
|
|
1540
1561
|
|
|
1541
1562
|
/**
|
|
1542
1563
|
* Checks if there is a next page.
|
|
1543
1564
|
*/
|
|
1544
|
-
function hasNextPage(options,
|
|
1545
|
-
if (!
|
|
1546
|
-
return typeof getNextPageParam(options,
|
|
1565
|
+
function hasNextPage(options, data) {
|
|
1566
|
+
if (!data) return false;
|
|
1567
|
+
return typeof getNextPageParam(options, data) !== 'undefined';
|
|
1547
1568
|
}
|
|
1548
1569
|
|
|
1549
1570
|
/**
|
|
1550
1571
|
* Checks if there is a previous page.
|
|
1551
1572
|
*/
|
|
1552
|
-
function hasPreviousPage(options,
|
|
1553
|
-
if (!
|
|
1554
|
-
return typeof getPreviousPageParam(options,
|
|
1573
|
+
function hasPreviousPage(options, data) {
|
|
1574
|
+
if (!data || !options.getPreviousPageParam) return false;
|
|
1575
|
+
return typeof getPreviousPageParam(options, data) !== 'undefined';
|
|
1555
1576
|
}
|
|
1556
1577
|
|
|
1557
1578
|
// CLASS
|
|
@@ -1676,10 +1697,11 @@
|
|
|
1676
1697
|
});
|
|
1677
1698
|
}
|
|
1678
1699
|
cancelQueries(filters = {}, cancelOptions = {}) {
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1700
|
+
const defaultedCancelOptions = {
|
|
1701
|
+
revert: true,
|
|
1702
|
+
...cancelOptions
|
|
1703
|
+
};
|
|
1704
|
+
const promises = notifyManager.batch(() => this.#queryCache.findAll(filters).map(query => query.cancel(defaultedCancelOptions)));
|
|
1683
1705
|
return Promise.all(promises).then(noop).catch(noop);
|
|
1684
1706
|
}
|
|
1685
1707
|
invalidateQueries(filters = {}, options = {}) {
|
|
@@ -2266,14 +2288,12 @@
|
|
|
2266
2288
|
#result;
|
|
2267
2289
|
#queries;
|
|
2268
2290
|
#observers;
|
|
2269
|
-
#observersMap;
|
|
2270
2291
|
constructor(client, queries) {
|
|
2271
2292
|
super();
|
|
2272
2293
|
this.#client = client;
|
|
2273
2294
|
this.#queries = [];
|
|
2274
2295
|
this.#result = [];
|
|
2275
2296
|
this.#observers = [];
|
|
2276
|
-
this.#observersMap = {};
|
|
2277
2297
|
if (queries) {
|
|
2278
2298
|
this.setQueries(queries);
|
|
2279
2299
|
}
|
|
@@ -2307,14 +2327,12 @@
|
|
|
2307
2327
|
// set options for the new observers to notify of changes
|
|
2308
2328
|
newObserverMatches.forEach(match => match.observer.setOptions(match.defaultedQueryOptions, notifyOptions));
|
|
2309
2329
|
const newObservers = newObserverMatches.map(match => match.observer);
|
|
2310
|
-
const newObserversMap = Object.fromEntries(newObservers.map(observer => [observer.options.queryHash, observer]));
|
|
2311
2330
|
const newResult = newObservers.map(observer => observer.getCurrentResult());
|
|
2312
2331
|
const hasIndexChange = newObservers.some((observer, index) => observer !== prevObservers[index]);
|
|
2313
2332
|
if (prevObservers.length === newObservers.length && !hasIndexChange) {
|
|
2314
2333
|
return;
|
|
2315
2334
|
}
|
|
2316
2335
|
this.#observers = newObservers;
|
|
2317
|
-
this.#observersMap = newObserversMap;
|
|
2318
2336
|
this.#result = newResult;
|
|
2319
2337
|
if (!this.hasListeners()) {
|
|
2320
2338
|
return;
|
|
@@ -2359,7 +2377,7 @@
|
|
|
2359
2377
|
const unmatchedQueries = defaultedQueryOptions.filter(defaultedOptions => !matchedQueryHashes.includes(defaultedOptions.queryHash));
|
|
2360
2378
|
const getObserver = options => {
|
|
2361
2379
|
const defaultedOptions = this.#client.defaultQueryOptions(options);
|
|
2362
|
-
const currentObserver = this.#
|
|
2380
|
+
const currentObserver = this.#observers.find(o => o.options.queryHash === defaultedOptions.queryHash);
|
|
2363
2381
|
return currentObserver ?? new QueryObserver(this.#client, defaultedOptions);
|
|
2364
2382
|
};
|
|
2365
2383
|
const newOrReusedObservers = unmatchedQueries.map(options => {
|
|
@@ -2413,7 +2431,7 @@
|
|
|
2413
2431
|
options.behavior = infiniteQueryBehavior();
|
|
2414
2432
|
return super.getOptimisticResult(options);
|
|
2415
2433
|
}
|
|
2416
|
-
fetchNextPage(options
|
|
2434
|
+
fetchNextPage(options) {
|
|
2417
2435
|
return this.fetch({
|
|
2418
2436
|
...options,
|
|
2419
2437
|
meta: {
|
|
@@ -2423,9 +2441,7 @@
|
|
|
2423
2441
|
}
|
|
2424
2442
|
});
|
|
2425
2443
|
}
|
|
2426
|
-
fetchPreviousPage({
|
|
2427
|
-
...options
|
|
2428
|
-
} = {}) {
|
|
2444
|
+
fetchPreviousPage(options) {
|
|
2429
2445
|
return this.fetch({
|
|
2430
2446
|
...options,
|
|
2431
2447
|
meta: {
|
|
@@ -2450,8 +2466,8 @@
|
|
|
2450
2466
|
...result,
|
|
2451
2467
|
fetchNextPage: this.fetchNextPage,
|
|
2452
2468
|
fetchPreviousPage: this.fetchPreviousPage,
|
|
2453
|
-
hasNextPage: hasNextPage(options, state.data
|
|
2454
|
-
hasPreviousPage: hasPreviousPage(options, state.data
|
|
2469
|
+
hasNextPage: hasNextPage(options, state.data),
|
|
2470
|
+
hasPreviousPage: hasPreviousPage(options, state.data),
|
|
2455
2471
|
isFetchingNextPage,
|
|
2456
2472
|
isFetchingPreviousPage,
|
|
2457
2473
|
isRefetching: isRefetching && !isFetchingNextPage && !isFetchingPreviousPage
|
|
@@ -2489,6 +2505,7 @@
|
|
|
2489
2505
|
observer: this
|
|
2490
2506
|
});
|
|
2491
2507
|
}
|
|
2508
|
+
this.#currentMutation?.setOptions(this.options);
|
|
2492
2509
|
}
|
|
2493
2510
|
onUnsubscribe() {
|
|
2494
2511
|
if (!this.listeners.length) {
|
|
@@ -2576,24 +2593,10 @@
|
|
|
2576
2593
|
return query.state.status === 'success';
|
|
2577
2594
|
}
|
|
2578
2595
|
function dehydrate(client, options = {}) {
|
|
2579
|
-
const
|
|
2580
|
-
const
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
client.getMutationCache().getAll().forEach(mutation => {
|
|
2584
|
-
if (shouldDehydrateMutation(mutation)) {
|
|
2585
|
-
mutations.push(dehydrateMutation(mutation));
|
|
2586
|
-
}
|
|
2587
|
-
});
|
|
2588
|
-
}
|
|
2589
|
-
if (options.dehydrateQueries !== false) {
|
|
2590
|
-
const shouldDehydrateQuery = options.shouldDehydrateQuery || defaultShouldDehydrateQuery;
|
|
2591
|
-
client.getQueryCache().getAll().forEach(query => {
|
|
2592
|
-
if (shouldDehydrateQuery(query)) {
|
|
2593
|
-
queries.push(dehydrateQuery(query));
|
|
2594
|
-
}
|
|
2595
|
-
});
|
|
2596
|
-
}
|
|
2596
|
+
const filterMutation = options.shouldDehydrateMutation ?? defaultShouldDehydrateMutation;
|
|
2597
|
+
const mutations = client.getMutationCache().getAll().flatMap(mutation => filterMutation(mutation) ? [dehydrateMutation(mutation)] : []);
|
|
2598
|
+
const filterQuery = options.shouldDehydrateQuery ?? defaultShouldDehydrateQuery;
|
|
2599
|
+
const queries = client.getQueryCache().getAll().flatMap(query => filterQuery(query) ? [dehydrateQuery(query)] : []);
|
|
2597
2600
|
return {
|
|
2598
2601
|
mutations,
|
|
2599
2602
|
queries
|
|
@@ -2660,6 +2663,7 @@
|
|
|
2660
2663
|
exports.isCancelledError = isCancelledError;
|
|
2661
2664
|
exports.isServer = isServer;
|
|
2662
2665
|
exports.keepPreviousData = keepPreviousData;
|
|
2666
|
+
exports.matchQuery = matchQuery;
|
|
2663
2667
|
exports.notifyManager = notifyManager;
|
|
2664
2668
|
exports.onlineManager = onlineManager;
|
|
2665
2669
|
exports.replaceEqualDeep = replaceEqualDeep;
|