UNPKG

@graphql-cli/codegen

Version:

GraphQL Code Generator's GraphQL CLI plugin. GraphQL Code Generator is a tool that generates code from your GraphQL schema and documents for your backend or frontend with flexible support for custom plugins and templates.

26 lines (25 loc) 996 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const common_1 = require("@graphql-cli/common"); const cli_1 = require("@graphql-codegen/cli"); exports.default = (0, common_1.defineCommand)(api => { return { command: 'codegen', builder(yargs) { return yargs.options((0, cli_1.buildOptions)()); }, async handler(args) { const config = await api.useConfig({ rootDir: args.config || process.cwd(), extensions: [cli_1.CodegenExtension], }); // Create Codegen Context with our loaded GraphQL Config const codegenContext = new cli_1.CodegenContext({ graphqlConfig: config, }); // This will update Codegen Context with the options provided in CLI arguments (0, cli_1.updateContextWithCliFlags)(codegenContext, args); await (0, cli_1.generate)(codegenContext); }, }; });