Netflix / dgs-codegen

Apache License 2.0
183 stars 99 forks source link

Generate interfaces for schema types defined in schema in kotlin projects #653

Open mr-nothing opened 9 months ago

mr-nothing commented 9 months ago

When I'm trying to generateInterfaces for kotlin language with use of generateJava task, they are not generated.

I saw ticket here that touch on this topic and it was stated that it is probably a feature of not a first priority.

I could probably add some context to highlight that this is pretty vital thing to have in kotlin based projects.

Let's take a look at the following setup:

type Team {
    id: Int
    parentTeam: Team!
    childTeams: [Team!]!
}

Now I'm trying to organize my dataloaders and data fetchers as optimal as possible. In kotlin projects I have the following options and none of them looks optimal to me:

Could you please share if there any plans to make generateInterfaces available for kotlin?

Thank you very much!

congotej commented 9 months ago

Hi @mr-nothing! Thanks for providing context on this, and we definitely understand that this would be valuable for Kotlin. We will add this to our backlog for future enhancements. However, due to other priorities, we most likely will not be able to get to it immediately. If this is a time-sensitive requirement for your project, we always welcome contributions from our community.

bjoernmayer commented 2 months ago

If we would have interfaces for data classes, weren't we then able to automatically extend them when the extend keyword is used?

Example:

In my core library I have a type Acommodation with one field id. In one of my subgraphs I use extend Accommodation to add a field name: String.

On Kotlin side there could be then an Interface for both Accommodation types. The one in the subgraph can then extend the one from the core library (or whereever the type was initally declared)

mr-nothing commented 2 months ago

Hey, @bjoernmayer! Yeah, this is kind of a problem, but that Accomodation interface could have as-is name, Accomodatiton but that helper Accomodation interface could have a name with some suffix attached Helper, Interface, Util, Base, etc. I think there will be more corner cases to take into accountt but this can be easily solved like this imo