apollo-kotlin
apollo-kotlin copied to clipboard
Name clash / redeclaration using data builders
Version
3.8.2
Summary
In my GraphQL schema I have two existing types named like: "SomeType" and "SomeTypeMap". When enabling data builders, Apollo Kotlin generates a class for my "SomeTypeMap" but it also generates its own "SomeTypeMap" interface associated with "SomeType" as part of the data builder codegen.
This creates a redeclaration error in the kotlin compiler.
Steps to reproduce the behavior
No response
Logs
No response
Thanks for reporting this. That's unfortunate! Maybe the generated map could have a name with a __ prefix to avoid clashes.
~~It's not ideal, but what you could do for now is rename SomeTypeMap in your schema to something else.~~
Actually you can also use the @targetName directive so the generated class for your type gets a name that doesn't clash. In an extra.graphqls file next to your shema, something like:
extend type SomeTypeMap @targetName(name: "SomeTypeMap2")
Ah, that might help as a workaround in the meantime. Thanks for the heads up