import { defineCommand } from '@graphql-cli/common' ; import { CodegenExtension , CodegenContext , generate , updateContextWithCliFlags , buildOptions , YamlCliFlags , } from '@graphql-codegen/cli' ; export default defineCommand < { } , YamlCliFlags > ( api => { return { command : 'codegen' , builder ( yargs ) { return yargs . options ( buildOptions ( ) as any ) as any ; } , async handler ( args ) { const config = await api . useConfig ( { rootDir : args . config || process . cwd ( ) , extensions : [ CodegenExtension ] , } ) ; const codegenContext = new CodegenContext ( { graphqlConfig : config , } ) ; updateContextWithCliFlags ( codegenContext , args ) ; await generate ( codegenContext ) ; } , } ; } ) ;