INNER CODE UNIT · TypeScript
getGqlClient
Diizzayy/nuxt-graphql-client · src/runtime/composables/index.ts:12
const getGqlClient = (client?: GqlClients, state?: Ref<GqlState>): GqlClients => {
if (!state) { state = useGqlState() }
return client || (state.value?.default ? 'default' : Object.keys(state.value)[0]) as GqlClients
}
const useGqlState = (): Ref<GqlState> => {
const nuxtApp = useNuxtApp() as Partial<{ _gqlState: Ref<GqlState> }>
if (!nuxtApp._gqlState) { throw new Error('GQL State is not available.') }
return nuxtApp?._gqlState
}
/**
*
* @param {object} options Changes to be made to gqlState
* @param {GqlClients} options.client The name of your GraphQL client.