dotansimha / dotansimha/graphql-code-generator
Uppercase and Lowercase graphql operation names result in duplicated types / interfaces in the generated graphql.ts
- 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/client-preset
### Describe the bug
When generating the `graphql.ts` from codegen using `client-preset`, there is a scenario where no error in thrown but duplicated interfaces / types are created in the generated file, causing the TypeScript compilation to fail afterwards.
This happens when the names given to the operations are unique and differ only with the case, e.g.:
```GraphQL
query myQuery {
myQuery {
id
}
}
query MyQuery {
myQuery {
id
}
}
```
will not trigger any error on the generation but will create twice the `MyQuery` type, resulting in compile errors.
### Your Example Website or App
https://stackblitz.com/edit/github-7tzyn8?file=src/gql/graphql.ts
### Steps to Reproduce the Bug or Issue
1. Use the `client` preset for codegen with `graphql`
2. Create 2 queries named the same but one with an uppercase and the other with a lowercase
3. Observe that the code generation happens normally
4. Notice the generated `graphql.ts` containing duplicated types
### Expected behavior
Either a `Not all operations have an unique name` should be thrown, or having a `myQuery` and `MyQuery` type generated (first solution seems to make more sense).
### Screenshots or Videos
_No response_
### Platform
- OS: macOS
- NodeJS: v16.14.2
- `graphql` version: 16.2.0
- `@graphql-codegen/*` version(s): 2.13.7
### Codegen Config File
```TypeScript
import { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'schema.graphql',
overwrite: true,
documents: ['src/**/*.tsx'],
ignoreNoDocuments: true,
generates: {
'./src/gql/': {
preset: 'client',
plugins: [],
},
},
};
export default config;
```
### Additional context
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.