This is port of the netflix codegen plugin for Gradle. Found here.
COPIED FROM NETFLIX DOCUMENTATION.
The DGS Code Generation plugin generates code for basic types and example data fetchers based on the your Domain Graph Service's graphql schema file during the project's build process. The plugin requires the path to schema files and the package name to use to generate the file. If no schema path is specified, it will look under src/resources/schema for any files with .graphqls extension. plugin generates code for basic types and example data fetchers based on the your Domain Graph Service's graphql schema file during the project's build process. The plugin requires the path to schema files and the package name to use to generate the file. If no schema path is specified, it will look under src/resources/schema for any files with .graphqls extension.
Options are configured in the <configuration>
element of the dgs-codegen-maven-plugin plugin.
- Type: array
- Required: false
- Default:
${project.build.resources}/schema
Example
<schemaPaths>
<param>src/main/resources/schema/schema.graphqls1</param>
<param>src/main/resources/schema/schema.graphqls2</param>
</schemaPaths>
- Type: string
- Required: true
Example
<packageName>com.acme.se.generated</packageName>
- Type: map
- Required: false
Example
<typeMapping>
<Date>java.time.LocalDateTime</Date>
</typeMapping>
- Type: string
- Required: false
- Default: client
Example
<subPackageNameClient>client</subPackageNameClient>
- Type: string
- Required: false
- Default: client
Example
<subPackageNameDatafetchers>datafetchers</subPackageNameDatafetchers>
- Type: string
- Required: false
- Default: client
Example
<subPackageNameTypes>types</subPackageNameTypes>
- Type: boolean
- Required: false
- Default: false
Example
<generateBoxedTypes>false</generateBoxedTypes>
- Type: boolean
- Required: false
- Default: false
Example
<generateClient>false</generateClient>
- Type: boolean
- Required: false
- Default: false
Example
<generateInterfaces>false</generateInterfaces>
- Type: string
- Required: false
- Default:
${project.basedir}/target/generated-sources
Example:
<outputDir>${project.build.directory}/generated-sources</outputDir>
- Type: string
- Required: false
- Default:
${project.basedir}/target/generated-examples
Example:
<outputDir>${project.build.directory}/generated-examples</outputDir>
- Description: Limit generation to specified set of queries. Used in conjunction with
generateClient
. - Type: array
- Required: false
- Default: []
Example
<includeQueries>
<param>QueryFieldName1</param>
<param>QueryFieldName2</param>
</includeQueries>
- Description: Limit generation to specified set of mutations. Used in conjunction with
generateClient
. - Type: array
- Required: false
- Default: []
Example
<includeMutations>
<param>MutationFieldName1</param>
<param>MutationFieldName1</param>
</includeMutations>
- Type: boolean
- Required: false
- Default: false
Example
<skipEntityQueries>false</skipEntityQueries>
- Type: boolean
- Required: false
- Default: false
Example
<shortProjectionNames>false</shortProjectionNames>
- Type: boolean
- Required: false
- Default: false
Example
<generateDataTypes>false</generateDataTypes>
- Type: int
- Required: false
- Default: 10
Example
<maxProjectionDepth>10</maxProjectionDepth>
- Type: String
- Required: false
- Default: java
Example
<language>kotlin</language>
- Type: boolean
- Required: false
- Default: false
Example
<omitNullInputFields>false</omitNullInputFields>
- Type: boolean
- Required: false
- Default: false
Example
<kotlinAllFieldsOptional>false</kotlinAllFieldsOptional>
- Type: boolean
- Required: false
- Default: false
Example
<snakeCaseConstantNames>false</snakeCaseConstantNames>
Add the following to your pom files build/plugins section.
<plugin>
<groupId>io.github.deweyjose</groupId>
<artifactId>graphqlcodegen-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaPaths>
<param>src/main/resources/schema/schema.graphqls</param>
</schemaPaths>
<packageName>com.acme.[your_project].generated</packageName>
</configuration>
</plugin>
You'll also need to add the generates-sources folder to the classpath:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
COPIED FROM NETFLIX DOCUMENTATION.
The generated types are available as part of the packageName.types package under build/generated. These are automatically added to your project's sources. The generated example data fetchers are available under build/generated-examples. Note that these are NOT added to your project's sources and serve mainly as a basic boilerplate code requiring further customization.