Skip to content

Commit f331140

Browse files
chore: upgrade tanstack/react-query to 5.77.0 (coder#18039)
1 parent 2a15aa8 commit f331140

File tree

98 files changed

+523
-577
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+523
-577
lines changed

site/.storybook/preview.jsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { DecoratorHelpers } from "@storybook/addon-themes";
2828
import isChromatic from "chromatic/isChromatic";
2929
import { StrictMode } from "react";
3030
import { HelmetProvider } from "react-helmet-async";
31-
import { QueryClient, QueryClientProvider, parseQueryArgs } from "react-query";
31+
import { QueryClient, QueryClientProvider } from "react-query";
3232
import { withRouter } from "storybook-addon-remix-react-router";
3333
import "theme/globalFonts";
3434
import themes from "../src/theme";
@@ -114,20 +114,7 @@ function withQuery(Story, { parameters }) {
114114

115115
if (parameters.queries) {
116116
for (const query of parameters.queries) {
117-
if (query.isError) {
118-
// Based on `setQueryData`, but modified to set the result as an error.
119-
const cache = queryClient.getQueryCache();
120-
const parsedOptions = parseQueryArgs(query.key);
121-
const defaultedOptions = queryClient.defaultQueryOptions(parsedOptions);
122-
// Adds an uninitialized response to the cache, which we can now mutate.
123-
const cachedQuery = cache.build(queryClient, defaultedOptions);
124-
// Setting `manual` prevents retries.
125-
cachedQuery.setData(undefined, { manual: true });
126-
// Set the `error` value and the appropriate status.
127-
cachedQuery.setState({ error: query.data, status: "error" });
128-
} else {
129-
queryClient.setQueryData(query.key, query.data);
130-
}
117+
queryClient.setQueryData(query.key, query.data);
131118
}
132119
}
133120

site/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"@radix-ui/react-slot": "1.1.1",
7070
"@radix-ui/react-switch": "1.1.1",
7171
"@radix-ui/react-tooltip": "1.1.7",
72-
"@tanstack/react-query-devtools": "4.35.3",
72+
"@tanstack/react-query-devtools": "5.77.0",
7373
"@xterm/addon-canvas": "0.7.0",
7474
"@xterm/addon-fit": "0.10.0",
7575
"@xterm/addon-unicode11": "0.8.0",
@@ -103,7 +103,7 @@
103103
"react-dom": "18.3.1",
104104
"react-helmet-async": "2.0.5",
105105
"react-markdown": "9.0.3",
106-
"react-query": "npm:@tanstack/react-query@4.35.3",
106+
"react-query": "npm:@tanstack/react-query@5.77.0",
107107
"react-router-dom": "6.26.2",
108108
"react-syntax-highlighter": "15.6.1",
109109
"react-virtualized-auto-sizer": "1.0.24",

site/pnpm-lock.yaml

Lines changed: 23 additions & 75 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/api/queries/chats.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const createChat = (queryClient: QueryClient) => {
55
return {
66
mutationFn: API.createChat,
77
onSuccess: async () => {
8-
await queryClient.invalidateQueries(["chats"]);
8+
await queryClient.invalidateQueries({ queryKey: ["chats"] });
99
},
1010
};
1111
};

site/src/api/queries/debug.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const health = () => ({
1313
export const refreshHealth = (queryClient: QueryClient) => {
1414
return {
1515
mutationFn: async () => {
16-
await queryClient.cancelQueries(HEALTH_QUERY_KEY);
16+
await queryClient.cancelQueries({ queryKey: HEALTH_QUERY_KEY });
1717
const newHealthData = await API.getHealth(true);
1818
queryClient.setQueryData(HEALTH_QUERY_KEY, newHealthData);
1919
},
@@ -38,7 +38,7 @@ export const updateHealthSettings = (
3838
return {
3939
mutationFn: API.updateHealthSettings,
4040
onSuccess: async (_, newSettings) => {
41-
await queryClient.invalidateQueries(HEALTH_QUERY_KEY);
41+
await queryClient.invalidateQueries({ queryKey: HEALTH_QUERY_KEY });
4242
queryClient.setQueryData(HEALTH_QUERY_SETTINGS_KEY, newSettings);
4343
},
4444
};

site/src/api/queries/externalAuth.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ export const exchangeExternalAuthDevice = (
3737
queryKey: ["external-auth", providerId, "device", deviceCode],
3838
onSuccess: async () => {
3939
// Force a refresh of the Git auth status.
40-
await queryClient.invalidateQueries(["external-auth", providerId]);
40+
await queryClient.invalidateQueries({
41+
queryKey: ["external-auth", providerId],
42+
});
4143
},
4244
};
4345
};
@@ -57,7 +59,9 @@ export const unlinkExternalAuths = (queryClient: QueryClient) => {
5759
return {
5860
mutationFn: API.unlinkExternalAuthProvider,
5961
onSuccess: async () => {
60-
await queryClient.invalidateQueries(["external-auth"]);
62+
await queryClient.invalidateQueries({
63+
queryKey: ["external-auth"],
64+
});
6165
},
6266
};
6367
};

site/src/api/queries/groups.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ export const createGroup = (queryClient: QueryClient, organization: string) => {
117117
mutationFn: (request: CreateGroupRequest) =>
118118
API.createGroup(organization, request),
119119
onSuccess: async () => {
120-
await queryClient.invalidateQueries(groupsQueryKey);
121-
await queryClient.invalidateQueries(
122-
getGroupsByOrganizationQueryKey(organization),
123-
);
120+
await queryClient.invalidateQueries({
121+
queryKey: groupsQueryKey,
122+
});
123+
await queryClient.invalidateQueries({
124+
queryKey: getGroupsByOrganizationQueryKey(organization),
125+
});
124126
},
125127
};
126128
};
@@ -169,11 +171,13 @@ const invalidateGroup = (
169171
groupId: string,
170172
) =>
171173
Promise.all([
172-
queryClient.invalidateQueries(groupsQueryKey),
173-
queryClient.invalidateQueries(
174-
getGroupsByOrganizationQueryKey(organization),
175-
),
176-
queryClient.invalidateQueries(getGroupQueryKey(organization, groupId)),
174+
queryClient.invalidateQueries({ queryKey: groupsQueryKey }),
175+
queryClient.invalidateQueries({
176+
queryKey: getGroupsByOrganizationQueryKey(organization),
177+
}),
178+
queryClient.invalidateQueries({
179+
queryKey: getGroupQueryKey(organization, groupId),
180+
}),
177181
]);
178182

179183
function sortGroupsByName<T extends Group>(

site/src/api/queries/idpsync.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ export const patchOrganizationSyncSettings = (queryClient: QueryClient) => {
99
mutationFn: (request: OrganizationSyncSettings) =>
1010
API.patchOrganizationIdpSyncSettings(request),
1111
onSuccess: async () =>
12-
await queryClient.invalidateQueries(getOrganizationIdpSyncSettingsKey()),
12+
await queryClient.invalidateQueries({
13+
queryKey: getOrganizationIdpSyncSettingsKey(),
14+
}),
1315
};
1416
};
1517

0 commit comments

Comments
 (0)