graphqlcodegen icon indicating copy to clipboard operation
graphqlcodegen copied to clipboard

Not able to generate builder classes in Kotlin

Open saitejdandge opened this issue 3 years ago • 2 comments

Plugin is not generating builder classes when the selected language is Kotlin, is there a way around this.

saitejdandge avatar Aug 17 '22 05:08 saitejdandge

Hi, will take a look tomorrow.

deweyjose avatar Aug 18 '22 02:08 deweyjose

Hi @saitejdandge

I did some research with version 1.22 of the plugin.

If you want to use the Builder pattern for your generated types you'll need to add the following to your plugin configuration block to trigger the DGS kotlin2 codepath: <generateKotlinNullableClasses>true</generateKotlinNullableClasses>

Client Generation It looks like the client types are generated as Java, except for Entities, even if you've selected Kotlin. You can generate Kotlin client types by setting the following in your configuration block. <generateKotlinClosureProjections>true</generateKotlinClosureProjections>.

Please keep in mind this plugin is a thin wrapper over the Netflix DGS codegen project to support the maven based community.

If you're curious this is the code that's actually generating the types: https://github.com/Netflix/dgs-codegen/blob/5c89523dd90b645746ed73ab7c873412d34624b9/graphql-dgs-codegen-core/src/main/kotlin/com/netflix/graphql/dgs/codegen/CodeGen.kt#L293

deweyjose avatar Aug 27 '22 12:08 deweyjose