Skip to content

Commit

Permalink
Fix prefetching multiple queries causes only the last one to be passe…
Browse files Browse the repository at this point in the history
…d to page (#3551)
  • Loading branch information
Zeko369 authored Jul 17, 2022
1 parent ab4d9de commit 8d9ea00
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/twelve-lemons-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@blitzjs/next": patch
---

Fix prefetching multiple queries causes only the last one to be passed to page
4 changes: 3 additions & 1 deletion packages/blitz-next/src/index-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ export const setupBlitzServer = ({plugins, onError}: SetupBlitzOptions) => {
defaultOptions = {},
infinite = false,
) => {
queryClient = new QueryClient({defaultOptions})
if (!queryClient) {
queryClient = new QueryClient({defaultOptions})
}

const queryKey = infinite ? getInfiniteQueryKey(fn, input) : getQueryKey(fn, input)
await queryClient.prefetchQuery(queryKey, () => fn(input, ctx))
Expand Down

0 comments on commit 8d9ea00

Please sign in to comment.