Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade tanstack query to v5 #4360

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ad17045
upgrade syntax to v5
siddhsuresh Jul 16, 2024
7110ae3
blitz-next changes
siddhsuresh Jul 16, 2024
be6ed9d
fix types and export new functions
siddhsuresh Jul 16, 2024
c473d33
fix blitz suspense logic
siddhsuresh Jul 16, 2024
96bfd50
fix workflow
siddhsuresh Jul 16, 2024
00a603c
changeset
siddhsuresh Jul 16, 2024
c4eced2
fix pnpm version
siddhsuresh Jul 16, 2024
29ff22b
Merge branch 'main' into siddharth/query-v5
siddhsuresh Jul 31, 2024
a1c75dc
Merge branch 'main' into siddharth/query-v5
siddhsuresh Aug 28, 2024
b8bc21e
fix pnpm lock file
siddhsuresh Aug 28, 2024
25ce6f9
latest pnpm version
siddhsuresh Aug 28, 2024
3071c76
fix
siddhsuresh Aug 28, 2024
985af9e
fix pnpm lock file
siddhsuresh Aug 28, 2024
ef05a9a
fixes
siddhsuresh Sep 30, 2024
18c6bc0
Merge branch 'main' into siddharth/query-v5
siddhsuresh Sep 30, 2024
87dca1e
commit
siddhsuresh Sep 30, 2024
be9fb20
commit
siddhsuresh Oct 8, 2024
a70af7a
Merge branch 'main' into siddharth/query-v5
siddhsuresh Oct 26, 2024
579bc78
pnpm lock update
siddhsuresh Oct 26, 2024
ff95925
revert change
siddhsuresh Oct 26, 2024
e46f059
fixes
siddhsuresh Oct 26, 2024
8260135
temp: remove patch
siddhsuresh Oct 26, 2024
bafb063
lockfile
siddhsuresh Oct 26, 2024
c458d7b
chore: fix build and lint
siddhsuresh Oct 26, 2024
f7ff214
fix: auth-with-rpc tests
siddhsuresh Oct 26, 2024
90c030a
qm test
siddhsuresh Oct 26, 2024
4123e39
remaining tests
siddhsuresh Oct 26, 2024
5b56ebd
fix rpc unit tests
siddhsuresh Dec 20, 2024
c243704
revrt
siddhsuresh Dec 20, 2024
ec2300c
another revert pnpm version change
siddhsuresh Dec 20, 2024
e5b7bc6
revert back to pnpm 8.6.6
siddhsuresh Dec 20, 2024
efaa1df
Merge branch 'main' into siddharth/query-v5
siddhsuresh Dec 20, 2024
817ba6e
Merge branch 'main' into siddharth/query-v5
siddhsuresh Dec 23, 2024
8b0fe77
Merge branch 'main' into siddharth/query-v5
siddhsuresh Dec 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/sweet-socks-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@blitzjs/next": major
"@blitzjs/rpc": major
"blitz": major
"@blitzjs/auth": major
"@blitzjs/codemod": major
"@blitzjs/config": major
"@blitzjs/generator": major
---

TODO: Upgrade @tanstack/react-query to v5.1.1
4 changes: 2 additions & 2 deletions .github/workflows/pr-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: |
pr="$(gh api repos/${{ github.repository }}/pulls/${{ github.event.issue.number }})"
head_sha="$(echo "$pr" | jq -r .head.sha)"

echo "head_sha=$head_sha" >> $GITHUB_OUTPUT

- uses: actions/checkout@v4
Expand All @@ -39,7 +39,7 @@ jobs:
- name: Setup PNPM
uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
with:
version: 8.9.0
version: 8.6.6

- name: Setup Node
uses: actions/setup-node@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Pre-publish
uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
with:
version: 8.9.0
version: 8.6.6
- run: pnpm install
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
Expand Down
2 changes: 1 addition & 1 deletion apps/next13/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@hookform/error-message": "2.0.0",
"@hookform/resolvers": "2.9.10",
"@prisma/client": "^4.5.0",
"@tanstack/react-query": "4.0.10",
"@tanstack/react-query": "5.51.1",
"blitz": "2.2.0",
"flatted": "3.2.7",
"next": "15.0.1",
Expand Down
4 changes: 4 additions & 0 deletions apps/next13/src/app/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default function Loading() {
// You can add any UI inside Loading, including a Skeleton.
return "Loading..."
}
4 changes: 2 additions & 2 deletions apps/next13/src/app/react-query.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"use client"

