dgs-codegen icon indicating copy to clipboard operation
dgs-codegen copied to clipboard

Mapping classes with conflicting naming in libraries fails

Open anderssandven opened this issue 3 years ago • 3 comments

This issue seems to have been introduced after 5.1.9 somewhere.

I have a schema which roughly looks like this:

enum Currency {
  USD, EUR
}

type Item {
   amount: Amount
   currency: Currency
}

I have type mappings like this: Currency -> generated.Currency Amount -> java.lang.Long

What happens is that I do not get the type mapping as part of the import statement in the generated class. I am generating Java. The issue seems to be that the codegen actually wants to find the type it maps to, as it works if I change the mapping to an existing class.

Is this a bug or a feature? I see no reason why I shouldnt be able to use my generated classes as part of the type mapping which exists in the first place to avoid naming clashes.

anderssandven avatar Jun 28 '22 12:06 anderssandven

Looks like a bug. You should be able to override via type mappings.

berngp avatar Jun 28 '22 18:06 berngp

You can't use type mappings with codegen generated classes. i.e Amount should work but the type mapping for Currency will not if it is generated by codegen.

srinivasankavitha avatar Jul 05 '22 16:07 srinivasankavitha

Seems like you disagree a bit here. Imo it makes a lot of sense to be able to use whatever you generate. This is an issue for all mappings using "homemade" scalars.

anderssandven avatar Jul 05 '22 18:07 anderssandven