Class GenerateServerCodeMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
com.graphql_java_generator.mavenplugin.AbstractCommonMojo
com.graphql_java_generator.mavenplugin.AbstractGenerateCodeCommonMojo
com.graphql_java_generator.mavenplugin.AbstractGenerateServerCodeMojo
com.graphql_java_generator.mavenplugin.GenerateServerCodeMojo
- All Implemented Interfaces:
CommonConfiguration
,GenerateCodeCommonConfiguration
,GenerateServerCodeConfiguration
,org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@Mojo(name="generateServerCode",
defaultPhase=GENERATE_SOURCES,
requiresProject=true,
threadSafe=true)
@ThreadSafe
public class GenerateServerCodeMojo
extends AbstractGenerateServerCodeMojo
The generateServerCode Maven goal (and Gradle task) generates the java code for an almost ready to start GraphQL server. The developer has only to develop request to the data.
The java code is generated from one or more GraphQL schemas. It allows to work in Java with graphQL, in a schema first approach. These items are generated:
- the main method (in a jar project) or the main servlet (in a war project)
- All the GraphQL wiring, based on graphql-java-spring, itself being build on top of graphql-java
- All the POJOs, that contain the incoming request contents. The request response is written by the user code into these POJO, and the plugin take care of mapping them into the server response.
- An option allows to annotate the POJOs with the standard JPA annotations, to make it easy to link with a database. Please note that a
- All the interfaces for the
DataFetchersDelegate
(named providers in the graphql.org presentation) that the server needs to implement
The specific code that needs to be implemented is the access to the Data: your database, other APIs or web services,
or any kind of storage you may have. This is done by implementing the interfaces for the DataFetchersDelegate
into a Spring component, that is:
- Create a class for each generated
DataFetchersDelegate
interface - Make it implement the relevant
DataFetchersDelegate
interface - Mark it with the
Component
annotation
And you're done! :)
You'll find more info in the tutorials: take a look at the Maven server tutorial or the Gradle server tutorial
- Author:
- etienne-sf
-
Nested Class Summary
-
Field Summary
Fields inherited from class com.graphql_java_generator.mavenplugin.AbstractGenerateServerCodeMojo
batchMappingDataFetcherReturnType, generateBatchLoaderEnvironment, generateBatchMappingDataFetchers, generateDataFetcherForEveryFieldsWithArguments, ignoredSpringMappings, javaTypeForIDType
Fields inherited from class com.graphql_java_generator.mavenplugin.AbstractCommonMojo
buildContext, ctx, enumPrefix, enumSuffix, inputPrefix, inputSuffix, interfacePrefix, interfaceSuffix, jsonGraphqlSchemaFilename, maxTokens, projectHelper, springConfigurationClass, typePrefix, typeSuffix, unionPrefix, unionSuffix
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
Fields inherited from interface com.graphql_java_generator.plugin.conf.GenerateCodeCommonConfiguration
DEFAULT_COPY_RUNTIME_SOURCES, DEFAULT_QUERY_MUTATION_EXECUTION_PROTOCOL, DEFAULT_SCHEMA_PERSONALIZATION_FILE, DEFAULT_SEPARATE_UTIL_CLASSES, DEFAULT_SOURCE_ENCODING, DEFAULT_SPRING_BEAN_SUFFIX, DEFAULT_TARGET_RESOURCE_FOLDER, DEFAULT_TARGET_SOURCE_FOLDER, DEFAULT_USE_JAKARTA_EE9
Fields inherited from interface com.graphql_java_generator.plugin.conf.GenerateServerCodeConfiguration
DEFAULT_BATCH_MAPPING_DATA_FETCHER_RETURN_TYPE, DEFAULT_BATCH_MAPPING_DATA_FETCHER_RETURN_TYPE_STR, DEFAULT_GENERATE_BATCH_LOADER_ENVIRONMENT, DEFAULT_GENERATE_BATCH_MAPPING_DATA_FETCHERS, DEFAULT_GENERATE_DATA_FETCHER_FOR_EVERY_FIELD_WITH_ARGUMENT, DEFAULT_GENERATE_DATA_LOADER_FOR_LISTS, DEFAULT_GENERATE_JPA_ANNOTATION, DEFAULT_IGNORED_SPRING_MAPPINGS, DEFAULT_JAVA_TYPE_FOR_ID_TYPE, DEFAULT_SCAN_BASE_PACKAGES
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
-
Method Summary
Methods inherited from class com.graphql_java_generator.mavenplugin.AbstractGenerateServerCodeMojo
getBatchMappingDataFetcherReturnType, getIgnoredSpringMappings, getJavaTypeForIDType, getMode, getPackaging, getScanBasePackages, isGenerateBatchLoaderEnvironment, isGenerateBatchMappingDataFetchers, isGenerateDataFetcherForEveryFieldsWithArguments, isGenerateDataLoaderForLists, isGenerateJPAAnnotation
Methods inherited from class com.graphql_java_generator.mavenplugin.AbstractGenerateCodeCommonMojo
executePostExecutionTask, getCustomScalars, getPackageName, getQueryMutationExecutionProtocol, getSchemaPersonalizationFile, getSourceEncoding, getSpringBeanSuffix, getTargetClassFolder, getTargetFolder, getTargetResourceFolder, getTargetSourceFolder, isAddRelayConnections, isCopyRuntimeSources, isSeparateUtilityClasses, isUseJakartaEE9
Methods inherited from class com.graphql_java_generator.mavenplugin.AbstractCommonMojo
execute, getEnumPrefix, getEnumSuffix, getInputPrefix, getInputSuffix, getInterfacePrefix, getInterfaceSuffix, getJsonGraphqlSchemaFilename, getMaxTokens, getProjectDir, getSchemaFileFolder, getSchemaFilePattern, getTemplates, getTypePrefix, getTypeSuffix, getUnionPrefix, getUnionSuffix, isSkipGenerationIfSchemaHasNotChanged
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
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, isSkipGenerationIfSchemaHasNotChanged, logCommonConfiguration
Methods inherited from interface com.graphql_java_generator.plugin.conf.GenerateCodeCommonConfiguration
getCustomScalars, getPackageName, getQueryMutationExecutionProtocol, getSchemaPersonalizationFile, getSourceEncoding, getSpringAutoConfigurationPackage, getSpringBeanSuffix, getTargetClassFolder, getTargetResourceFolder, getTargetSourceFolder, isCopyRuntimeSources, isGenerateUtilityClasses, isSeparateUtilityClasses, isUseJakartaEE9, logGenerateCodeCommonConfiguration
Methods inherited from interface com.graphql_java_generator.plugin.conf.GenerateServerCodeConfiguration
getQuotedScanBasePackages, isGenerateJacksonAnnotations, logConfiguration, logGenerateServerCodeConfiguration
-
Constructor Details
-
GenerateServerCodeMojo
protected GenerateServerCodeMojo()
-