Skip to content

Commit 96c8c7f

Browse files
committed
Merge branch 'develop'
2 parents 7f0fd75 + d23aed9 commit 96c8c7f

File tree

126 files changed

+1932
-242
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+1932
-242
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
id "org.sonarqube" version "3.1.1"
1010
}
1111

12-
def graphqlCodegenVersion = '5.0.0' // This variable used in the automatic release process
12+
def graphqlCodegenVersion = '5.1.0' // This variable used in the automatic release process
1313

1414
group = "io.github.kobylynskyi"
1515
version = graphqlCodegenVersion

docs/client-side-cases-by-proxy.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ final public class DynamicProxy implements InvocationHandler, ExecutionGraphql {
4242
/**
4343
* this is graphql request need that what response fields.
4444
*/
45-
private GraphQLResponseProjection projection;
45+
private final GraphQLResponseProjection projection;
4646

4747
/**
4848
* this graphql request that need request params. (if have)
4949
*/
50-
private GraphQLOperationRequest request;
50+
private final GraphQLOperationRequest request;
5151

5252
/**
5353
* should limit max depth when invoke method on projection.
5454
*/
55-
private int maxDepth;
55+
private final int maxDepth;
5656

5757
DynamicProxy(GraphQLResponseProjection projection, GraphQLOperationRequest request, int maxDepth) {
5858
this.projection = projection;
@@ -79,7 +79,7 @@ final public class DynamicProxy implements InvocationHandler, ExecutionGraphql {
7979

8080
/**
8181
* proxy invoke
82-
*
82+
*
8383
* <p>when handle projection, we use reflect to invoke method directly
8484
* but when handle request(need set parameters), we use reflect to get field which is a internal implementation of set method
8585
*
@@ -166,10 +166,10 @@ final public class DynamicProxy implements InvocationHandler, ExecutionGraphql {
166166
//if this method have no parameter, then do not need invoke on request instance
167167
//other wise, we need append parameters to request field which use hashmap store params
168168
if (!parameters.isEmpty()) {
169-
for (Parameter parameter : parameters) {
170-
Object argsCopy = args[i++];
171-
request.getInput().put(parameter.getName(), argsCopy);
172-
}
169+
for (Parameter parameter : parameters) {
170+
Object argsCopy = args[i++];
171+
request.getInput().put(parameter.getName(), argsCopy);
172+
}
173173
}
174174
try {
175175
field = projection.getClass().getSuperclass().getDeclaredField("fields");
@@ -191,7 +191,7 @@ final public class DynamicProxy implements InvocationHandler, ExecutionGraphql {
191191
}
192192

193193
return executeByHttp(entityClazzName, request, projection);// request and projection for creating GraphQLRequest, entityClazzName for deserialize
194-
}
194+
}
195195
}
196196
```
197197

docs/codegen-options.md

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
| `generateImmutableModels` | Boolean | False | Specifies whether generated model classes should be immutable. |
1919
| `generateToString` | Boolean | False | Specifies whether generated model classes should have toString method defined. |
2020
| `addGeneratedAnnotation` | Boolean | True | Specifies whether generated classes should have `@Generated` annotation. |
21+
| `generateJacksonTypeIdResolver` | Boolean | False | Specifies whether generated union interfaces should be annotated with a custom Jackson type id resolver generated in model package. |
2122
| `apiNamePrefix` | String | Empty | Sets the prefix for GraphQL api classes (query, mutation, subscription). |
2223
| `apiNameSuffix` | String | `Resolver` | Sets the suffix for GraphQL api classes (query, mutation, subscription). |
2324
| `apiInterfaceStrategy` | *See<br>[ApiInterfaceStrategy](#option-apiinterfacestrategy)* | `INTERFACE_PER_OPERATION` | *See [ApiInterfaceStrategy](#option-apiinterfacestrategy)* |
@@ -51,6 +52,7 @@ See [DirectiveAnnotationsMapping](#option-directiveannotationsmapping)* |
5152
| `responseProjectionSuffix` | String | ResponseProjection | Sets the suffix for `ResponseProjection` classes. |
5253
| `parametrizedInputSuffix` | String | ParametrizedInput | Sets the suffix for `ParametrizedInput` classes. |
5354
| `parentInterfaces` | *See<br>[parentInterfaces](#option-parentinterfaces)* | Empty | Block to define parent interfaces for generated interfaces (query / mutation / subscription / type resolver). *See [parentInterfaces](#option-parentinterfaces)* |
55+
| `generateAllMethodInProjection` | Boolean | true | Enables whether the `all$()` method should be generated in the projection classes. Disabling enforces the client to select the fields manually. |
5456
| `responseProjectionMaxDepth` | Integer | 3 | Sets max depth when use `all$()` which for facilitating the construction of projection automatically, the fields on all projections are provided when it be invoked. This is a global configuration, of course, you can use `all$(max)` to set for each method. For self recursive types, too big depth may result in a large number of returned data!|
5557
| `generatedLanguage` | Enum | GeneratedLanguage.JAVA | Choose which language you want to generate, Java,Scala,Kotlin were supported. Note that due to language features, there are slight differences in default values between languages.|
5658
| `generateModelOpenClasses` | Boolean | false | The class type of the generated model. If true, generate normal classes, else generate data classes. It only support in kotlin(```data class```) and scala(```case class```). Maybe we will consider to support Java ```record``` in the future.|

plugins/gradle/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
```groovy
1919
plugins {
20-
id "io.github.kobylynskyi.graphql.codegen" version "5.0.0"
20+
id "io.github.kobylynskyi.graphql.codegen" version "5.1.0"
2121
}
2222
```
2323

@@ -31,7 +31,7 @@ buildscript {
3131
}
3232
}
3333
dependencies {
34-
classpath "io.github.kobylynskyi.graphql.codegen:graphql-codegen-gradle-plugin:5.0.0"
34+
classpath "io.github.kobylynskyi.graphql.codegen:graphql-codegen-gradle-plugin:5.1.0"
3535
}
3636
}
3737

plugins/gradle/example-client-kotlin/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import io.github.kobylynskyi.graphql.codegen.gradle.GraphQLCodegenGradleTask
44
plugins {
55
id 'java'
66
id "org.jetbrains.kotlin.jvm" version "1.3.71"
7-
id "io.github.kobylynskyi.graphql.codegen" version "5.0.0"
7+
id "io.github.kobylynskyi.graphql.codegen" version "5.1.0"
88
}
99

10-
def graphqlCodegenClientKotlinVersion = '5.0.0' // Variable used in the automatic release process
10+
def graphqlCodegenClientKotlinVersion = '5.1.0' // Variable used in the automatic release process
1111

1212
group = 'io.github.dreamylost'
1313
version = graphqlCodegenClientKotlinVersion
@@ -29,7 +29,7 @@ repositories {
2929

3030

3131
dependencies {
32-
implementation "io.github.kobylynskyi:graphql-java-codegen:5.0.0"
32+
implementation "io.github.kobylynskyi:graphql-java-codegen:5.1.0"
3333
implementation "javax.validation:validation-api:2.0.1.Final"
3434
implementation "com.squareup.okhttp3:okhttp:4.2.2"
3535
implementation "com.fasterxml.jackson.core:jackson-core:2.12.0"

plugins/gradle/example-client/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77

88
// use the latest available version:
99
// https://plugins.gradle.org/plugin/io.github.kobylynskyi.graphql.codegen
10-
id "io.github.kobylynskyi.graphql.codegen" version "5.0.0"
10+
id "io.github.kobylynskyi.graphql.codegen" version "5.1.0"
1111
}
1212

1313
mainClassName = "io.github.kobylynskyi.order.Application"
@@ -18,11 +18,11 @@ dependencies {
1818

1919
implementation "com.graphql-java-kickstart:graphql-spring-boot-starter:11.0.0"
2020
implementation "com.graphql-java-kickstart:graphiql-spring-boot-starter:11.0.0"
21-
implementation "com.graphql-java:graphql-java-extended-scalars:16.0.0"
21+
implementation "com.graphql-java:graphql-java-extended-scalars:16.0.1"
2222

2323
// use the latest available version:
2424
// https://search.maven.org/artifact/io.github.kobylynskyi/graphql-java-codegen
25-
implementation "io.github.kobylynskyi:graphql-java-codegen:5.0.0"
25+
implementation "io.github.kobylynskyi:graphql-java-codegen:5.1.0"
2626

2727
implementation "org.apache.httpcomponents:httpclient:4.5.13"
2828
implementation "javax.validation:validation-api:2.0.1.Final"

plugins/gradle/example-server/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
//
77
// use the latest available version:
88
// https://plugins.gradle.org/plugin/io.github.kobylynskyi.graphql.codegen
9-
id "io.github.kobylynskyi.graphql.codegen" version "5.0.0"
9+
id "io.github.kobylynskyi.graphql.codegen" version "5.1.0"
1010
}
1111

1212
mainClassName = "io.github.kobylynskyi.product.Application"
@@ -17,7 +17,7 @@ dependencies {
1717

1818
implementation "com.graphql-java-kickstart:graphql-spring-boot-starter:11.0.0"
1919
implementation "com.graphql-java-kickstart:graphiql-spring-boot-starter:11.0.0"
20-
implementation "com.graphql-java:graphql-java-extended-scalars:16.0.0"
20+
implementation "com.graphql-java:graphql-java-extended-scalars:16.0.1"
2121

2222
implementation "javax.validation:validation-api:2.0.1.Final"
2323

plugins/gradle/graphql-java-codegen-gradle-plugin/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ apply plugin: "java"
1616
apply plugin: "idea"
1717
apply plugin: "maven-publish"
1818

19-
def graphqlCodegenGradlePluginVersion = '5.0.0' // This variable used in the automatic release process
19+
def graphqlCodegenGradlePluginVersion = '5.1.0' // This variable used in the automatic release process
2020

2121
group = "io.github.kobylynskyi"
2222
version = graphqlCodegenGradlePluginVersion

plugins/gradle/graphql-java-codegen-gradle-plugin/src/main/java/io/github/kobylynskyi/graphql/codegen/gradle/GraphQLCodegenGradleTask.java

+27-1
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,19 @@ public class GraphQLCodegenGradleTask extends DefaultTask implements GraphQLCode
8383
private Boolean useOptionalForNullableReturnTypes = MappingConfigConstants.DEFAULT_USE_OPTIONAL_FOR_NULLABLE_RETURN_TYPES;
8484
private Boolean generateApisWithThrowsException = MappingConfigConstants.DEFAULT_GENERATE_APIS_WITH_THROWS_EXCEPTION;
8585
private Boolean addGeneratedAnnotation = MappingConfigConstants.DEFAULT_ADD_GENERATED_ANNOTATION;
86+
private Boolean generateJacksonTypeIdResolver = MappingConfigConstants.DEFAULT_GENERATE_JACKSON_TYPE_ID_RESOLVER;
8687
private Set<String> fieldsWithResolvers = new HashSet<>();
8788
private Set<String> fieldsWithoutResolvers = new HashSet<>();
8889
private Set<String> typesAsInterfaces = new HashSet<>();
89-
private RelayConfig relayConfig = new RelayConfig();
90+
private final RelayConfig relayConfig = new RelayConfig();
9091

9192

9293
private Boolean generateClient;
9394
private String requestSuffix;
9495
private String responseSuffix;
9596
private String responseProjectionSuffix;
9697
private String parametrizedInputSuffix;
98+
private Boolean generateAllMethodInProjection = MappingConfigConstants.DEFAULT_GENERATE_ALL_METHOD;
9799
private int responseProjectionMaxDepth = MappingConfigConstants.DEFAULT_RESPONSE_PROJECTION_MAX_DEPTH;
98100
private Set<String> useObjectMapperForRequestSerialization = new HashSet<>();
99101

@@ -143,6 +145,7 @@ public void generate() throws Exception {
143145
mappingConfig.setUseOptionalForNullableReturnTypes(useOptionalForNullableReturnTypes);
144146
mappingConfig.setGenerateApisWithThrowsException(generateApisWithThrowsException);
145147
mappingConfig.setAddGeneratedAnnotation(addGeneratedAnnotation);
148+
mappingConfig.setGenerateJacksonTypeIdResolver(generateJacksonTypeIdResolver);
146149
mappingConfig.setApiReturnType(apiReturnType);
147150
mappingConfig.setApiReturnListType(apiReturnListType);
148151
mappingConfig.setSubscriptionReturnType(subscriptionReturnType);
@@ -165,6 +168,7 @@ public void generate() throws Exception {
165168
mappingConfig.setParametrizedInputSuffix(parametrizedInputSuffix);
166169
mappingConfig.setUseObjectMapperForRequestSerialization(useObjectMapperForRequestSerialization != null ?
167170
useObjectMapperForRequestSerialization : new HashSet<>());
171+
mappingConfig.setGenerateAllMethodInProjection(generateAllMethodInProjection);
168172
mappingConfig.setResponseProjectionMaxDepth(responseProjectionMaxDepth);
169173

170174
mappingConfig.setResolverParentInterface(getResolverParentInterface());
@@ -632,6 +636,17 @@ public void setAddGeneratedAnnotation(Boolean addGeneratedAnnotation) {
632636
this.addGeneratedAnnotation = addGeneratedAnnotation;
633637
}
634638

639+
@Input
640+
@Optional
641+
@Override
642+
public Boolean getGenerateJacksonTypeIdResolver() {
643+
return generateJacksonTypeIdResolver;
644+
}
645+
646+
public void setGenerateJacksonTypeIdResolver(Boolean generateJacksonTypeIdResolver) {
647+
this.generateJacksonTypeIdResolver = generateJacksonTypeIdResolver;
648+
}
649+
635650
@Input
636651
@Optional
637652
@Override
@@ -742,6 +757,17 @@ public void setUseObjectMapperForRequestSerialization(Set<String> useObjectMappe
742757
this.useObjectMapperForRequestSerialization = useObjectMapperForRequestSerialization;
743758
}
744759

760+
@Input
761+
@Optional
762+
@Override
763+
public Boolean getGenerateAllMethodInProjection() {
764+
return generateAllMethodInProjection;
765+
}
766+
767+
public void setGenerateAllMethodInProjection(boolean generateAllMethodInProjection) {
768+
this.generateAllMethodInProjection = generateAllMethodInProjection;
769+
}
770+
745771
@Input
746772
@Optional
747773
@Override

plugins/maven/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<plugin>
2121
<groupId>io.github.kobylynskyi</groupId>
2222
<artifactId>graphql-codegen-maven-plugin</artifactId>
23-
<version>5.0.0</version>
23+
<version>5.1.0</version>
2424
<executions>
2525
<execution>
2626
<goals>

plugins/maven/example-client/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>io.github.kobylynskyi</groupId>
66
<artifactId>graphql-codegen-maven-plugin-example-client</artifactId>
7-
<version>5.0.0</version>
7+
<version>5.1.0</version>
88
<name>graphql-codegen-maven-plugin-example-client</name>
99

1010
<build>
@@ -144,7 +144,7 @@
144144
<dependency>
145145
<groupId>com.graphql-java</groupId>
146146
<artifactId>graphql-java-extended-scalars</artifactId>
147-
<version>16.0.0</version>
147+
<version>16.0.1</version>
148148
</dependency>
149149

150150

plugins/maven/example-server/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>io.github.kobylynskyi</groupId>
66
<artifactId>graphql-codegen-maven-plugin-example-server</artifactId>
7-
<version>5.0.0</version>
7+
<version>5.1.0</version>
88
<name>graphql-codegen-maven-plugin-example-server</name>
99

1010
<build>
@@ -97,7 +97,7 @@
9797
<dependency>
9898
<groupId>com.graphql-java</groupId>
9999
<artifactId>graphql-java-extended-scalars</artifactId>
100-
<version>16.0.0</version>
100+
<version>16.0.1</version>
101101
</dependency>
102102

103103
<dependency>

plugins/maven/graphql-java-codegen-maven-plugin/pom.xml

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>io.github.kobylynskyi</groupId>
55
<artifactId>graphql-codegen-maven-plugin</artifactId>
6-
<version>5.0.0</version>
6+
<version>5.1.0</version>
77
<packaging>maven-plugin</packaging>
88

99
<name>graphql-codegen-maven-plugin</name>
@@ -56,10 +56,10 @@
5656
</ciManagement>
5757

5858
<properties>
59-
<version.maven-plugin-api>3.6.3</version.maven-plugin-api>
60-
<version.maven-core>3.6.3</version.maven-core>
61-
<version.maven-plugin-annotations>3.6.0</version.maven-plugin-annotations>
62-
<version.maven-plugin-plugin>3.6.0</version.maven-plugin-plugin>
59+
<version.maven-plugin-api>3.8.1</version.maven-plugin-api>
60+
<version.maven-core>3.8.1</version.maven-core>
61+
<version.maven-plugin-annotations>3.6.1</version.maven-plugin-annotations>
62+
<version.maven-plugin-plugin>3.6.1</version.maven-plugin-plugin>
6363
<version.maven-compiler-plugin>3.8.1</version.maven-compiler-plugin>
6464
<version.maven-resources-plugin>3.2.0</version.maven-resources-plugin>
6565
<version.maven-source-plugin>3.2.1</version.maven-source-plugin>
@@ -72,7 +72,7 @@
7272
<version.maven-gpg-plugin>1.6</version.maven-gpg-plugin>
7373
<version.maven-shared-utils>3.3.3</version.maven-shared-utils>
7474

75-
<version.graphql-java-codegen>5.0.0</version.graphql-java-codegen>
75+
<version.graphql-java-codegen>5.1.0</version.graphql-java-codegen>
7676
</properties>
7777

7878
<dependencies>

plugins/maven/graphql-java-codegen-maven-plugin/src/main/java/io/github/kobylynskyi/graphql/codegen/GraphQLCodegenMojo.java

+18
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ public class GraphQLCodegenMojo extends AbstractMojo implements GraphQLCodegenCo
152152
@Parameter(defaultValue = MappingConfigConstants.DEFAULT_ADD_GENERATED_ANNOTATION_STRING)
153153
private boolean addGeneratedAnnotation;
154154

155+
@Parameter(defaultValue = MappingConfigConstants.DEFAULT_GENERATE_JACKSON_TYPE_ID_RESOLVER_STRING)
156+
private boolean generateJacksonTypeIdResolver;
157+
155158
@Parameter
156159
private String[] fieldsWithResolvers;
157160

@@ -185,6 +188,9 @@ public class GraphQLCodegenMojo extends AbstractMojo implements GraphQLCodegenCo
185188
@Parameter(defaultValue = MappingConfigConstants.DEFAULT_RESPONSE_PROJECTION_MAX_DEPTH_STRING)
186189
private int responseProjectionMaxDepth;
187190

191+
@Parameter(defaultValue = MappingConfigConstants.DEFAULT_GENERATE_ALL_METHOD_STRING)
192+
private boolean generateAllMethodInProjection;
193+
188194
@Parameter
189195
private ParentInterfacesConfig parentInterfaces = new ParentInterfacesConfig();
190196

@@ -239,6 +245,7 @@ public void execute() throws MojoExecutionException {
239245
mappingConfig.setUseOptionalForNullableReturnTypes(useOptionalForNullableReturnTypes);
240246
mappingConfig.setGenerateApisWithThrowsException(generateApisWithThrowsException);
241247
mappingConfig.setAddGeneratedAnnotation(addGeneratedAnnotation);
248+
mappingConfig.setGenerateJacksonTypeIdResolver(generateJacksonTypeIdResolver);
242249
mappingConfig.setFieldsWithResolvers(mapToHashSet(fieldsWithResolvers));
243250
mappingConfig.setFieldsWithoutResolvers(mapToHashSet(fieldsWithoutResolvers));
244251
mappingConfig.setRelayConfig(relayConfig);
@@ -248,6 +255,7 @@ public void execute() throws MojoExecutionException {
248255
mappingConfig.setResponseSuffix(responseSuffix);
249256
mappingConfig.setResponseProjectionSuffix(responseProjectionSuffix);
250257
mappingConfig.setParametrizedInputSuffix(parametrizedInputSuffix);
258+
mappingConfig.setGenerateAllMethodInProjection(generateAllMethodInProjection);
251259
mappingConfig.setResponseProjectionMaxDepth(responseProjectionMaxDepth);
252260
mappingConfig.setUseObjectMapperForRequestSerialization(mapToHashSet(useObjectMapperForRequestSerialization));
253261
mappingConfig.setTypesAsInterfaces(mapToHashSet(typesAsInterfaces));
@@ -490,6 +498,11 @@ public Boolean getAddGeneratedAnnotation() {
490498
return addGeneratedAnnotation;
491499
}
492500

501+
@Override
502+
public Boolean getGenerateJacksonTypeIdResolver() {
503+
return generateJacksonTypeIdResolver;
504+
}
505+
493506
@Override
494507
public ApiRootInterfaceStrategy getApiRootInterfaceStrategy() {
495508
return apiRootInterfaceStrategy;
@@ -515,6 +528,11 @@ public Set<String> getFieldsWithoutResolvers() {
515528
return mapToHashSet(fieldsWithoutResolvers);
516529
}
517530

531+
@Override
532+
public Boolean getGenerateAllMethodInProjection() {
533+
return generateAllMethodInProjection;
534+
}
535+
518536
@Override
519537
public Integer getResponseProjectionMaxDepth() {
520538
return responseProjectionMaxDepth;

0 commit comments

Comments
 (0)