Interface GenerateCodeCommonConfiguration
- All Superinterfaces:
CommonConfiguration
- All Known Subinterfaces:
GenerateClientCodeConfiguration
,GeneratePojoConfiguration
,GenerateServerCodeConfiguration
,GraphQLConfiguration
- Author:
- etienne-sf
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from interface com.graphql_java_generator.plugin.conf.CommonConfiguration
DEFAULT_ADD_RELAY_CONNECTIONS, DEFAULT_JSON_GRAPHQL_SCHEMA_FILE, DEFAULT_MAX_TOKENS, DEFAULT_PACKAGE_NAME, DEFAULT_PREFIX, DEFAULT_SCHEMA_FILE_FOLDER, DEFAULT_SCHEMA_FILE_PATTERN, DEFAULT_SCHEMA_SUB_FOLDER, DEFAULT_SKIP_GENERATION_IF_SCHEMA_HAS_NOT_CHANGED, DEFAULT_SUFFIX
-
Method Summary
Modifier and TypeMethodDescriptionThis parameter contains the list of custom scalars implementations.getMode()
The generation mode: either client or server.The packageName in which the generated classes will be createdTheQueryMutationExecutionProtocol
to use for GraphQL queries and mutations (not subscriptions).schemaPersonalizationFile is the file name where the GraphQL maven plugin will find personalization that it must apply before generating the code.The encoding for the generated source filesdefault String
Returns the package that contains the Spring Auto Configuration class.Retrieves the suffix that will be applied to the name of the Spring Beans that are generated for this schema.The folder where the generated classes will be compiled, that is: where the class file are stored after compilationThe folder where the generated resources will be generatedThe folder where the source code for the generated classes will be generatedboolean
Flag to enable (or not) the copy of the sources from the graphql-java-runtime library to target source code directory.default boolean
Indicates whether the utility classes should be generated.boolean
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.boolean
void
Logs all the configuration parameters (only when in the debug level)default void
Methods inherited from interface com.graphql_java_generator.plugin.conf.CommonConfiguration
getDefaultTargetSchemaFileName, getEnumPrefix, getEnumSuffix, getInputPrefix, getInputSuffix, getInterfacePrefix, getInterfaceSuffix, getJsonGraphqlSchemaFilename, getMaxTokens, getProjectDir, getSchemaFileFolder, getSchemaFilePattern, getTargetSchemaSubFolder, getTemplates, getTypePrefix, getTypeSuffix, getUnionPrefix, getUnionSuffix, isAddRelayConnections, isGenerateJacksonAnnotations, isSkipGenerationIfSchemaHasNotChanged, logCommonConfiguration
-
Field Details
-
DEFAULT_COPY_RUNTIME_SOURCES
- See Also:
-
DEFAULT_QUERY_MUTATION_EXECUTION_PROTOCOL
- See Also:
-
DEFAULT_SCHEMA_PERSONALIZATION_FILE
- See Also:
-
DEFAULT_SEPARATE_UTIL_CLASSES
- See Also:
-
DEFAULT_SOURCE_ENCODING
- See Also:
-
DEFAULT_SPRING_BEAN_SUFFIX
- See Also:
-
DEFAULT_TARGET_RESOURCE_FOLDER
- See Also:
-
DEFAULT_TARGET_SOURCE_FOLDER
- See Also:
-
DEFAULT_USE_JAKARTA_EE9
- See Also:
-
-
Method Details
-
getCustomScalars
List<CustomScalarDefinition> getCustomScalars()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
GraphQLScalarType
that will manage this Custom Scalar. This class must be a subtype ofGraphQLScalarType
. Bu the constructor ofGraphQLScalarType
has 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
GraphQLScalarType
that 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
GraphQLScalarType
that 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.
-
getMode
PluginMode getMode()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.
This parameter is mandatory. It forced toPluginMode.client
by the generateClientCode goal/task an toPluginMode.server
by the generateServerCode goal/task. -
getPackageName
String getPackageName()The packageName in which the generated classes will be created -
getQueryMutationExecutionProtocol
QueryMutationExecutionProtocol getQueryMutationExecutionProtocol()TheQueryMutationExecutionProtocol
to use for GraphQL queries and mutations (not subscriptions). The allowed values are: http and webSocket.
The default value is http. -
getSchemaPersonalizationFile
File getSchemaPersonalizationFile()schemaPersonalizationFile is the file name where the GraphQL maven plugin will find personalization that it must apply before generating the code. Since the 2.2 release, it is available for both client and server. Before, it applies to the server mode only.
This allows to:
- Add or modify fields
- Add interface and annotation to classes (GraphQL types, input types, interfaces, unions and enums) or fields.
See the doc on the project's wiki for more details.
-
getSourceEncoding
String getSourceEncoding()The encoding for the generated source files -
getSpringAutoConfigurationPackage
Returns the package that contains the Spring Auto Configuration class. This package may not be the package that contains the executor, nor one of its subpackages, so that the configuration class is not read as a standard Spring configuration class. -
getSpringBeanSuffix
String getSpringBeanSuffix()Retrieves the suffix that will be applied to the name of the Spring Beans that are generated for this schema. It's mandatory if you' using a Spring app and have more than one GraphQL schemas. The default value is an empty String. -
getTargetClassFolder
File getTargetClassFolder()The folder where the generated classes will be compiled, that is: where the class file are stored after compilation -
getTargetResourceFolder
File getTargetResourceFolder()The folder where the generated resources will be generated -
getTargetSourceFolder
File getTargetSourceFolder()The folder where the source code for the generated classes will be generated -
isCopyRuntimeSources
boolean isCopyRuntimeSources()Flag to enable (or not) the copy of the sources from the graphql-java-runtime library to target source code directory. That is: it allows to control whether the runtime code is embedded in the generated code or not.
Caution: the default value changed since the 2.0 version. In 1.x version, the default value is true. Since 2.0 version, the default value is false.
- If copyRuntimeSources=true: the runtime is copied along with the generated code. The project configuration
(pom.xml or build.gradle) must contain the
com.graphql-java-generator:graphql-java-dependencies
dependency, with the same version as the GraphQL plugin - If copyRuntimeSources=false: the runtime is NOT copied along with the generated code. The project
configuration (pom.xml or build.gradle) must contain the
com.graphql-java-generator:graphql-java-runtime
dependency, with the same version as the GraphQL plugin
- Returns:
- If copyRuntimeSources=true: the runtime is copied along with the generated code. The project configuration
(pom.xml or build.gradle) must contain the
-
isGenerateUtilityClasses
default boolean isGenerateUtilityClasses()Indicates whether the utility classes should be generated. If false, only the POJO are generated, that is: only the Java classes and interfaces that match the GraphQL provided schema. There is no runtime sources for this goal.- Returns:
- true if all classes should be generated, false if only the POJO classes should be generated
-
isSeparateUtilityClasses
boolean isSeparateUtilityClasses()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.
The classes that map the GraphQL schema (type, input type, interfaces, unions...) are generated in the package defined in the packageName plugin parameter, then:
- If false (default for versions 1.x), the utility classes are generated in the the same package
- If true (default for version 2.0 and after), the utility classes are generated in the util subpackage of this package
- Returns:
-
isUseJakartaEE9
boolean isUseJakartaEE9() -
logConfiguration
void logConfiguration()Logs all the configuration parameters (only when in the debug level)- Specified by:
logConfiguration
in interfaceCommonConfiguration
-
logGenerateCodeCommonConfiguration
default void logGenerateCodeCommonConfiguration()
-