/dgs-codegen-maven-plugin

A Maven port of Netflix's DGS codegen gradle plugin

Primary LanguageJavaApache License 2.0Apache-2.0

GitHub Workflow Status GitHub release (latest SemVer) License

A Maven port of Netflix's DGS codegen gradle plugin. The core code to generate the classes already exists as its own module, so this is plugin is just a thin wrapper around that.

Sample Usage

Add the following plugin to your Maven build:

<plugin>
    <groupId>com.github.michaelboyles</groupId>
    <artifactId>dgs-codegen-maven-plugin</artifactId>
    <version>1.1.0</version>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <packageName>com.foo.bar</packageName>
            </configuration>
        </execution>
    </executions>
</plugin>

The dependency is available from jitpack.io. You can use the following repo declaration:

<pluginRepository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</pluginRepository>

Goals

dgs-codegen-maven-plugin:generate

Generates classes for the DGS framework.

Binds by default to the lifecycle phase: generate-sources.

Required Parameters

Property Type Since Description
packageName String 1.0.0 The package name to use for generated classes

Optional Parameters

Property Type Since Description
schemaPaths File[] 1.0.0 Path to directory/directories containing GraphQL schemas. Default: ${project.build.sourceDirectory}/../resources/schema
subPackageNameClient String 1.0.0 The package under packageName to place client classes. Default: client
subPackageNameDatafetchers String 1.0.0 The package under packageName to place data fetcher classes. Default: datafetchers
subPackageNameTypes String 1.0.0 The package under packageName to place types. Default: types
language String 1.0.0 The programming language that generated classes should use. Valid values are KOTLIN and JAVA. Default is inferred from the classpath
typeMapping Map 1.0.0 A map from GraphQL type name to Java class name, e.g. for scalars
generateBoxedTypes boolean 1.0.0 Whether to use boxed types, e.g. java.lang.Integer, for non-nullable fields (nullable fields must use boxed types, so that null can represent absence of a value). Default: false
generateClient boolean 1.0.0 Whether to generate classes for a GraphQL client. Default: false
generateDataTypes boolean 1.1.0 Generate data types. Useful for only generating a Query API. Input types are still generated when generateClient is true. Default: true
generateInterfaces boolean 1.1.0 Whether to generate additional interfaces with an 'I' prefix for classes. Default: false
outputDir File 1.0.0 The directory to place generated classes. Default: ${project.build.directory}/generated-sources/annotations/
examplesOutputDir File 1.0.0 The directory to place generated examples. Default: ${project.build.directory}/generated-examples
includeQueries String[] 1.0.0 If present, only generate the queries specified in this list
includeMutations String[] 1.0.0 If present, only generate the mutations in this list
skipEntityQueries boolean 1.0.0 Whether to skip entity queries. Default: false
shortProjectionNames boolean 1.0.0 Whether to shorten projection names. See ClassnameShortener. e.g. "ThisIsATest" becomes "ThIsATe". Default: false
maxProjectionDepth int 1.1.0 Maximum projection depth to generate. Useful for (federated) schemas with very deep nesting. Default: 10