Class GeneratePojoMojo

All Implemented Interfaces:
CommonConfiguration, GenerateClientCodeConfiguration, GenerateCodeCommonConfiguration, GeneratePojoConfiguration, GenerateServerCodeConfiguration, GraphQLConfiguration, org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="generatePojo", defaultPhase=GENERATE_SOURCES, requiresProject=true) @ThreadSafe public class GeneratePojoMojo extends AbstractGeneratePojoMojo

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
  • Constructor Details

    • GeneratePojoMojo

      public GeneratePojoMojo()