Skip to content

Commit 0198f41

Browse files
authored
Merge pull request #953 from kobylynskyi/develop
5.4.0 release
2 parents 8eaef37 + 0443f98 commit 0198f41

File tree

120 files changed

+1537
-89
lines changed

Some content is hidden

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

120 files changed

+1537
-89
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
id "org.sonarqube" version "3.2.0"
1010
}
1111

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

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

docs/codegen-options.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ See [DirectiveAnnotationsMapping](#option-directiveannotationsmapping)* |
5656
| `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!|
5757
| `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.|
5858
| `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.|
59+
| `initializeNullableTypes` | Boolean | false | Adds a default null value to nullable arguments. Only supported in Kotlin.
60+
| `generateSealedInterfaces` | Boolean | false | This applies to generated interfaces on unions and interfaces. If true, generate sealed interfaces, else generate normal ones. It is only supported in Kotlin. |
5961
| `typesAsInterfaces` | Set(String) | Empty | Types that must generated as interfaces should be defined here in format: `TypeName` or `@directive`. E.g.: `User`, `@asInterface`. |
62+
| `useObjectMapperForRequestSerialization` | Set(String) | Empty | Fields that require serialization using `com.fasterxml.jackson.databind.ObjectMapper#writeValueAsString(Object)`. Values should be defined here in the following format: `GraphqlObjectName.fieldName` or `GraphqlTypeName`. If just type is specified, then all fields of this type will be serialized using ObjectMapper. E.g.: `["Person.createdDateTime", ZonedDateTime"]` |
63+
| `supportUnknownFields` | Boolean | false | Specifies whether api classes should support unknown fields during serialization or deserialization. If `true`, classes will include a property of type [`java.util.Map<String,Object>`](https://docs.oracle.com/javase/8/docs/api/index.html?java/util/Map.html) that will store unknown fields.|
64+
| `unknownFieldsPropertyName` | String | userDefinedFields | Specifies the name of the property to be included in api classes to support unknown fields during serialization or deserialization|
65+
6066

6167
### Option `graphqlSchemas`
6268

plugins/gradle/README.md

Lines changed: 2 additions & 2 deletions
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.3.0"
20+
id "io.github.kobylynskyi.graphql.codegen" version "5.4.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.3.0"
34+
classpath "io.github.kobylynskyi.graphql.codegen:graphql-codegen-gradle-plugin:5.4.0"
3535
}
3636
}
3737

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

Lines changed: 5 additions & 3 deletions
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.3.0"
7+
id "io.github.kobylynskyi.graphql.codegen" version "5.4.0"
88
}
99

10-
def graphqlCodegenClientKotlinVersion = '5.3.0' // Variable used in the automatic release process
10+
def graphqlCodegenClientKotlinVersion = '5.4.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.3.0"
32+
implementation "io.github.kobylynskyi:graphql-java-codegen:5.4.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"
@@ -57,11 +57,13 @@ task graphqlCodegenKotlinService(type: GraphQLCodegenGradleTask) {
5757
apiPackageName = "io.github.dreamylost.api"
5858
modelPackageName = "io.github.dreamylost.model"
5959
generateModelOpenClasses = true
60+
generateSealedInterfaces = true
6061
customAnnotationsMapping = [
6162
"Character": ["@com.fasterxml.jackson.annotation.JsonTypeInfo(use=com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, include=com.fasterxml.jackson.annotation.JsonTypeInfo.As.PROPERTY,property = \"__typename\")",
6263
"@com.fasterxml.jackson.annotation.JsonSubTypes(value = arrayOf(" + System.lineSeparator() +
6364
" com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = HumanTO::class, name = \"Human\"), " + System.lineSeparator() +
6465
" com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = DroidTO::class, name = \"Droid\")))"],
6566
]
6667
modelNameSuffix = "TO"
68+
supportUnknownFields = true
6769
}

plugins/gradle/example-client/build.gradle

Lines changed: 2 additions & 2 deletions
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.3.0"
10+
id "io.github.kobylynskyi.graphql.codegen" version "5.4.0"
1111
}
1212

1313
mainClassName = "io.github.kobylynskyi.order.Application"
@@ -22,7 +22,7 @@ dependencies {
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.3.0"
25+
implementation "io.github.kobylynskyi:graphql-java-codegen:5.4.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

Lines changed: 4 additions & 1 deletion
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.3.0"
9+
id "io.github.kobylynskyi.graphql.codegen" version "5.4.0"
1010
}
1111

