Runtime Classes


As the result of the execution of graphql-maven-plugin:generateClientCode maven goal or gradle task, two type of source code is generated

  • The Query, Mutation and POJOs classes
  • All the necessary runtime classes that do not depend on the schema and support the client execution

The runtime classes are copied as source code so, your project, when it runs, doesn't depend on any external dependency from graphql-java-generator.

How to use the configure source code generation to no include runtime classes?

To avoid the generation of runtime classes you can use the parameter copyRuntimeSources (-Dcom.graphql_java_generator.mavenplugin.copyRuntimeSources) If copyRuntimeSources is "false", then the runtime classes won't be generated. By default, the parameter value is "true".

The main purpose for adding this feature to the plugin is double:

  • Do not generate/keep non-model dependent code if it's already in a dependency. If for some reason an upgrade or patch of the runtime classes is released, the code does not need to be regenerated and just the graphql-java-runtime dependency version must be updated.
  • On the other hand, in some cases, you may want to customize the runtime classes with customized behavior. I know that this may sound a bit strange but I found myself in this situation.

Here there's an example of plugin configuration to not generate runtime classes

<project ...>


Remember that if you decide not to generate runtime classes, com.graphql-java-generator:graphql-java-runtime:1.12.3, or an equivalent dependency of you own must be somehow included in your classpath. You can use com.graphql-java-generator:graphql-java-runtime:1.12.3 artifact as a dependency in your project to include graphql-java-runtime in your classpath

<project ...>