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

Adding custom suffix to generated types

Open maory opened this issue 3 years ago • 5 comments

With DGS codegen, I want the schema types to correspond my Model entity types.

For example let's assume that I have a query in my schema:

type Dog {
name: String!
}

My generated type will be <generated_types_package>.Dog.java In most cases, I will have another class for my model object. <model_type_package>.Dog.java

What happens in this case that in my DataFetcher I need to declare explicitly on the type package prefix, which makes the code pretty hard to read.

My suggestion is to add a custom suffix to any schema generated type (not input) <model_type_package>.Dog.java --> <model_type_package>.DogGQL.java

maory avatar Jun 07 '22 14:06 maory

I can see that being hard to use. We can looking into improving that in the future. Feel free to open a PR if you would like to have that available sooner.

srinivasankavitha avatar Jun 07 '22 16:06 srinivasankavitha

@srinivasankavitha Thank you for your response. I will check out that, Since I am using maven I will need another PR for the maven plugin to support such kind of config.

maory avatar Jun 07 '22 19:06 maory

+1, I'm going to name my entities <Name>Entity but would still like this to avoid potential conflicts and to match that kind of class naming convention

xenoterracide avatar Aug 24 '22 18:08 xenoterracide

Ah ok, we don't maintain or own the maven plugin. That is more community maintained.

On Tue, Jun 7, 2022 at 12:59 PM maory @.***> wrote:

@srinivasankavitha https://github.com/srinivasankavitha Thank you for your response. I will check out that, Since I am using maven I will need another PR for the maven plugin to support such kind of config.

— Reply to this email directly, view it on GitHub https://github.com/Netflix/dgs-codegen/issues/389#issuecomment-1149106144, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJ5JPXLCKNBEH6FXTUTKFSLVN6SZZANCNFSM5YDGP4WA . You are receiving this because you were mentioned.Message ID: @.***>

srinivasankavitha avatar Oct 11 '22 08:10 srinivasankavitha

I'm using gradle, just FYI

xenoterracide avatar Oct 11 '22 13:10 xenoterracide