graphql-java-codegen icon indicating copy to clipboard operation
graphql-java-codegen copied to clipboard

Support overriding freemarker templates, similar to how OpenAPI generator does.

Open nhoughto opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe. The output of templating of things like Input or Type classes is almost what I want, but more control to make it exactly right for my use case would be a good quality of life improvement for using this plugin.

Describe the solution you'd like A way to inform the generation process to use an alternate set of freemarker templates, overriding the OOTB ones, similar to https://openapi-generator.tech/docs/customization

The impact of this change on your project should be minimal, the code change very slight with no impact on the rest of the main generation path. It is essentially a simple escape-hatch to allow people to make tweaks that solve their individual need that would be very unlikely to get considered as a feature.

Because of the way templates are constructed currently, as a static map put together at class init time, likely an environment variable or JVM arg is the best way to flag/toggle this behaviour. A env var to specify a directory on disk to load template files from would work, ideally falling back to OOTB ones if not found, but I could live without that if required.

Describe alternatives you've considered Modifying the files after they are generated, but this is clumsy, imprecise and error prone. Cat is out of the bag and hard to stuff it back in, better to change the template.

nhoughto avatar Oct 21 '21 23:10 nhoughto

👍🏻 I wanted this feature a long time ago.

jxnu-liguobin avatar Oct 22 '21 06:10 jxnu-liguobin

Addressed in #1048

kobylynskyi avatar Mar 18 '23 02:03 kobylynskyi

Thanks @velo for working on this feature! Will include in the upcoming 5.7.0 release.

kobylynskyi avatar Mar 19 '23 21:03 kobylynskyi

Thanks @velo for working on this feature! Will include in the upcoming 5.7.0 release.

Awesome, thanks for that.

Any timeframes?

velo avatar Mar 19 '23 22:03 velo

Most likely Mar 20. Mar 21 the latest.

kobylynskyi avatar Mar 19 '23 22:03 kobylynskyi