UNPKG

1.25 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const cli_1 = require("@graphql-codegen/cli");
4exports.plugin = {
5 async init({ program, loadGraphQLConfig, reportError }) {
6 // Let codegen manage our command instance with its own options
7 cli_1.setCommandOptions(program
8 .command('codegen'))
9 .action(async (cliFlags) => {
10 try {
11 // Load root GraphQL Config not Project Config because Codegen will update it by looking at `project` param
12 const graphqlConfig = await loadGraphQLConfig({
13 extensions: [cli_1.CodegenExtension]
14 });
15 // Create Codegen Context with our loaded GraphQL Config
16 const codegenContext = new cli_1.CodegenContext({
17 graphqlConfig: graphqlConfig,
18 });
19 // This will update Codegen Context with the options provided in CLI arguments
20 cli_1.updateContextWithCliFlags(codegenContext, cliFlags);
21 await cli_1.generate(codegenContext);
22 }
23 catch (e) {
24 reportError(e);
25 }
26 });
27 }
28};
29//# sourceMappingURL=index.js.map
\No newline at end of file