Netflix / Netflix/dgs-codegen

Mapping classes with conflicting naming in libraries fails

Open
#409 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
217
Forks
116
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the schema and mappings with Java generation, especially Currency -> generated.Currency and Amount -> java.lang.Long. Trace the type-mapping and import-resolution path in the code generator; done means the generated Item includes the mapping for generated.Currency without requiring that class to already exist.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.