From 0e8dd8f01eed8eac5abdb5cee090e274c9d05c07 Mon Sep 17 00:00:00 2001 From: Pascal Martineau Date: Thu, 18 Sep 2025 11:54:22 -0400 Subject: [PATCH] fix: handleSwitchTo --- .../themes/ccat/server/graphqlMiddleware.serverOptions.ts | 1 + wp-content/themes/ccat/server/utils/auth.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/wp-content/themes/ccat/server/graphqlMiddleware.serverOptions.ts b/wp-content/themes/ccat/server/graphqlMiddleware.serverOptions.ts index 09d9406..ce8bcdf 100644 --- a/wp-content/themes/ccat/server/graphqlMiddleware.serverOptions.ts +++ b/wp-content/themes/ccat/server/graphqlMiddleware.serverOptions.ts @@ -32,6 +32,7 @@ export default defineGraphqlServerOptions({ return { headers: { ...headers, Authorization: `Bearer ${session.secure.authToken}` } }; }, + // @ts-expect-error https://github.com/dulnan/nuxt-graphql-middleware/issues/69 async onServerResponse(event, response, _operation, operationName) { switch (operationName) { case "login": diff --git a/wp-content/themes/ccat/server/utils/auth.ts b/wp-content/themes/ccat/server/utils/auth.ts index 31a9c74..fad34df 100644 --- a/wp-content/themes/ccat/server/utils/auth.ts +++ b/wp-content/themes/ccat/server/utils/auth.ts @@ -26,11 +26,11 @@ export async function handleLogout(event: H3Event) { } export async function handleSwitchTo(event: H3Event, data?: SwitchToRootMutation) { - if (!data?.userSwitchTo?.user) { + if (!data?.switchTo?.user) { return; } const session = await getUserSession(event); - const { authToken, refreshToken, user } = data.userSwitchTo; + const { authToken, refreshToken, user } = data.switchTo; await setUserSession(event, { user: { id: user.id,