apollo-kotlin icon indicating copy to clipboard operation
apollo-kotlin copied to clipboard

Name clash / redeclaration using data builders

Open sampengilly opened this issue 1 year ago • 6 comments

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

sampengilly avatar Jan 16 '24 00:01 sampengilly

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.~~

BoD avatar Jan 16 '24 10:01 BoD

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")

BoD avatar Jan 16 '24 10:01 BoD

Ah, that might help as a workaround in the meantime. Thanks for the heads up

sampengilly avatar Jan 16 '24 11:01 sampengilly