1212
mainClassName = "io.github.kobylynskyi.product.Application"
@@ -48,6 +48,9 @@ graphqlCodegen {
4848
}
4949
modelNameSuffix = "TO"
5050
generateApis = true
51+
supportUnknownFields = true
52+
unknownFieldsPropertyName = "additionalFields"
53+
5154
}
5255

5356
repositories {

plugins/gradle/example-server/src/main/java/io/github/kobylynskyi/product/Application.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
@SpringBootApplication
77
public class Application {
88

9+
910
public static void main(String[] args) {
1011
SpringApplication.run(Application.class, args);
1112
}

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

Lines changed: 1 addition & 1 deletion
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.3.0' // This variable used in the automatic release process
19+
def graphqlCodegenGradlePluginVersion = '5.4.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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ public class GraphQLCodegenGradleTask extends DefaultTask implements GraphQLCode
103103
private List<String> configurationFiles;
104104
private GeneratedLanguage generatedLanguage = MappingConfigConstants.DEFAULT_GENERATED_LANGUAGE;
105105
private Boolean generateModelOpenClasses = MappingConfigConstants.DEFAULT_GENERATE_MODEL_OPEN_CLASSES;
106+
private Boolean initializeNullableTypes = MappingConfigConstants.DEFAULT_INITIALIZE_NULLABLE_TYPES;
107+
private Boolean generateSealedInterfaces = MappingConfigConstants.DEFAULT_GENERATE_SEALED_INTERFACES;
108+
109+
private Boolean supportUnknownFields = MappingConfigConstants.DEFAULT_SUPPORT_UNKNOWN_FIELDS;
110+
private String unknownFieldsPropertyName = MappingConfigConstants.DEFAULT_UNKNOWN_FIELDS_PROPERTY_NAME;
106111

107112
public GraphQLCodegenGradleTask() {
108113
setGroup("codegen");
@@ -178,6 +183,10 @@ public void generate() throws Exception {
178183

179184
mappingConfig.setGeneratedLanguage(generatedLanguage);
180185
mappingConfig.setGenerateModelOpenClasses(generateModelOpenClasses);
186+
mappingConfig.setInitializeNullableTypes(initializeNullableTypes);
187+
188+
mappingConfig.setSupportUnknownFields(isSupportUnknownFields());
189+
mappingConfig.setUnknownFieldsPropertyName(getUnknownFieldsPropertyName());
181190

182191
instantiateCodegen(mappingConfig).generate();
183192
}
@@ -844,4 +853,50 @@ public Boolean isGenerateModelOpenClasses() {
844853
public void setGenerateModelOpenClasses(Boolean generateModelOpenClasses) {
845854
this.generateModelOpenClasses = generateModelOpenClasses;
846855
}
856+
857+
@Input
858+
@Optional
859+
@Override
860+
public Boolean isInitializeNullableTypes() {
861+
return initializeNullableTypes;
862+
}
863+
864+
public void setInitializeNullableTypes(Boolean initializeNullableTypes) {
865+
this.initializeNullableTypes = initializeNullableTypes;
866+
}
867+
868+
@Input
869+
@Optional
870+
@Override
871+
public Boolean isGenerateSealedInterfaces() {
872+
return generateSealedInterfaces;
873+
}
874+
875+
public void setGenerateSealedInterfaces(Boolean generateSealedInterfaces) {
876+
this.generateSealedInterfaces = generateSealedInterfaces;
877+
}
878+
879+
@Input
880+
@Optional
881+
@Override
882+
public Boolean isSupportUnknownFields() {
883+
return supportUnknownFields;
884+
}
885+
886+
public void setSupportUnknownFields(boolean supportUnknownFields) {
887+
this.supportUnknownFields = supportUnknownFields;
888+
}
889+
890+
@Input
891+
@Optional
892+
@Override
893+
public String getUnknownFieldsPropertyName() {
894+
return unknownFieldsPropertyName;
895+
}
896+
897+
public void setUnknownFieldsPropertyName(String unknownFieldsPropertyName) {
898+
this.unknownFieldsPropertyName = unknownFieldsPropertyName;
899+
}
900+
901+
847902
}

plugins/maven/README.md

Lines changed: 1 addition & 1 deletion
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.3.0</version>
23+
<version>5.4.0</version>
2424
<executions>
2525
<execution>
2626
<goals>

0 commit comments

Comments
 (0)