Open gentlementlegen opened 1 year ago
ok so after some digging in I realized this happens because the output types follow namingConvention
which can be defined by the user and default it is change-case-all#pascalCase
https://the-guild.dev/graphql/codegen/docs/config-reference/naming-convention#namingconvention
One option is during generation we normalize all names and then it will lead to error for unique names which I guess we can somehow better suggest hints to rename cause today it will just generate types with duplicates which is way more annoying to debug.
Thoughts @dotansimha @n1ru4l @B2o5T?
Also fails for enums with case sensitive keys, which can be resolved with
config:
namingConvention:
enumValues: keep
Which packages are impacted by your issue?
@graphql-codegen/client-preset
Describe the bug
When generating the
graphql.ts
from codegen usingclient-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.:
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
client
preset for codegen withgraphql
graphql.ts
containing duplicated typesExpected behavior
Either a
Not all operations have an unique name
should be thrown, or having amyQuery
andMyQuery
type generated (first solution seems to make more sense).Screenshots or Videos
No response
Platform
graphql
version: 16.2.0@graphql-codegen/*
version(s): 2.13.7Codegen Config File
Additional context
No response