import {useQuery, useMutation} from "@blitzjs/rpc"
import {useQuery, useMutation, useSuspenseQuery} from "@blitzjs/rpc"
import logout from "../auth/mutations/logout"
import getCurrentUser from "../users/queries/getCurrentUser"
import {useTransition} from "react"
import {useRouter} from "next/navigation"

export default function Test() {
const router = useRouter()
const [user] = useQuery(getCurrentUser, null)
const [user] = useSuspenseQuery(getCurrentUser, null)
const [isPending, startTransition] = useTransition()
const [logoutMutation] = useMutation(logout)
console.log(user)
Expand Down
2 changes: 1 addition & 1 deletion apps/toolkit-app-passportjs/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
3 changes: 1 addition & 2 deletions apps/toolkit-app/next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const { withNextAuthAdapter } = require("@blitzjs/auth/next-auth")
const { withBlitz } = require("@blitzjs/next")

/**
Expand All @@ -11,4 +10,4 @@ const config = {
},
}

module.exports = withBlitz(withNextAuthAdapter(config))
module.exports = withBlitz(config)
48 changes: 0 additions & 48 deletions apps/toolkit-app/src/pages/api/auth/[...nextauth].ts

This file was deleted.

5 changes: 0 additions & 5 deletions apps/toolkit-app/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ const UserInfo = () => {
<Link href={"/auth/login"} className={styles.loginButton}>
<strong>Login</strong>
</Link>
<Link href="/api/auth/github/login" passHref legacyBehavior>
<a className="button small">
<strong>Sign in with GitHub</strong>
</a>
</Link>
</>
)
}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
44 changes: 0 additions & 44 deletions apps/web/src/pages/api/auth/[...auth].ts

This file was deleted.

13 changes: 9 additions & 4 deletions apps/web/src/pages/page-with-inf-prefetch.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useInfiniteQuery} from "@blitzjs/rpc"
import {useSuspenseInfiniteQuery} from "@blitzjs/rpc"
import {gSSP} from "src/blitz-server"
import getInfiniteUsers from "src/queries/getInfiniteUsers"

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

function PageWithPrefetchInfiniteQuery(props) {
const [usersPages] = useInfiniteQuery(getInfiniteUsers, (page = {take: 3, skip: 0}) => page, {
getNextPageParam: (lastPage) => lastPage.nextPage,
})
const [usersPages] = useSuspenseInfiniteQuery(
getInfiniteUsers,
(page = {take: 3, skip: 0}) => page,
{
getNextPageParam: (lastPage) => lastPage.nextPage,
initialPageParam: {take: 3, skip: 0},
},
)
return (
<div>
{usersPages.map((usersPage) =>
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/pages/page-with-prefetch.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useQuery} from "@blitzjs/rpc"
import {useSuspenseQuery} from "@blitzjs/rpc"
import {gSSP} from "src/blitz-server"
import getUsers from "src/queries/getUsers"

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

function PageWithPrefetch(props) {
const [users] = useQuery(getUsers, {})
const [users] = useSuspenseQuery(getUsers, {})
return (
<div>
{users.map((u) => (
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/pages/users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function UsersPage() {
<div>
Users:
<ul>
{users.map((user) => (
{users?.map((user) => (
<li key={user.id}>
{user.name} - {user.email}
</li>
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/auth-with-rpc/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import {useMutation, useQuery} from "@blitzjs/rpc"
import {QueryClient, useMutation, useQuery} from "@blitzjs/rpc"
import logout from "../mutations/logout"
import getAuthenticatedBasic from "../queries/getAuthenticatedBasic"
import {Suspense} from "react"

function Content() {
const [result] = useQuery(getAuthenticatedBasic, undefined)
const [result, {isLoading, isError, error}] = useQuery(getAuthenticatedBasic, undefined)
const [logoutMutation] = useMutation(logout)
if (isError) throw error
if (isLoading || !result) return <div>Loading...</div>
return (
<div>
<>
<div id="content">{result}</div>
<button
id="logout"
Expand All @@ -17,16 +18,14 @@ function Content() {
>
logout
</button>
</div>
</>
)
}

function AuthenticatedQuery() {
return (
<div id="page">
<Suspense fallback={"Loading..."}>
<Content />
</Suspense>
<Content />
</div>
siddhsuresh marked this conversation as resolved.
Show resolved Hide resolved
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {useMutation, useQuery} from "@blitzjs/rpc"
import {useMutation, useSuspenseQuery} from "@blitzjs/rpc"
import {BlitzPage} from "@blitzjs/next"
import AuthenticateRedirectLayout from "../layouts/AuthenticateRedirectLayout"
import logout from "../mutations/logout"
import getAuthenticatedBasic from "../queries/getAuthenticatedBasic"
import {Suspense} from "react"

function Content() {
const [result] = useQuery(getAuthenticatedBasic, undefined)
const [result] = useSuspenseQuery(getAuthenticatedBasic, undefined)
const [logoutMutation] = useMutation(logout)
return (
<div>
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/auth-with-rpc/src/pages/login.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {useRouter} from "next/router"
import {useMutation, useQuery} from "@blitzjs/rpc"
import {useMutation, useSuspenseQuery} from "@blitzjs/rpc"
import login from "../mutations/login"
import logout from "../mutations/logout"
import getCurrentUser from "../queries/getCurrentUser"
Expand All @@ -8,7 +8,7 @@ import {Suspense, useState} from "react"
function Content() {
const router = useRouter()
const [error, setError] = useState(null)
const [userId] = useQuery(getCurrentUser, null)
const [userId] = useSuspenseQuery(getCurrentUser, null)
const [loginMutation] = useMutation(login)
const [logoutMutation] = useMutation(logout)

Expand Down
4 changes: 2 additions & 2 deletions integration-tests/auth-with-rpc/src/pages/noauth-query.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {useQuery} from "@blitzjs/rpc"
import {useSuspenseQuery} from "@blitzjs/rpc"
import getNoauthBasic from "../queries/getNoauthBasic"
import {Suspense} from "react"

function Content() {
const [result] = useQuery(getNoauthBasic, undefined)
const [result] = useSuspenseQuery(getNoauthBasic, undefined)
return <div id="content">{result}</div>
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {useMutation, useQuery} from "@blitzjs/rpc"
import {useMutation, useSuspenseQuery} from "@blitzjs/rpc"
import {BlitzPage} from "@blitzjs/next"
import logout from "../mutations/logout"
import getAuthenticatedBasic from "../queries/getAuthenticatedBasic"
import {Suspense} from "react"

function Content() {
const [result] = useQuery(getAuthenticatedBasic, undefined)
const [result] = useSuspenseQuery(getAuthenticatedBasic, undefined)
const [logoutMutation] = useMutation(logout)
return (
<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {useMutation, useQuery} from "@blitzjs/rpc"
import {useMutation, useSuspenseQuery} from "@blitzjs/rpc"
import {BlitzPage} from "@blitzjs/next"
import logout from "../mutations/logout"
import getAuthenticatedBasic from "../queries/getAuthenticatedBasic"
import {Suspense} from "react"

function Content() {
const [result] = useQuery(getAuthenticatedBasic, undefined)
const [result] = useSuspenseQuery(getAuthenticatedBasic, undefined)
const [logoutMutation] = useMutation(logout)
return (
<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {useMutation, useQuery} from "@blitzjs/rpc"
import {useMutation, useSuspenseQuery} from "@blitzjs/rpc"
import {BlitzPage} from "@blitzjs/next"
import logout from "../mutations/logout"
import getAuthenticatedBasic from "../queries/getAuthenticatedBasic"
import {Suspense} from "react"

function Content() {
const [result] = useQuery(getAuthenticatedBasic, undefined)
const [result] = useSuspenseQuery(getAuthenticatedBasic, undefined)
const [logoutMutation] = useMutation(logout)
return (
<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {useMutation, useQuery} from "@blitzjs/rpc"
import {useMutation, useSuspenseQuery} from "@blitzjs/rpc"
import {BlitzPage} from "@blitzjs/next"
import logout from "../mutations/logout"
import getAuthenticatedBasic from "../queries/getAuthenticatedBasic"
import {Suspense} from "react"

function Content() {
const [result] = useQuery(getAuthenticatedBasic, undefined)
const [result] = useSuspenseQuery(getAuthenticatedBasic, undefined)
const [logoutMutation] = useMutation(logout)
return (
<div>
Expand Down
Loading
Loading