Skip to content

Commit b6e057e

Browse files
committed
fix(apollo-vertex): remove ssr false for shell template
1 parent f3bd6b3 commit b6e057e

2 files changed

Lines changed: 5 additions & 16 deletions

File tree

apps/apollo-vertex/registry/shell/shell-auth-provider.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
1+
import { useQuery, useQueryClient } from "@tanstack/react-query";
22
import { jwtDecode } from "jwt-decode";
33
import {
44
createContext,
@@ -69,13 +69,14 @@ interface UseAccessTokenProps {
6969
export const useAccessToken = ({ clientId, baseUrl }: UseAccessTokenProps) => {
7070
const queryClient = useQueryClient();
7171

72-
const { data: token } = useSuspenseQuery({
72+
const { data: token } = useQuery({
7373
queryKey: TOKEN_QUERY_KEY,
7474
queryFn: async () => await ensureValidToken(queryClient, clientId, baseUrl),
7575
refetchInterval: 60 * 1000,
76+
enabled: typeof window !== "undefined",
7677
});
7778

78-
return token;
79+
return token ?? null;
7980
};
8081

8182
interface ShellAuthProviderProps {
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"use client";
22

33
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
4-
import dynamic from "next/dynamic";
54
import { ApolloShell } from "@/registry/shell/shell";
65

76
interface ShellTemplateWithAuthProps {
@@ -10,9 +9,7 @@ interface ShellTemplateWithAuthProps {
109
const queryClient = new QueryClient();
1110

1211
const baseUrl = typeof window === "undefined" ? "" : window.location.origin;
13-
export function ShellTemplateComponent({
14-
variant,
15-
}: ShellTemplateWithAuthProps) {
12+
export function ShellTemplate({ variant }: ShellTemplateWithAuthProps) {
1613
return (
1714
<QueryClientProvider client={queryClient}>
1815
<ApolloShell
@@ -28,12 +25,3 @@ export function ShellTemplateComponent({
2825
</QueryClientProvider>
2926
);
3027
}
31-
32-
export const ShellTemplate = dynamic(
33-
() => {
34-
return Promise.resolve(ShellTemplateComponent);
35-
},
36-
{
37-
ssr: false,
38-
},
39-
);

0 commit comments

Comments
 (0)