INNER CODE UNIT · TypeScript

fnName

Diizzayy/nuxt-graphql-client · src/context.ts:31

  const fnName = (fn: string) => prefix + upperFirst(fn)

  const fnExp = (fn: string, typed = false) => {
    const name = fnName(fn)

    if (!typed) { return `export const ${name} = (...params) => useGql()('${fn}', ...params)` }

    return `  export const ${name}: (...params: Parameters<GqlSdkFuncs['${fn}']>) => ReturnType<GqlSdkFuncs['${fn}']>`
  }

  ctx.clients = ctx.clients?.filter(c => ctx.clientDocs?.[c]?.length)

  ctx.generateImports = () => [
    'import { useGql } from \'#imports\'',
    ...ctx.clients!.map(client => `import { getSdk as ${client}GqlSdk } from '#gql/${client}'`),
    'export const GqlSdks = {',
    ...ctx.clients!.map(client => `  ${client}: ${client}GqlSdk,`),
    '}',

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…