Some output errors are hidden and fail silently even with "verbose" and "noSilentErrors" on #10189
Description
Which packages are impacted by your issue?
@graphql-codegen/cli
Describe the bug
Some errors during the output stage are supressed even with verbose
and noSilentErrors
options set to true, failing silently not giving any clue as to what the problem is (sometimes giving no clue that there is a problem unless you delete the old output, refresh and see no new output is generated).
An easy way to replicate this is to try to output to a directory (e.g. './types/
) with configuration that will want to output to a single file. Instead of throwing a relevant error, this fails silently during the output phase (I imagine a lot of other file system errors (e.g. permissions errors?) will get suppressed in a similar way?).
With npm run codegen
the verbose console output will look like this, appearing to have succeeded:
[STARTED] Parse Configuration
[SUCCESS] Parse Configuration
[STARTED] Generate outputs
[STARTED] Generate to ./types/
[STARTED] Load GraphQL schemas
[SUCCESS] Load GraphQL schemas
[STARTED] Load GraphQL documents
[SUCCESS] Load GraphQL documents
[STARTED] Generate
[SUCCESS] Generate
[SUCCESS] Generate to ./types/
[SUCCESS] Generate outputs
Passing --verbose
to npm itself like npm run --verbose codegen
adds npm verb code 1
and using PNPM adds ELIFECYCLE Command failed with exit code 1.
but nothing indicates what the supressed error is.
Your Example Website or App
https://stackblitz.com/edit/github-hceazx?file=types.ts
Steps to Reproduce the Bug or Issue
Run npm run codegen
Expected behavior
It should give a relevant error message, in this case something like "./types/
is not a file" or just output the actual system error in the console.
Screenshots or Videos
No response
Platform
- OS: macOS (and whatever StackBitz uses)
- NodeJS: v18.19.1 (and whatever StackBitz uses)
graphql
version: 16.9.0@graphql-codegen/*
version(s): @graphql-codegen/cli 5.0.3
Codegen Config File
import { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'schema.graphql',
documents: 'document.graphql',
generates: {
// This config should output to a file (some other configs may output to a folder).
// Instead of giving an error message, `npm run codegen --verbose` fails silently.
'./types/': { plugins: ['typescript', 'typescript-operations'] },
},
verbose: true,
noSilentErrors: true,
};
export default config;
Additional context
Related non-dupe suppressed error issues:
- There's a
noSilentErrors
option that it false by default (?!?) but it makes no difference in this case - There's an open issue about suppressed errors with
ignoreNoDocuments
, but I'm not using that - There's also an issue with some syntax errors failing silently but that's a different step to this and appears to be a bug with existing error forwarding
- See More verbose error messages (closed as completed) for some relevant history