Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async init({ program, loadGraphQLConfig, reportError }) {
const commandInstance = program.command('codegen');
// Let codegen manage our command instance with its own options
setCommandOptions(commandInstance)
.action(async cliFlags => {
try {
// Load root GraphQL Config not Project Config because Codegen will update it by looking at `project` param
const graphqlConfig = await loadGraphQLConfig({
extensions: [CodegenExtension]
});
// Create Codegen Context with our loaded GraphQL Config
const codegenContext = new CodegenContext({
graphqlConfig,
});
// This will update Codegen Context with the options provided in CLI arguments
updateContextWithCliFlags(codegenContext, cliFlags);
await generate(codegenContext);
} catch (e) {
reportError(e);
}