Serialized Form
-
Package com.graphql_java_generator.gradleplugin
-
Class com.graphql_java_generator.gradleplugin.GraphqlExtension extends java.lang.Object implements Serializable
- serialVersionUID:
- 1L
-
Serialized Fields
-
copyRuntimeSources
boolean copyRuntimeSources
Flag to enable copy sources for graphql-java-runtime library to target source code directory. It allows to control whether the runtime code is embedded in the generated code or not.
The default behavior is the old one, that is: the runtime code is embedded. This means that when you upgrade the plugin version, just build the project and everything is coherent.
If you set this parameter to false, the runtime is no more copied with the generated code. You then have to add the runtime dependency in the pom dependencies: it's the com.graphql-java-generator:graphql-java-runtime dependency, with the exact same version as the plugin version.
This also allows you to create your own runtime, and change the "standard" behavior. But of course, you'll have to check the compatibility with all the next versions.
-
customScalars
java.util.List<com.graphql_java_generator.plugin.CustomScalarDefinition> customScalars
This parameter contains the list of custom scalars implementations. One such implementation must be provided for each custom scalar defined in the GraphQL implemented by the project for its GraphQL schema. It's a list, where the key is the scalar name, as defined in the GraphQL schema, and the value is the full class name of the implementation of
GraphQLScalarType.This parameter is a list of customScalars. For each one, you must define the name, the javaType and exactly one of these fields: graphQLScalarTypeClass, graphQLScalarTypeStaticField or graphQLScalarTypeGetter.
Here is the detail:
- graphQLTypeName: The type name, as defined in the GraphQL schema, for instance Date
- javaType: The full class name for the java type that contains the data for this type, once in the Java code, for instance java.util.Date
- graphQLScalarTypeClass: The full class name for the
GraphQLScalarTypethat will manage this Custom Scalar. This class must be a subtype ofGraphQLScalarType. Bu the constructor ofGraphQLScalarTypehas been deprecated, so you'll find no sample for that in this project - graphQLScalarTypeStaticField: The full class name followed by the static field name that contains the
GraphQLScalarTypethat will manage this Custom Scalar. For instance, the graphql-java package provides several custom scalars like graphql.Scalars.GraphQLLong. You can also use the graphql-java-extended-scalars project, that provides other custom scalars like graphql.scalars.ExtendedScalars.NonNegativeInt. - graphQLScalarTypeGetter: The full class name followed by the static method name that returns the
GraphQLScalarTypethat will manage this Custom Scalar. For instance: org.mycompany.MyScalars.getGraphQLLong() or com.graphql_java_generator.customscalars.GraphQLScalarTypeDate. This call may contain parameters, provided that this a valid java command.
Please have a look at the allGraphQLCases (both client and server) samples for more information. The allGraphQLCases client pom is a good sample.
-
generateDeprecatedRequestResponse
boolean generateDeprecatedRequestResponse
Since 1.7.1 version
Generates a XxxxResponse class for each query/mutation/subscription, and (if separateUtilityClasses is true) Xxxx classes in the util subpackage. This allows to keep compatibility with code Developed with the 1.x versions of the plugin.
The best way to use the plugin is to directly use the Xxxx query/mutation/subscription classes, where Xxxx is the query/mutation/subscription name defined in the GraphQL schema.
Default value is true
-
generateJPAAnnotation
boolean generateJPAAnnotation
Indicates whether the plugin should generate the JPA annotations, for generated objects, when in server mode. -
logger
GradleLogger logger
-
mode
com.graphql_java_generator.plugin.PluginMode mode
The generation mode: either client or server. Choose client to generate the code which can query a graphql server or server to generate a code for the server side. -
packageName
java.lang.String packageName
The packageName in which the generated classes will be created -
project
org.gradle.api.Project project
-
scanBasePackages
java.lang.String scanBasePackages
(only for server mode) A comma separated list of package names, without double quotes, that will also be parsed by Spring, to discover Spring beans, Spring repositories and JPA entities when the server starts. You should use this parameter only for packages that are not subpackage of the package defined in the _packageName_ parameter and not subpackage of com.graphql_java_generator
This allows for instance, to set packageName to your.app.package.graphql, and to define your Spring beans, like the DataFetcherDelegates or your Spring data repositories in any other folder, by setting for instance scanBasePackages to your.app.package.impl, your.app.package.graphql, or just your.app.package
-
schemaFileFolder
java.lang.String schemaFileFolder
The folder where the graphql schema file(s) will be searched. The default schema is the main resource folder. -
schemaFilePattern
java.lang.String schemaFilePattern
The pattern to find the graphql schema file(s). The default value is "/*.graphqls" meaning that the maven plugin will search all graphqls files in the "/src/main/resources" folder (please check also the schemaFileFolder plugin parameter). -
schemaPersonalizationFile
java.lang.String schemaPersonalizationFile
schemaPersonalizationFile is the file name where the GraphQL maven plugin will find personalization that it must apply before generating the code. This applies to the server mode only. See the doc on the plugin web site for more details.
The standard file would be something like /src/main/graphql/schemaPersonalizationFile.json, which avoids to embed this compile time file within your maven artifact (as it is not in the /src/main/java nor in the /src/main/resources folders).
-
separateUtilityClasses
boolean separateUtilityClasses
Indicates whether the utility classes (that is: the classes that are not match an item in the GraphQL schema) are generated in the same package than the classes that matches the GraphQL schema.
That is: internal technical classes, java classes that contain the method to execute the queries/mutations/subscriptions, Jackson deserializer for custom scalars...
The default value is false, to maintain the previous behavior. In this case, all classes are generated in the packageName, or the default package if this parameter is not defined.
If true, the GraphQL classes are generated in the package defined in the packageName plugin parameter. And all the utility classes are generated in the util subpackage of this package.
-
sourceEncoding
java.lang.String sourceEncoding
The encoding for the generated source files -
templates
java.util.Map<java.lang.String,java.lang.String> templates
Map of the code templates to be used: this allows to override the default templates, and control exactly what code is generated by the plugin.
You can override any of the Velocity templates of the project. The list of templates is defined in the enum CodeTemplate, that you can check here.
You can find a sample in the CustomTemplates client sample.
Important notice: Please note that the default templates may change in the future. And some of these modifications would need to be reported into the custom templates. We'll try to better expose a stable public API in the future.
-
-