Skip to content

Commit ce1a603

Browse files
authored
feat: upgrade tanstack query to v5 (#4360)
* upgrade syntax to v5 * blitz-next changes * fix types and export new functions * fix blitz suspense logic * fix workflow * changeset * fix pnpm version * fix pnpm lock file * latest pnpm version * fix * fix pnpm lock file * fixes * commit * commit * pnpm lock update * revert change * fixes * temp: remove patch * lockfile * chore: fix build and lint * fix: auth-with-rpc tests * qm test * remaining tests * fix rpc unit tests * revrt * another revert pnpm version change * revert back to pnpm 8.6.6 * pnpm lock fix * try fix * fix
1 parent 125370a commit ce1a603

File tree

65 files changed

+538
-421
lines changed

Some content is hidden

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

65 files changed

+538
-421
lines changed

.changeset/sweet-socks-juggle.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@blitzjs/next": major
3+
"@blitzjs/rpc": major
4+
"blitz": major
5+
"@blitzjs/auth": major
6+
"@blitzjs/codemod": major
7+
"@blitzjs/config": major
8+
"@blitzjs/generator": major
9+
---
10+
11+
TODO: Upgrade @tanstack/react-query to v5.1.1

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ jobs:
148148
- name: Install playwright
149149
if: matrix.folder != 'next-13-app-dir' || matrix.os != 'windows-latest'
150150
run: |
151-
pnpx playwright@1.28.0 install --with-deps
151+
pnpx playwright@1.49.1 install --with-deps
152152
shell: bash
153153

154154
- name: Build

.github/workflows/pr-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
run: |
3030
pr="$(gh api repos/${{ github.repository }}/pulls/${{ github.event.issue.number }})"
3131
head_sha="$(echo "$pr" | jq -r .head.sha)"
32-
32+
3333
echo "head_sha=$head_sha" >> $GITHUB_OUTPUT
3434
3535
- uses: actions/checkout@v4
@@ -39,7 +39,7 @@ jobs:
3939
- name: Setup PNPM
4040
uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
4141
with:
42-
version: 8.9.0
42+
version: 8.6.6
4343

4444
- name: Setup Node
4545
uses: actions/setup-node@v4

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- name: Pre-publish
3838
uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
3939
with:
40-
version: 8.9.0
40+
version: 8.6.6
4141
- run: pnpm install
4242
env:
4343
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1

apps/next13/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@hookform/error-message": "2.0.0",
2020
"@hookform/resolvers": "2.9.10",
2121
"@prisma/client": "^4.5.0",
22-
"@tanstack/react-query": "4.0.10",
22+
"@tanstack/react-query": "5.51.1",
2323
"blitz": "2.2.1",
2424
"flatted": "3.2.7",
2525
"next": "15.0.1",

apps/next13/src/app/loading.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default function Loading() {
2+
// You can add any UI inside Loading, including a Skeleton.
3+
return "Loading..."
4+
}

apps/next13/src/app/react-query.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
"use client"
22

3-
import {useQuery, useMutation} from "@blitzjs/rpc"
3+
import {useQuery, useMutation, useSuspenseQuery} from "@blitzjs/rpc"
44
import logout from "../auth/mutations/logout"
55
import getCurrentUser from "../users/queries/getCurrentUser"
66
import {useTransition} from "react"
77
import {useRouter} from "next/navigation"
88

99
export default function Test() {
1010
const router = useRouter()
11-
const [user] = useQuery(getCurrentUser, null)
11+
const [user] = useSuspenseQuery(getCurrentUser, null)
1212
const [isPending, startTransition] = useTransition()
1313
const [logoutMutation] = useMutation(logout)
1414
console.log(user)

apps/toolkit-app-passportjs/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/basic-features/typescript for more information.
5+
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.

apps/toolkit-app/next.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const { withNextAuthAdapter } = require("@blitzjs/auth/next-auth")
21
const { withBlitz } = require("@blitzjs/next")
32

43
/**
@@ -11,4 +10,4 @@ const config = {
1110
},
1211
}
1312

14-
module.exports = withBlitz(withNextAuthAdapter(config))
13+
module.exports = withBlitz(config)

apps/toolkit-app/src/pages/api/auth/[...nextauth].ts

Lines changed: 0 additions & 48 deletions
This file was deleted.

apps/toolkit-app/src/pages/index.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ const UserInfo = () => {
4444
<Link href={"/auth/login"} className={styles.loginButton}>
4545
<strong>Login</strong>
4646
</Link>
47-
<Link href="/api/auth/github/login" passHref legacyBehavior>
48-
<a className="button small">
49-
<strong>Sign in with GitHub</strong>
50-
</a>
51-
</Link>
5247
</>
5348
)
5449
}

apps/web/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/basic-features/typescript for more information.
5+
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.

apps/web/src/pages/api/auth/[...auth].ts

Lines changed: 0 additions & 44 deletions
This file was deleted.

apps/web/src/pages/page-with-inf-prefetch.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {useInfiniteQuery} from "@blitzjs/rpc"
1+
import {useSuspenseInfiniteQuery} from "@blitzjs/rpc"
22
import {gSSP} from "src/blitz-server"
33
import getInfiniteUsers from "src/queries/getInfiniteUsers"
44

@@ -10,9 +10,14 @@ export const getServerSideProps = gSSP(async ({ctx}) => {
1010
})
1111

1212
function PageWithPrefetchInfiniteQuery(props) {
13-
const [usersPages] = useInfiniteQuery(getInfiniteUsers, (page = {take: 3, skip: 0}) => page, {
14-
getNextPageParam: (lastPage) => lastPage.nextPage,
15-
})
13+
const [usersPages] = useSuspenseInfiniteQuery(
14+
getInfiniteUsers,
15+
(page = {take: 3, skip: 0}) => page,
16+
{
17+
getNextPageParam: (lastPage) => lastPage.nextPage,
18+
initialPageParam: {take: 3, skip: 0},
19+
},
20+
)
1621
return (
1722
<div>
1823
{usersPages.map((usersPage) =>

apps/web/src/pages/page-with-prefetch.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {useQuery} from "@blitzjs/rpc"
1+
import {useSuspenseQuery} from "@blitzjs/rpc"
22
import {gSSP} from "src/blitz-server"
33
import getUsers from "src/queries/getUsers"
44

@@ -10,7 +10,7 @@ export const getServerSideProps = gSSP(async ({ctx}) => {
1010
})
1111

1212
function PageWithPrefetch(props) {
13-
const [users] = useQuery(getUsers, {})
13+
const [users] = useSuspenseQuery(getUsers, {})
1414
return (
1515
<div>
1616
{users.map((u) => (

apps/web/src/pages/users.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function UsersPage() {
77
<div>
88
Users:
99
<ul>
10-
{users.map((user) => (
10+
{users?.map((user) => (
1111
<li key={user.id}>
1212
{user.name} - {user.email}
1313
</li>

integration-tests/auth-with-rpc/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/basic-features/typescript for more information.
5+
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.

integration-tests/auth-with-rpc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"husky": "8.0.2",
5050
"jsdom": "20.0.3",
5151
"lint-staged": "13.0.3",
52-
"playwright": "1.28.0",
52+
"playwright": "1.49.1",
5353
"prettier": "^2.7.1",
5454
"prettier-plugin-prisma": "4.4.0",
5555
"pretty-quick": "3.1.3",

integration-tests/auth-with-rpc/src/pages/authenticated-query.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import {useMutation, useQuery} from "@blitzjs/rpc"
1+
import {QueryClient, useMutation, useQuery} from "@blitzjs/rpc"
22
import logout from "../mutations/logout"
33
import getAuthenticatedBasic from "../queries/getAuthenticatedBasic"
4-
import {Suspense} from "react"
54

65
function Content() {
7-
const [result] = useQuery(getAuthenticatedBasic, undefined)
6+
const [result, {isLoading, isError, error}] = useQuery(getAuthenticatedBasic, undefined)
87
const [logoutMutation] = useMutation(logout)
8+
if (isError) throw error
9+
if (isLoading || !result) return <div>Loading...</div>
910
return (
10-
<div>
11+
<>
1112
<div id="content">{result}</div>
1213
<button
1314
id="logout"
@@ -17,16 +18,14 @@ function Content() {
1718
>
1819
logout
1920
</button>
20-
</div>
21+
</>
2122
)
2223
}
2324

2425
function AuthenticatedQuery() {
2526
return (
2627
<div id="page">
27-
<Suspense fallback={"Loading..."}>
28-
<Content />
29-
</Suspense>
28+
<Content />
3029
</div>
3130
)
3231
}

integration-tests/auth-with-rpc/src/pages/layout-authenticate-redirect.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import {useMutation, useQuery} from "@blitzjs/rpc"
1+
import {useMutation, useSuspenseQuery} from "@blitzjs/rpc"
22
import {BlitzPage} from "@blitzjs/next"
33
import AuthenticateRedirectLayout from "../layouts/AuthenticateRedirectLayout"
44
import logout from "../mutations/logout"
55
import getAuthenticatedBasic from "../queries/getAuthenticatedBasic"
66
import {Suspense} from "react"
77

88
function Content() {
9-
const [result] = useQuery(getAuthenticatedBasic, undefined)
9+
const [result] = useSuspenseQuery(getAuthenticatedBasic, undefined)
1010
const [logoutMutation] = useMutation(logout)
1111
return (
1212
<div>

integration-tests/auth-with-rpc/src/pages/login.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {useRouter} from "next/router"
2-
import {useMutation, useQuery} from "@blitzjs/rpc"
2+
import {useMutation, useSuspenseQuery} from "@blitzjs/rpc"
33
import login from "../mutations/login"
44
import logout from "../mutations/logout"
55
import getCurrentUser from "../queries/getCurrentUser"
@@ -8,7 +8,7 @@ import {Suspense, useState} from "react"
88
function Content() {
99
const router = useRouter()
1010
const [error, setError] = useState(null)
11-
const [userId] = useQuery(getCurrentUser, null)
11+
const [userId] = useSuspenseQuery(getCurrentUser, null)
1212
const [loginMutation] = useMutation(login)
1313
const [logoutMutation] = useMutation(logout)
1414

integration-tests/auth-with-rpc/src/pages/noauth-query.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import {useQuery} from "@blitzjs/rpc"
1+
import {useSuspenseQuery} from "@blitzjs/rpc"
22
import getNoauthBasic from "../queries/getNoauthBasic"
33
import {Suspense} from "react"
44

55
function Content() {
6-
const [result] = useQuery(getNoauthBasic, undefined)
6+
const [result] = useSuspenseQuery(getNoauthBasic, undefined)
77
return <div id="content">{result}</div>
88
}
99

integration-tests/auth-with-rpc/src/pages/page-dot-authenticate-redirect.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import {useMutation, useQuery} from "@blitzjs/rpc"
1+
import {useMutation, useSuspenseQuery} from "@blitzjs/rpc"
22
import {BlitzPage} from "@blitzjs/next"
33
import logout from "../mutations/logout"
44
import getAuthenticatedBasic from "../queries/getAuthenticatedBasic"
55
import {Suspense} from "react"
66

77
function Content() {
8-
const [result] = useQuery(getAuthenticatedBasic, undefined)
8+
const [result] = useSuspenseQuery(getAuthenticatedBasic, undefined)
99
const [logoutMutation] = useMutation(logout)
1010
return (
1111
<div>

integration-tests/auth-with-rpc/src/pages/page-dot-authenticate-role-redirect-stay.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import {useMutation, useQuery} from "@blitzjs/rpc"
1+
import {useMutation, useSuspenseQuery} from "@blitzjs/rpc"
22
import {BlitzPage} from "@blitzjs/next"
33
import logout from "../mutations/logout"
44
import getAuthenticatedBasic from "../queries/getAuthenticatedBasic"
55
import {Suspense} from "react"
66

77
function Content() {
8-
const [result] = useQuery(getAuthenticatedBasic, undefined)
8+
const [result] = useSuspenseQuery(getAuthenticatedBasic, undefined)
99
const [logoutMutation] = useMutation(logout)
1010
return (
1111
<div>

integration-tests/auth-with-rpc/src/pages/page-dot-authenticate-role-redirect.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import {useMutation, useQuery} from "@blitzjs/rpc"
1+
import {useMutation, useSuspenseQuery} from "@blitzjs/rpc"
22
import {BlitzPage} from "@blitzjs/next"
33
import logout from "../mutations/logout"
44
import getAuthenticatedBasic from "../queries/getAuthenticatedBasic"
55
import {Suspense} from "react"
66

77
function Content() {
8-
const [result] = useQuery(getAuthenticatedBasic, undefined)
8+
const [result] = useSuspenseQuery(getAuthenticatedBasic, undefined)
99
const [logoutMutation] = useMutation(logout)
1010
return (
1111
<div>

0 commit comments

Comments
 (0)