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, Comparable<org.gradle.api.Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.TaskInternal, org.gradle.api.Named, 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.
  • 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.

If false (default value since 2.0, recommended), you must add the runtime dependency, for the client or server, depending on the mode parameter you choosed. So the needed dependency would one of these two:

                
                        com.graphql-java-generator
                        graphql-java-client-runtime
                        ${graphql-plugin.version}
                
 
                
                        com.graphql-java-generator
                        graphql-java-server-runtime
                        ${graphql-plugin.version}
                
 

If true, you must add the runtime dependency, for the client or server, depending on the mode parameter you choosed. So the needed dependency would one of these two:

                
                        com.graphql-java-generator
                        graphql-java-client-dependencies
                        pom
                        ${graphql-plugin.version}
                
 
                
                        com.graphql-java-generator
                        graphql-java-server-dependencies
                        pom
                        ${graphql-plugin.version}
                
 
  • Constructor Details

    • GeneratePojoTask

      @Inject public GeneratePojoTask(org.gradle.api.file.ProjectLayout projectLayout)
      Parameters:
      projectLayout - This Gradle service is automatically injected by gradle. It allows to retrieve the project directory, as accessing the Gradle Project is forbidden from a task.
    • GeneratePojoTask

      public GeneratePojoTask(GeneratePojoExtension extension, org.gradle.api.file.ProjectLayout projectLayout)
  • Method Details

    • execute

      public void execute()
      Overrides:
      execute in class GraphQLGenerateCodeTask
    • getExtension

      protected GeneratePojoExtension getExtension()
      Overrides:
      getExtension in class GraphQLGenerateCodeTask
    • isGenerateJacksonAnnotations

      @Input public boolean isGenerateJacksonAnnotations()
      Specified by:
      isGenerateJacksonAnnotations in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
      Specified by:
      isGenerateJacksonAnnotations in interface com.graphql_java_generator.plugin.conf.GenerateClientCodeConfiguration
      Specified by:
      isGenerateJacksonAnnotations in interface com.graphql_java_generator.plugin.conf.GeneratePojoConfiguration
      Specified by:
      isGenerateJacksonAnnotations in interface com.graphql_java_generator.plugin.conf.GenerateServerCodeConfiguration
      Specified by:
      isGenerateJacksonAnnotations in interface com.graphql_java_generator.plugin.conf.GraphQLConfiguration
      Overrides:
      isGenerateJacksonAnnotations in class GraphQLGenerateCodeTask
    • setGenerateJacksonAnnotations

      public void setGenerateJacksonAnnotations(boolean generateJacksonAnnotations)
    • isGenerateUtilityClasses

      public boolean isGenerateUtilityClasses()
      Specified by:
      isGenerateUtilityClasses in interface com.graphql_java_generator.plugin.conf.GenerateCodeCommonConfiguration
      Specified by:
      isGenerateUtilityClasses in interface com.graphql_java_generator.plugin.conf.GeneratePojoConfiguration
      Overrides:
      isGenerateUtilityClasses in class GenerateCodeCommonTask
    • isSeparateUtilityClasses

      public boolean isSeparateUtilityClasses()
      There is no utility classes for this goal.
      Specified by:
      isSeparateUtilityClasses in interface com.graphql_java_generator.plugin.conf.GenerateCodeCommonConfiguration
      Specified by:
      isSeparateUtilityClasses in interface com.graphql_java_generator.plugin.conf.GeneratePojoConfiguration
      Overrides:
      isSeparateUtilityClasses in class GenerateCodeCommonTask
      Returns:
      The GeneratePojoConfiguration implementation of this method always returns false