This maven plugin is a port of the netflix codegen plugin for Gradle. Found here.
This project is a multi-module Maven reactor. The root pom.xml is a pom-packaging
aggregator; the published artifact lives in the graphqlcodegen-maven-plugin module. The example
project is vendored in and wired as Maven modules that build by default, so a single
./mvnw install runs the plugin's unit tests and the example tests together. Release stays
plugin-only (scoped with -pl), and Spring Boot lives only in the example modules.
. # aggregator (pom)
├── graphqlcodegen-maven-plugin/ # the published plugin
└── examples/graphqlcodegen-example/ # end-to-end harness (built by default)
├── common/ server/ client/ client-introspection/
This is the Maven plugin that users apply to their projects. It provides goals for generating Java (or Kotlin) code from GraphQL schemas, mirroring the functionality of the Netflix DGS Gradle codegen plugin. It is responsible for:
- Accepting configuration via plugin parameters.
- Resolving schema files from the local project and dependencies.
- Invoking the DGS codegen library with the correct configuration.
- Managing incremental code generation and manifest tracking.
- Holding a checked-in CodeGenConfigBuilder (graphqlcodegen-maven-plugin/src/main/java/io/github/deweyjose/graphqlcodegen) that mirrors the upstream CodeGenConfig constructor shape.
A vendored, multi-module DGS project that exercises the plugin end to end: jar-embedded schemas,
remote/introspection schemas, type mappings, and client-API generation. It builds by default
(plugin first in reactor order, so the examples use the just-built plugin) and is validated on every
push by the E2E Example GitHub Actions workflow. The client-introspection module starts its
own DGS server for live introspection, so no externally-running server is needed. Spring Boot and
the DGS framework live entirely in these modules and never enter the plugin's own build (a
maven-enforcer rule bans Spring Boot from the plugin). See Testing with the example
project.
Feel free to simply create a GitHub issue for requests to integrate with newer releases of the core DGS Codegen library.
PRs are welcome as well. The level of difficulty across DGS Codegen updates varies. Typically, new plugin options are added when the CodeGenConfig constructor in the core library changes.
When constructor parameters change upstream:
CodeGenConfigBuilder to match the latest constructor shape and ordering.graphqlcodegen-maven-plugin/src/main/java/io/github/deweyjose/graphqlcodegen/Codegen.javagraphqlcodegen-maven-plugin/src/main/java/io/github/deweyjose/graphqlcodegen/CodegenConfigProvider.javagraphqlcodegen-maven-plugin/src/main/java/io/github/deweyjose/graphqlcodegen/CodegenExecutor.javaProcess:
graphqlcodegen-maven-plugin/pom.xml and the root aggregator pom.xml, and the example's graphql-codegen-plugin.version property (keep them in sync).Codegen.java and related classes to support new options if needed../mvnw spotless:apply install locally — this builds and tests the plugin and the example modules (see below).The example project lives in examples/graphqlcodegen-example and builds by default as part of
the reactor, against the plugin you just built. A single command runs the plugin unit tests and the
example tests (including the client-introspection module, which starts its own DGS server):
./mvnw -B -ntp install
install (not verify) ensures the plugin is installed first so the examples resolve it. The
server module fetches its schema over HTTP from main by default; to build fully offline, serve
the in-repo schema and override the URL:
python3 -m http.server 8000 \
--directory examples/graphqlcodegen-example/server/src/main/resources/schema &
./mvnw -B -ntp install -Dcodegen.server.schemaUrl=http://localhost:8000/main.graphqls
The E2E Example CI workflow runs exactly this on every push (see
.github/workflows/e2e-example.yaml).
The DGS Code Generation plugin generates code for basic types and example data fetchers based on
your Domain Graph
Service's graphql schema file during the project's build process. The plugin requires the
designated packageName for file generation.
If no schemaPath is specified, it will look in the src/main/resources/schema folder for
any files with .graphqls, .graphql or .gqls extension.
https://github.com/deweyjose/graphqlcodegen-example
Options are configured in the <configuration> element of the dgs-codegen-maven-plugin plugin.
This options enables the plugin to limit code generation to only schema files that have changed. Today this only works with schemaPaths.
This only works for <schemaPaths>. A subsequent release for schema compilation via dependencies
will be release soon.
<onlyGenerateChanged>true</onlyGenerateChanged>
Example
<subPackageNameDocs>docs</subPackageNameDocs>
Example
<generateDocs>true</generateDocs>
Example
<generatedDocsFolder>true</generatedDocsFolder>
Example
<addGeneratedAnnotation>true</addGeneratedAnnotation>
Example
<dgs.codegen.skip>true</dgs.codegen.skip>
Or
# mvn ... -Ddgs.codegen.skip=true
A list of schema file or directory paths.
Directory paths: Only files with file extensions .graphql, .graphqls and .gqls will be considered.
Default value is ${project.basedir}/src/main/resources/schema.
${project.basedir}/src/main/resources/schemaExample
<schemaPaths>
<param>src/main/resources/schema/schema.graphqls1</param>
<param>src/main/resources/schema/schema.graphqls2</param>
<param>src/main/resources/someDirWithSchema</param>
</schemaPaths>
.graphql(s) files must exist under the META-INF folder in the external jar
file.Example
<schemaJarFilesFromDependencies>
<param>com.netflix.graphql.dgs:some-dependency:1.0.0</param>
<param>com.netflix.graphql.dgs:some-dependency:X.X.X</param>
</schemaJarFilesFromDependencies>
Example
<packageName>com.acme.se.generated</packageName>
Example
<typeMapping>
<Date>java.time.LocalDateTime</Date>
</typeMapping>
typeMappingPropertiesFilesSpecifies one or more typeMapping properties files that are available as compile-time classpath resources from external dependencies (e.g., shared JARs).
Each properties file must contain key-value pairs that will be added to the typeMapping map only if a mapping for a given GraphQL type is not already present.
If the same GraphQL type appears in both the typeMapping configuration and one of the typeMappingPropertiesFiles, the value from typeMapping will take precedence, and the entry from the properties file will be ignored.
<typeMappingPropertiesFiles>
<typeMappingPropertiesFile>commontypes-typeMapping.properties</typeMappingPropertiesFile>
<typeMappingPropertiesFile>someother-commontypes-typeMapping.properties</typeMappingPropertiesFile>
</typeMappingPropertiesFiles>
localTypeMappingPropertiesFilesSpecifies one or more typeMapping properties files that are available in the local project directory. These files should be specified relative to the project root.
Each properties file must contain key-value pairs that will be added to the typeMapping map only if a mapping for a given GraphQL type is not already present.
If the same GraphQL type appears in both the typeMapping configuration and one of the localTypeMappingPropertiesFiles, the value from typeMapping will take precedence, and the entry from the properties file will be ignored.
<localTypeMappingPropertiesFiles>
<localTypeMappingPropertiesFile>src/main/resources/type-mapping.properties</localTypeMappingPropertiesFile>
</localTypeMappingPropertiesFiles>
Example
<subPackageNameClient>client</subPackageNameClient>
Example
<subPackageNameDatafetchers>datafetchers</subPackageNameDatafetchers>
Example
<subPackageNameTypes>types</subPackageNameTypes>
Example
<generateBoxedTypes>false</generateBoxedTypes>
Example
<generateClientApi>false</generateClientApi>
Deprecated / no-op since graphql-dgs-codegen-core 8.4.0. Upstream removed the
generateClientApiv2option (the v2 client API path was consolidated). The parameter is still accepted so existing POMs keep parsing, but it no longer has any effect. UsegenerateClientApiinstead.
Example
<generateClientApiv2>false</generateClientApiv2>
Example
<generateInterfaces>false</generateInterfaces>
Example
<generateKotlinNullableClasses>false</generateKotlinNullableClasses>
Example
<generateKotlinClosureProjections>false</generateKotlinClosureProjections>
${project.build.directory}/generated-sourcesExample:
<outputDir>${project.build.directory}/generated-sources</outputDir>
Controls whether the plugin automatically adds the generated sources directory to the Maven compile classpath. This eliminates the need for the build-helper-maven-plugin in most setups.
Example:
<autoAddSource>true</autoAddSource>
${project.build.directory}/generated-examplesExample:
<exampleOutputDir>${project.build.directory}/generated-examples</exampleOutputDir>
${project.build.directory}/graphqlcodegenExample:
<schemaManifestOutputDir>${project.build.directory}/graphqlcodegen</schemaManifestOutputDir>
generateClient.Example
<includeQueries>
<param>QueryFieldName1</param>
<param>QueryFieldName2</param>
</includeQueries>
generateClient.Example
<includeMutations>
<param>MutationFieldName1</param>
<param>MutationFieldName1</param>
</includeMutations>
Example
<skipEntityQueries>false</skipEntityQueries>
Example
<shortProjectionNames>false</shortProjectionNames>
Example
<generateDataTypes>false</generateDataTypes>
Example
<language>kotlin</language>
graphql-dgs-codegen-core >= 8.2.1 (option removed upstream)Example
<omitNullInputFields>false</omitNullInputFields>
Example
```xml
<kotlinAllFiel
$ claude mcp add graphqlcodegen \
-- python -m otcore.mcp_server <graph>