Class GeneratePojoTask
- All Implemented Interfaces:
com.graphql_java_generator.plugin.conf.CommonConfiguration,com.graphql_java_generator.plugin.conf.GenerateClientCodeConfiguration,com.graphql_java_generator.plugin.conf.GenerateCodeCommonConfiguration,com.graphql_java_generator.plugin.conf.GeneratePojoConfiguration,com.graphql_java_generator.plugin.conf.GenerateServerCodeConfiguration,com.graphql_java_generator.plugin.conf.GraphQLConfiguration,java.lang.Comparable<org.gradle.api.Task>,org.gradle.api.internal.DynamicObjectAware,org.gradle.api.internal.TaskInternal,org.gradle.api.plugins.ExtensionAware,org.gradle.api.Task,org.gradle.util.Configurable<org.gradle.api.Task>
public class GeneratePojoTask extends GraphQLGenerateCodeTask implements com.graphql_java_generator.plugin.conf.GeneratePojoConfiguration
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. In this mode, as with the generateServerCode, you need to either add the graphql-java-server-dependencies dependencies, or set the copyRuntimeSources plugin parameter to false and add the graphql-java-runtime.
- 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. In this mode, as with the generateServerCode, you need to either add the graphql-java-client-dependencies dependencies, or set the copyRuntimeSources plugin parameter to false and add the graphql-java-runtime.
Note: The attribute have no default values: their default values is read from the
GenerateCodeCommonExtension, whose attributes can be either the default value, or a value set in the build
script.
Note: in this mode, copyRuntimeSources must be set to false. Some dependencies must be copied for the code to compile (exceptions, annotations...)
*-
Nested Class Summary
-
Field Summary
Fields inherited from class com.graphql_java_generator.gradleplugin.GenerateServerCodeTask
javaTypeForIDTypeFields inherited from class com.graphql_java_generator.gradleplugin.GenerateCodeCommonTask
targetResourceFolder, targetSourceFolderFields inherited from class com.graphql_java_generator.gradleplugin.CommonTask
extension, extensionClass, skipGenerationIfSchemaHasNotChangedFields inherited from interface com.graphql_java_generator.plugin.conf.CommonConfiguration
DEFAULT_ADD_RELAY_CONNECTIONS, DEFAULT_MAX_TOKENS, DEFAULT_PACKAGE_NAME, DEFAULT_SCHEMA_FILE_FOLDER, DEFAULT_SCHEMA_FILE_PATTERN, DEFAULT_SKIP_GENERATION_IF_SCHEMA_HAS_NOT_CHANGEDFields 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_SEPARATE_UTIL_CLASSES, DEFAULT_SOURCE_ENCODING, DEFAULT_SPRING_BEAN_SUFFIX, DEFAULT_TARGET_RESOURCE_FOLDER, DEFAULT_TARGET_SOURCE_FOLDERFields 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_JPA_ANNOTATION, DEFAULT_JAVA_TYPE_FOR_ID_TYPE, DEFAULT_SCAN_BASE_PACKAGES, DEFAULT_SCHEMA_PERSONALIZATION_FILE -
Constructor Summary
Constructors Constructor Description GeneratePojoTask() -
Method Summary
Modifier and Type Method Description voidexecute()protected GeneratePojoExtensiongetExtension()booleanisGenerateJacksonAnnotations()booleanisGenerateUtilityClasses()booleanisSeparateUtilityClasses()There is no utility classes for this goal.voidsetGenerateJacksonAnnotations(boolean generateJacksonAnnotations)Methods inherited from class com.graphql_java_generator.gradleplugin.GraphQLGenerateCodeTask
getMode, isGenerateDeprecatedRequestResponse, setGenerateDeprecatedRequestResponse, setModeMethods inherited from class com.graphql_java_generator.gradleplugin.GenerateServerCodeTask
getJavaTypeForIDType, getPackaging, getQuotedScanBasePackages, getScanBasePackages, getSchemaPersonalizationFile, isGenerateBatchLoaderEnvironment, isGenerateJPAAnnotation, setGenerateBatchLoaderEnvironment, setGenerateJPAAnnotation, setJavaTypeForIDType, setScanBasePackages, setSchemaPersonalizationFileMethods inherited from class com.graphql_java_generator.gradleplugin.GenerateCodeCommonTask
getCustomScalars, getPackageName, getSourceEncoding, getSpringAutoConfigurationPackage, getSpringBeanSuffix, getTargetClassFolder, getTargetResourceFolder, getTargetSourceFolder, isCopyRuntimeSources, registerGeneratedFolders, setCopyRuntimeSources, setCustomScalars, setPackageName, setSeparateUtilityClasses, setSourceEncoding, setSpringBeanSuffix, setTargetResourceFolder, setTargetSourceFolderMethods inherited from class com.graphql_java_generator.gradleplugin.CommonTask
configure, getDefaultTargetSchemaFileName, getFileValue, getMaxTokens, getProjectDir, getSchemaFileFolder, getSchemaFilePattern, getTemplates, getValue, isAddRelayConnections, isSkipGenerationIfSchemaHasNotChanged, logConfiguration, setAddRelayConnections, setParserOptions, setSchemaFileFolder, setSchemaFilePattern, setSkipGenerationIfSchemaHasNotChanged, setTemplatesMethods inherited from class org.gradle.api.internal.AbstractTask
appendParallelSafeAction, compareTo, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getAsDynamicObject, getConvention, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getIdentityPath, getImpliesSubProjects, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOnlyIf, getOutputs, getPath, getProject, getRequiredServices, getServices, getSharedResources, getShouldRunAfter, getStandardOutputCapture, getState, getTaskActions, getTaskDependencies, getTaskIdentity, getTemporaryDir, getTemporaryDirFactory, getTimeout, hasProperty, hasTaskActions, injectIntoNewInstance, isEnabled, isHasCustomActions, mustRunAfter, onlyIf, onlyIf, prependParallelSafeAction, property, replaceLogger, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setImpliesSubProjects, setMustRunAfter, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, toString, usesServiceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.graphql_java_generator.plugin.conf.CommonConfiguration
getDefaultTargetSchemaFileName, getMaxTokens, getProjectDir, getSchemaFileFolder, getSchemaFilePattern, getTemplates, 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, getSourceEncoding, getSpringAutoConfigurationPackage, getSpringBeanSuffix, getTargetClassFolder, getTargetResourceFolder, getTargetSourceFolder, isCopyRuntimeSources, logGenerateCodeCommonConfigurationMethods inherited from interface com.graphql_java_generator.plugin.conf.GeneratePojoConfiguration
getModeMethods inherited from interface com.graphql_java_generator.plugin.conf.GenerateServerCodeConfiguration
getJavaTypeForIDType, getPackaging, getQuotedScanBasePackages, getScanBasePackages, getSchemaPersonalizationFile, isGenerateBatchLoaderEnvironment, isGenerateJPAAnnotation, logConfiguration, logGenerateServerCodeConfiguration
-
Constructor Details
-
GeneratePojoTask
public GeneratePojoTask()
-
-
Method Details
-
execute
public void execute()- Overrides:
executein classGraphQLGenerateCodeTask
-
getExtension
- Overrides:
getExtensionin classGraphQLGenerateCodeTask
-
isGenerateJacksonAnnotations
@Input public boolean isGenerateJacksonAnnotations()- Specified by:
isGenerateJacksonAnnotationsin interfacecom.graphql_java_generator.plugin.conf.CommonConfiguration- Specified by:
isGenerateJacksonAnnotationsin interfacecom.graphql_java_generator.plugin.conf.GenerateClientCodeConfiguration- Specified by:
isGenerateJacksonAnnotationsin interfacecom.graphql_java_generator.plugin.conf.GeneratePojoConfiguration- Specified by:
isGenerateJacksonAnnotationsin interfacecom.graphql_java_generator.plugin.conf.GenerateServerCodeConfiguration- Specified by:
isGenerateJacksonAnnotationsin interfacecom.graphql_java_generator.plugin.conf.GraphQLConfiguration- Overrides:
isGenerateJacksonAnnotationsin classGraphQLGenerateCodeTask
-
setGenerateJacksonAnnotations
public void setGenerateJacksonAnnotations(boolean generateJacksonAnnotations) -
isGenerateUtilityClasses
public boolean isGenerateUtilityClasses()- Specified by:
isGenerateUtilityClassesin interfacecom.graphql_java_generator.plugin.conf.GenerateCodeCommonConfiguration- Specified by:
isGenerateUtilityClassesin interfacecom.graphql_java_generator.plugin.conf.GeneratePojoConfiguration- Overrides:
isGenerateUtilityClassesin classGenerateCodeCommonTask
-
isSeparateUtilityClasses
public boolean isSeparateUtilityClasses()There is no utility classes for this goal.- Specified by:
isSeparateUtilityClassesin interfacecom.graphql_java_generator.plugin.conf.GenerateCodeCommonConfiguration- Specified by:
isSeparateUtilityClassesin interfacecom.graphql_java_generator.plugin.conf.GeneratePojoConfiguration- Overrides:
isSeparateUtilityClassesin classGenerateCodeCommonTask- Returns:
- The
GeneratePojoConfigurationimplementation of this method always returns false
-