INNER CODE UNIT · TypeScript
fns
Diizzayy/nuxt-graphql-client · src/context.ts:26
const fns = template.match(ctx?.codegen ? /\w+\s*(?=\(variables)/g : /\w+(?=:\s\(variables)/g)?.sort() || []
return [...acc, ...fns]
}, [] as string[])
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 = () => [