feat: enhance authentication error handling and schema fetching

Handle authentication errors related to consent and login in the Apollo 
client by redirecting users to the Auth0 login page as necessary. Update
the schema-fetching logic to support dynamic references from the URL, 
removing mock data and improving overall data integrity in the 
application.
Ensure proper loading states during the fetching process.
This commit is contained in:
2025-11-23 14:01:32 +01:00
parent de1f4b6e86
commit 5c17c798c4
3 changed files with 67 additions and 51 deletions
+18 -2
View File
@@ -51,8 +51,24 @@ export default defineNuxtPlugin((nuxtApp) => {
}
}
}
} catch (error) {
console.error('[Apollo] Failed to get Auth0 token:', error)
} catch (error: any) {
// Handle consent required error
if (error?.error === 'consent_required') {
console.warn('[Apollo] Consent required, redirecting to login...')
const auth0Instance = (nuxtApp.vueApp.config.globalProperties as any).$auth0
// Trigger login with consent
await auth0Instance.loginWithRedirect({
authorizationParams: {
prompt: 'consent',
},
})
} else if (error?.error === 'login_required') {
console.warn('[Apollo] Login required, redirecting...')
const auth0Instance = (nuxtApp.vueApp.config.globalProperties as any).$auth0
await auth0Instance.loginWithRedirect()
} else {
console.error('[Apollo] Failed to get Auth0 token:', error)
}
}
return { headers }