INNER CODE UNIT · TypeScript
useGqlToken
Diizzayy/nuxt-graphql-client · src/runtime/composables/index.ts:132
export function useGqlToken(opts: GqlTokenOptions & { token: GqlToken }): void
export function useGqlToken(...args: any[]) {
args = args || []
const config: TokenOpts = args[0]?.config || args?.[1]?.config
const refreshData = args[0]?.refreshData ?? args?.[1]?.refreshData ?? true
let client: GqlClients = args[0]?.client || args?.[1]?.client
let token: string = typeof args[0] === 'string' || args?.[0] === null ? args[0] : args?.[0]?.token
if (token) { token = token.trim() }
client = getGqlClient(client)
const tokenStorage = (useRuntimeConfig()?.public?.['graphql-client'] as GqlConfig)?.clients?.[client]?.tokenStorage
if (token !== undefined && typeof tokenStorage === 'object') {
if (tokenStorage.mode === 'cookie') {
const cookie = useCookie(tokenStorage.name!, tokenStorage.cookieOptions)