dotansimha / dotansimha/graphql-code-generator
Setting configs at the plugin level does not work in latest cli version
- 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, @graphql-codegen/plugin-helpers
### Describe the bug
Specifying configs at the plugin level as described in the [config reference](https://the-guild.dev/graphql/codegen/docs/config-reference/config-field#plugin-level) no longer works in the latest version of the cli (3.2.2). I think the root cause is in version 4.1.0 of the `@graphql-codegen/plugin-helpers` package. Running `yarn generate` returns the following output:
```
✖ Invalid Codegen Configuration!
Please make sure that your codegen config file has defined plugins list for output "types.ts".
It should looks like that:
schema:
- my-schema.graphql
generates:
my-file.ts:
- plugin1
- plugin2
- plugin3
◼ Generate outputs
error Command failed with exit code 1.
```
### Your Example Website or App
https://stackblitz.com/edit/github-vaowh6?file=codegen.ts
### Steps to Reproduce the Bug or Issue
1. Go to https://stackblitz.com/edit/github-vaowh6?file=codegen.ts
2. See error in terminal
3. Change the cli to an older version (one that does not require plugin-helpers 4.1.0). Enter `npm i @graphql-codegen/plugin-helpers@4.0.0 @graphql-codegen/cli@3.0.0` in the terminal
4. Run `yarn generate`. The error is now resolved.
### Expected behavior
As a user, I expected my codegen config containing plugin level configs to still work after updating to the latest version of the CLI.
### Screenshots or Videos
_No response_
### Platform
- `OS`: multiple
- `NodeJS`: multiple
- `graphql` version: 16.6.0
- `@graphql-codegen/add`: "4.0.1",
- `@graphql-codegen/cli`: "3.2.2"
### Codegen Config File
```
schema: 'schema.graphql',
documents: 'document.graphql',
generates: {
'types.ts': [
{
typescript: {
declarationKind: 'interface',
},
},
{
'typescript-operations': {
preResolveTypes: true,
},
},
],
},
```
### Additional context
I traced the problem back to this line of code: https://github.com/dotansimha/graphql-code-generator/blame/master/packages/utils/plugins-helpers/src/helpers.ts#L28. Using the previous version of that line does not give any errors.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.