INNER CODE UNIT · TypeScript

useGql

Diizzayy/nuxt-graphql-client · src/runtime/composables/index.ts:217

export function useGql(): <
  T extends GqlOps,
  R extends ReturnType<GqlSdkFuncs[T]>,
  P extends Parameters<GqlSdkFuncs[T]>['0']
> (...args: [T, P] | [{ operation: T, variables?: P }]) => R

export function useGql() {
  const state = useGqlState()
  const errState = useGqlErrorState()

  return (...args: any[]) => {
    const arg0 = args?.[0]
    const operation = (typeof arg0 === 'object' && 'operation' in arg0) ? arg0.operation : args?.[0] ?? undefined
    const variables = (typeof arg0 === 'object' && 'variables' in arg0) ? arg0.variables : args?.[1] ?? undefined

    const client = Object.keys(GqClientOps).find(k => GqClientOps[k as keyof typeof GqClientOps].includes(operation)) ?? 'default'

    const clientState = state?.value?.[client]

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…