Class 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 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:

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

    • GenerateServerCodeMojo

      protected GenerateServerCodeMojo()