Do not delete everything in "outputDir"
Issue Description
I'd like to generate classes inside a folder that is a Java source set. This folder contains other Java packages as subdirectories, and I want to insert the generated GraphQL classes alongside in a "generated" folder.
Currently, when I specify the parent directory as the outputDir when configuring the plugin, the entire folder is replaced by the generated folder.
Steps to Reproduce
Set an existing folder as the "outputDir" for code gen. Perform code gen. See the old contents erased.
Expected Result
When I specify an outputdir, if it exists the codegen process should be additive. The old folder contents should not be touched.
Actual Result
The folders contents are erased completed, replaced by only packages pertaining to graphql codegen.
Your Environment and Setup
- graphql-java-codegen version: X.X.X
- Build tool: E.g.: Maven/Gradle/SBT
- Mapping Config: E.g.:
<configuration>
<outputDir>${project.build.directory}/generated-sources/graphql</outputDir>
<packageName>io.github.kobylynskyi.graphql.model</packageName>
</configuration>
It's hard to tell if it's a classes of graphql. Maybe you want to say don't delete ${project.Build.Directory}/generated-sources/, and just delete ${project.Build.Directory}/generated-sources/graphql?
Yes exactly. The only files that should have a chance of being removed should be those conflicting with the package name I've configured
I've got the same issue. I'm generating classes with JOOQ from the database schema, then GraphQL Codegen is deleting them straight afterwards.
Hi - I also have the same issue which is quite an inconvenience - is there a projected date for a fix for this?
Hi - I also have the same issue which is quite an inconvenience - is there a projected date for a fix for this?
Using different directories is the most direct way.
build/generated/graphql
build/generated/test
But I don't have a good plan for the same directory at present.(:Sorry, I haven't paid attention to this issue recently
I'm generating classes with JOOQ from the database schema, then GraphQL Codegen is deleting them straight afterwards.
As pointed out by @jxnu-liguobin, you would want to put classes generated by different plugins into different directories so that they don't conflict between each other and live separately.
I know this issue is marked as resolved, but I would like to give another use case for this. In this scenario we run the GraphQL generator multiple times with different schemas and different packages. We do this because we have a root schema file defining common schemas that are being used by the sub schema files to avoid generating those multiple times and ending up with the type/cast hell basically of the same class. In this case the common schema generated classes get removed by the sub schema generated ones. Yes, it is possible to put them in different generated folders and still use them alltogether, but for this we normally have different packages. Any chance of adding an option to disable cleanup?