Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI exits with code 1 without an error message if directory is listed as output instead of file #9272

Open
dallonf opened this issue Apr 4, 2023 · 0 comments

Comments

@dallonf
Copy link

dallonf commented Apr 4, 2023

Which packages are impacted by your issue?

@graphql-codegen/cli

Describe the bug

If you accidentally specify a directory instead of a filepath as a key in generates, the graphql-codegen command will exit with an error code of 1, but provide no other messaging as to what's gone wrong.

Your Example Website or App

https://stackblitz.com/edit/github-itj2kj?file=package.json

Steps to Reproduce the Bug or Issue

In the StackBlitz example terminal, run: npm run codegen && echo done

Notice that "done" is not printed; this is because the codegen step exits with code 1.

If you change output to "output/types.ts" in the codegen.ts file and run the same command, you'll see that the operation completes and prints out "done".

Expected behavior

As a user, I expected some sort of error message to indicate what I've done wrong here, but instead an exit code (and a lack of generated output) is my only indication that anything's gone wrong at all.

Screenshots or Videos

No response

Platform

  • OS: macOS 12.6.3
  • NodeJS: v14.21.3 (but StackBlitz is on v16.14.2)
  • graphql version: v16.6.0
  • @graphql-codegen/* version(s):
    • @graphql-codegen/cli@3.3.0
    • @graphql-codegen/core@3.1.0
    • @graphql-codegen/introspection@3.0.1
    • @graphql-codegen/plugin-helpers@4.2.0
    • @graphql-codegen/schema-ast@3.0.1
    • @graphql-codegen/typescript-operations@3.0.3
    • @graphql-codegen/typescript-resolvers@3.2.0
    • @graphql-codegen/typescript@3.0.3
    • @graphql-codegen/visitor-plugin-common@3.1.0

Codegen Config File

import { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
  schema: 'schema.graphql',
  documents: 'document.graphql',
  generates: {
    // "output" is a directory
    output: { plugins: ['typescript', 'typescript-operations'] },
  },
};

export default config;

Additional context

From stepping through the CLI code, it looks like there's just no error reporting on the output step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant