30fdc71fcd
* fix(fe2): log out on invalid auth token on any GQL call * fix(fe1): redirecting to login page on any 403 GQL req * WIP invalid token * stricter toker invalidation checks in FE1 * stricter token check in FE2 as well
16 lines
422 B
TypeScript
16 lines
422 B
TypeScript
export const useApolloClientIfAvailable = () => {
|
|
const nuxt = useNuxtApp()
|
|
const getClient = () => (nuxt.$apollo?.default ? nuxt.$apollo.default : undefined)
|
|
return getClient
|
|
}
|
|
|
|
export const useApolloClientFromNuxt = () => {
|
|
const getClient = useApolloClientIfAvailable()
|
|
const client = getClient()
|
|
if (!client) {
|
|
throw new Error("Apollo Client can't be resolved from NuxtApp yet")
|
|
}
|
|
|
|
return client
|
|
}
|