UNPKG

996 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const common_1 = require("@graphql-cli/common");
4const cli_1 = require("@graphql-codegen/cli");
5exports.default = (0, common_1.defineCommand)(api => {
6 return {
7 command: 'codegen',
8 builder(yargs) {
9 return yargs.options((0, cli_1.buildOptions)());
10 },
11 async handler(args) {
12 const config = await api.useConfig({
13 rootDir: args.config || process.cwd(),
14 extensions: [cli_1.CodegenExtension],
15 });
16 // Create Codegen Context with our loaded GraphQL Config
17 const codegenContext = new cli_1.CodegenContext({
18 graphqlConfig: config,
19 });
20 // This will update Codegen Context with the options provided in CLI arguments
21 (0, cli_1.updateContextWithCliFlags)(codegenContext, args);
22 await (0, cli_1.generate)(codegenContext);
23 },
24 };
25});