dotansimha / dotansimha/graphql-code-generator

ignoreNoDocuments suppresses errors

Open
#9,915 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

### Which packages are impacted by your issue?

@graphql-codegen/cli

### Describe the bug

When `ignoreNoDocuments` flag is set to `true` in the graphql config, the errors from existing files are not shown to the console, and the `graphql-codegen` command exits with code `0`.

From [the docs](https://the-guild.dev/graphql/codegen/docs/config-reference/codegen-config):
> ignoreNoDocuments - A flag to not exit with non-zero exit code when there are no documents

So it seems to ignore errors not only when there are no documents but also when there are documents with errors.

### Your Example Website or App

NN

### Steps to Reproduce the Bug or Issue

This graphql code is correct:
```
mutation someMutation {
xxx {
set(
input: { ... }
)
}
}
```

And this one is not:
```
mutation someMutation() {
xxx {
set(
input: { ... }
)
}
}
```

The error should be something like `expected $, got )`. With `ignoreNoDocuments: true` there is no error but the output files are invalid, with that flag set to `false` the error is thrown properly.

### Expected behavior

The error should be something like `expected $, got )`. With `ignoreNoDocuments: true` there is no error but the output files are invalid, with that flag set to `false` the error is thrown properly.

### Screenshots or Videos

_No response_

### Platform

- OS: macOS Ventura 13.5.2 (22G91)
- NodeJS: v18.17.1
- `graphql` version: 15.8.0
- `@graphql-codegen/*` version(s): 5.0.2

### Codegen Config File

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

const config: CodegenConfig = {
schema: '[...]',
documents: ['src/**/*.{ts,tsx,graphql}'],
generates: {
'./src/__generated__/': {
preset: 'client',
plugins: [],
presetConfig: {
gqlTagName: 'gql',
},
},
'./src/__generated__/queries.ts': {
plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
},
},
ignoreNoDocuments: true,
};

export default config;

```

### Additional context

NN

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.