How to use the @graphql-codegen/cli.setCommandOptions function in @graphql-codegen/cli

To help you get started, we’ve selected a few @graphql-codegen/cli examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Urigo / graphql-cli / packages / commands / codegen / src / index.ts View on Github external
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);
        }

@graphql-codegen/cli

<p align="center"> <img src="https://github.com/dotansimha/graphql-code-generator/blob/master/logo.png?raw=true" /> </p>

MIT
Latest version published 3 months ago

Package Health Score

83 / 100
Full package analysis