Plugin Documentation
Goals available for this plugin:
Goal | Description |
---|---|
graphql:generateClientCode | The generateClientCode Maven goal (and Gradle task) generates the java code from one or more GraphQL schemas. It allows to work in Java with graphQL, in a schema first approach. It generates a class for each query, mutation and subscription type. These classes contain the methods to call the queries, mutations and subscriptions. That is: to execute a query against the GraphQL server, you just have to call one of these methods. It also generates the POJOs from the GraphQL schema. The GraphQL response is stored in these POJOs, for an easy and standard use in Java.You'll find more info in the tutorials: take a look at the Maven client tutorial or the Gradle client tutorial |
graphql:generateGraphQLSchema | The generateGraphQLSchema goal generates GraphQL schema, based on the source GraphQL schemas, and possibly containing additional stuff, like the Relay connection objects. It can be used to:
This goal is, by default, attached to the Initialize maven phase, to be sure that the GraphQL schema are generated before the code generation would need it, if relevant. |
graphql:generatePojo | 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:
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):
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. |
graphql:generateServerCode | 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 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
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 |
graphql:graphql | This goal is deprecated. The graphql goal generates the java code from one or more GraphQL schemas. It allows to work in Java with graphQL, in a schema first approach. It will be maintained in the future 2.x versions. The generateClientCode and generateServerCode should be used instead.The graphql goal has two main modes:
|
System Requirements
The following specifies the minimum requirements to run this Maven plugin:
Maven | 2.0 |
JDK | 8 |
Usage
You should specify the version in your project's plugin configuration:
<project> ... <build> <!-- To define the plugin version in your parent POM --> <pluginManagement> <plugins> <plugin> <groupId>com.graphql-java-generator</groupId> <artifactId>graphql-maven-plugin</artifactId> <version>2.8</version> </plugin> ... </plugins> </pluginManagement> <!-- To use the plugin goals in your POM or parent POM --> <plugins> <plugin> <groupId>com.graphql-java-generator</groupId> <artifactId>graphql-maven-plugin</artifactId> </plugin> ... </plugins> </build> ... </project>
For more information, see "Guide to Configuring Plug-ins"