|
1 |
| -# GraphQL Codegen Maven plugin # |
| 1 | +# This repository was moved to the brand new location |
2 | 2 |
|
3 |
| -[](https://circleci.com/gh/kobylynskyi/graphql-java-codegen-maven-plugin/tree/master) |
4 |
| -[](https://maven-badges.herokuapp.com/maven-central/io.github.kobylynskyi/graphql-codegen-maven-plugin) |
5 |
| -[](https://opensource.org/licenses/MIT) |
6 |
| - |
7 |
| -This document describes the maven plugin for GraphQL Generator. |
8 |
| - |
9 |
| -### Description |
10 |
| - |
11 |
| -This Maven plugin is able to generate the following classes based on your GraphQL schema: |
12 |
| -* Interfaces for GraphQL queries, mutations and subscriptions |
13 |
| -* Interfaces for GraphQL unions |
14 |
| -* POJO classes for GraphQL types |
15 |
| -* Enum classes for each GraphQL enum |
16 |
| - |
17 |
| -### Plugin Setup and Configuration |
18 |
| - |
19 |
| -```xml |
20 |
| -<build> |
21 |
| - <plugins> |
22 |
| - ... |
23 |
| - <plugin> |
24 |
| - <groupId>io.github.kobylynskyi</groupId> |
25 |
| - <artifactId>graphql-codegen-maven-plugin</artifactId> |
26 |
| - <version>1.4.2</version> |
27 |
| - <executions> |
28 |
| - <execution> |
29 |
| - <goals> |
30 |
| - <goal>generate</goal> |
31 |
| - </goals> |
32 |
| - <configuration> |
33 |
| - <graphqlSchemaPaths>${project.basedir}/src/main/resources/schema.graphqls</graphqlSchemaPaths> |
34 |
| - <outputDir>${project.build.directory}/generated-sources/graphql</outputDir> |
35 |
| - <packageName>io.github.kobylynskyi.bikeshop.graphql.model</packageName> |
36 |
| - <customTypesMapping> |
37 |
| - <DateTime>java.util.Date</DateTime> |
38 |
| - <Price.amount>java.math.BigDecimal</Price.amount> |
39 |
| - </customTypesMapping> |
40 |
| - <customAnnotationsMapping> |
41 |
| - <EpochMillis>com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.json.EpochMillisScalarDeserializer.class</EpochMillis> |
42 |
| - </customAnnotationsMapping> |
43 |
| - <modelNameSuffix>TO</modelNameSuffix> |
44 |
| - </configuration> |
45 |
| - </execution> |
46 |
| - </executions> |
47 |
| - </plugin> |
48 |
| - ... |
49 |
| - </plugins> |
50 |
| -</build> |
51 |
| -``` |
52 |
| - |
53 |
| - |
54 |
| -#### Plugin Options |
55 |
| - |
56 |
| -| Key | Data Type | Default value | Description | |
57 |
| -| ------------------------- | ------------------ | ----------------------------------------- | ----------- | |
58 |
| -| graphqlSchemaPaths | List(String) | None | GraphQL schema locations. You can supply multiple paths to GraphQL schemas. | |
59 |
| -| packageName | String | Empty | Java package for generated classes. | |
60 |
| -| outputDir | String | None | The output target directory into which code will be generated. | |
61 |
| -| apiPackage | String | Empty | Java package for generated api classes (Query, Mutation, Subscription). | |
62 |
| -| modelPackage | String | Empty | Java package for generated model classes (type, input, interface, enum, union). | |
63 |
| -| generateApis | Boolean | True | Specifies whether api classes should be generated as well as model classes. | |
64 |
| -| customTypesMapping | Map(String,String) | Empty | Can be used to supply custom mappings for scalars. <br/> Supports:<br/> * Map of (GraphqlObjectName.fieldName) to (JavaType) <br/> * Map of (GraphqlType) to (JavaType) | |
65 |
| -| customAnnotationsMapping | Map(String,String) | Empty | Can be used to supply custom annotations (serializers) for scalars. <br/> Supports:<br/> * Map of (GraphqlObjectName.fieldName) to (JavaType) <br/> * Map of (GraphqlType) to (JavaType) | |
66 |
| -| modelValidationAnnotation | String | @javax.validation.<br>constraints.NotNull | Annotation for mandatory (NonNull) fields. Can be null/empty. | |
67 |
| -| modelNamePrefix | String | Empty | Sets the prefix for GraphQL model classes (type, input, interface, enum, union). | |
68 |
| -| modelNameSuffix | String | Empty | Sets the suffix for GraphQL model classes (type, input, interface, enum, union). | |
69 |
| -| subscriptionReturnType | String | Empty | Return type for subscription methods. For example: `org.reactivestreams.Publisher`, `io.reactivex.Observable`, etc. | |
70 |
| -| generateEqualsAndHashCode | Boolean | False | Specifies whether generated model classes should have equals and hashCode methods defined. | |
71 |
| -| generateToString | Boolean | False | Specifies whether generated model classes should have toString method defined. | |
72 |
| -| generateAsyncApi | Boolean | False | If true, then wrap type into `java.util.concurrent.CompletableFuture` or `subscriptionReturnType` | |
73 |
| -| jsonConfigurationFile | String | Empty | Path to an external mapping configuration. | |
74 |
| - |
75 |
| -#### External mapping configuration |
76 |
| - |
77 |
| -Provide a path to external file via property `jsonConfigurationFile` |
78 |
| -Sample content of the file: |
79 |
| - |
80 |
| -```json |
81 |
| -{ |
82 |
| - "generateApis": true, |
83 |
| - "packageName": "com.kobylynskyi.graphql.testconfigjson", |
84 |
| - "customTypesMapping": { |
85 |
| - "Price.amount": "java.math.BigDecimal" |
86 |
| - } |
87 |
| -} |
88 |
| -``` |
89 |
| - |
90 |
| -### Different configuration for each graphql schema |
91 |
| -If you want to have different configuration for different `.graphqls` files (e.g.: different javaPackage, outputDir, etc.), then you will need to define separate executions for each set of schemas. E.g.: |
92 |
| - |
93 |
| -```xml |
94 |
| -<executions> |
95 |
| - <execution> |
96 |
| - <id>graphqlCodegenService1</id> |
97 |
| - <goals> |
98 |
| - <goal>generate</goal> |
99 |
| - </goals> |
100 |
| - <configuration> |
101 |
| - <graphqlSchemaPaths>${project.basedir}/src/main/resources/schema1.graphqls</graphqlSchemaPaths> |
102 |
| - <outputDir>${project.build.directory}/generated-sources/graphql1</outputDir> |
103 |
| - </configuration> |
104 |
| - </execution> |
105 |
| - <execution> |
106 |
| - <id>graphqlCodegenService2</id> |
107 |
| - <goals> |
108 |
| - <goal>generate</goal> |
109 |
| - </goals> |
110 |
| - <configuration> |
111 |
| - <graphqlSchemaPaths>${project.basedir}/src/main/resources/schema2.graphqls</graphqlSchemaPaths> |
112 |
| - <outputDir>${project.build.directory}/generated-sources/graphql2</outputDir> |
113 |
| - </configuration> |
114 |
| - </execution> |
115 |
| -</executions> |
116 |
| -``` |
117 |
| - |
118 |
| -### Example |
119 |
| - |
120 |
| -[example project](example) |
121 |
| - |
122 |
| - |
123 |
| -### Inspired by |
124 |
| -[swagger-codegen](https://github.com/swagger-api/swagger-codegen) |
| 3 | +[graphql-java-codegen-maven-plugin](https://github.com/kobylynskyi/graphql-java-codegen/tree/master/plugins/graphql-java-codegen-maven-plugin) |
125 | 4 |
|
| 5 | +All open issues/PRs were transferred to the repository above. |
0 commit comments