Class GeneratePojoMojo
- All Implemented Interfaces:
CommonConfiguration,GenerateClientCodeConfiguration,GenerateCodeCommonConfiguration,GeneratePojoConfiguration,GenerateServerCodeConfiguration,GraphQLConfiguration,org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
The generatePojo goal generates all the java objects that match the provided GraphQL schema. It allows to work in Java with graphQL, in a schema first approach.
This goal generates:- One java interface for each GraphQL `union` and `interface`
- One java class for each GraphQL `type` and `input` type, including the query, mutation and subscription (if any). If the GraphQL type implements an interface, then its java class implements this same interface
- One java enum for each GraphQL enum
Every class, interface and their attributes are marked with the annotation from the GraphQL annotation package. This allows to retrieve the GraphQL information for every class, interface and attribute, at runtime.
It can run in two modes (see the mode plugin parameter for more information):
- server: In the server mode, only the GraphQL annotation are added. You can add the JPA annotation, with the generateJPAAnnotation plugin parameter set to true.
- client: The client mode is the default one. This mode generates the same POJO as in server mode, with the addition of the Jackson annotations. These annotations allows to serialize and unserialize the GraphQL POJO to and from JSON. And the CustomJacksonDeserializers utility class is generated, that allows to deserialize custom scalars and arrays.
To avoid to add plugin dependencies, the recommended value for copyRuntimeSources is true. Please note that the default value changed from true to false since 2.0.
In other word, since 2.0, it is a recommended to set the copyRuntimeSources plugin parameter to true.
- Author:
- etienne-sf
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class com.graphql_java_generator.mavenplugin.AbstractGeneratePojoMojo
generateJacksonAnnotationsFields inherited from class com.graphql_java_generator.mavenplugin.AbstractGenerateServerCodeMojo
generateBatchLoaderEnvironment, javaTypeForIDTypeFields inherited from class com.graphql_java_generator.mavenplugin.AbstractCommonMojo
buildContext, ctx, enumPrefix, enumSuffix, inputPrefix, inputSuffix, interfacePrefix, interfaceSuffix, maxTokens, projectHelper, springConfigurationClass, typePrefix, typeSuffix, unionPrefix, unionSuffixFields inherited from interface com.graphql_java_generator.plugin.conf.CommonConfiguration
DEFAULT_ADD_RELAY_CONNECTIONS, 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_SUFFIXFields inherited from interface com.graphql_java_generator.plugin.conf.GenerateClientCodeConfiguration
DEFAULT_GENERATE_DEPRECATED_REQUEST_RESPONSEFields inherited from interface com.graphql_java_generator.plugin.conf.GenerateCodeCommonConfiguration
DEFAULT_COPY_RUNTIME_SOURCES, DEFAULT_QUERY_MUTATION_EXECUTION_PROTOCOL, DEFAULT_SEPARATE_UTIL_CLASSES, DEFAULT_SOURCE_ENCODING, DEFAULT_SPRING_BEAN_SUFFIX, DEFAULT_TARGET_RESOURCE_FOLDER, DEFAULT_TARGET_SOURCE_FOLDER, DEFAULT_USE_JAKARTA_EE9Fields inherited from interface com.graphql_java_generator.plugin.conf.GeneratePojoConfiguration
DEFAULT_GENERATE_JACKSON_ANNOTATIONSFields inherited from interface com.graphql_java_generator.plugin.conf.GenerateServerCodeConfiguration
DEFAULT_GENERATE_BATCH_LOADER_ENVIRONMENT, DEFAULT_GENERATE_DATA_LOADER_FOR_LISTS, DEFAULT_GENERATE_JPA_ANNOTATION, DEFAULT_JAVA_TYPE_FOR_ID_TYPE, DEFAULT_SCAN_BASE_PACKAGES, DEFAULT_SCHEMA_PERSONALIZATION_FILEFields inherited from interface com.graphql_java_generator.plugin.conf.GraphQLConfiguration
DEFAULT_MODEFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class com.graphql_java_generator.mavenplugin.AbstractGeneratePojoMojo
isGenerateJacksonAnnotationsMethods inherited from class com.graphql_java_generator.mavenplugin.AbstractGraphQLMojo
getMode, isGenerateDeprecatedRequestResponseMethods inherited from class com.graphql_java_generator.mavenplugin.AbstractGenerateServerCodeMojo
getJavaTypeForIDType, getPackaging, getScanBasePackages, getSchemaPersonalizationFile, isGenerateBatchLoaderEnvironment, isGenerateDataLoaderForLists, isGenerateJPAAnnotationMethods inherited from class com.graphql_java_generator.mavenplugin.AbstractGenerateCodeCommonMojo
executePostExecutionTask, getCustomScalars, getPackageName, getQueryMutationExecutionProtocol, getSourceEncoding, getSpringBeanSuffix, getTargetClassFolder, getTargetFolder, getTargetResourceFolder, getTargetSourceFolder, isAddRelayConnections, isCopyRuntimeSources, isSeparateUtilityClasses, isUseJakartaEE9Methods inherited from class com.graphql_java_generator.mavenplugin.AbstractCommonMojo
execute, getEnumPrefix, getEnumSuffix, getInputPrefix, getInputSuffix, getInterfacePrefix, getInterfaceSuffix, getMaxTokens, getProjectDir, getSchemaFileFolder, getSchemaFilePattern, getTemplates, getTypePrefix, getTypeSuffix, getUnionPrefix, getUnionSuffix, isSkipGenerationIfSchemaHasNotChangedMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.graphql_java_generator.plugin.conf.CommonConfiguration
getDefaultTargetSchemaFileName, getEnumPrefix, getEnumSuffix, getInputPrefix, getInputSuffix, getInterfacePrefix, getInterfaceSuffix, getMaxTokens, getProjectDir, getSchemaFileFolder, getSchemaFilePattern, getTargetSchemaSubFolder, getTemplates, getTypePrefix, getTypeSuffix, getUnionPrefix, getUnionSuffix, isAddRelayConnections, isSkipGenerationIfSchemaHasNotChanged, logCommonConfigurationMethods inherited from interface com.graphql_java_generator.plugin.conf.GenerateClientCodeConfiguration
isGenerateDeprecatedRequestResponseMethods inherited from interface com.graphql_java_generator.plugin.conf.GenerateCodeCommonConfiguration
getCustomScalars, getPackageName, getQueryMutationExecutionProtocol, getSourceEncoding, getSpringAutoConfigurationPackage, getSpringBeanSuffix, getTargetClassFolder, getTargetResourceFolder, getTargetSourceFolder, isCopyRuntimeSources, isUseJakartaEE9, logGenerateCodeCommonConfigurationMethods inherited from interface com.graphql_java_generator.plugin.conf.GeneratePojoConfiguration
getMode, isGenerateUtilityClasses, isSeparateUtilityClassesMethods inherited from interface com.graphql_java_generator.plugin.conf.GenerateServerCodeConfiguration
getJavaTypeForIDType, getPackaging, getQuotedScanBasePackages, getScanBasePackages, getSchemaPersonalizationFile, isGenerateBatchLoaderEnvironment, isGenerateDataLoaderForLists, isGenerateJPAAnnotation, logConfiguration, logGenerateServerCodeConfigurationMethods inherited from interface com.graphql_java_generator.plugin.conf.GraphQLConfiguration
logConfiguration
-
Constructor Details
-
GeneratePojoMojo
public GeneratePojoMojo()
-