Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9e19738
Don't fail with enums in directive parameters.
meistermeier Apr 28, 2021
e29d1fb
Merge branch 'develop' into issue/gh-673
kobylynskyi Apr 29, 2021
7f93937
Move null condition to top.
meistermeier Apr 29, 2021
8d63027
Avoid duplicates in enum imports (Scala).
meistermeier Apr 29, 2021
aa85c36
Fix checkstyle.
meistermeier Apr 29, 2021
c40ec60
Update to next development version: 5.2.1-SNAPSHOT
kobylynskyi Jun 16, 2021
fb17635
Scala: fix generateModelOpenClasses (#741)
jxnu-liguobin Jul 5, 2021
1ddbbf5
Add @JvmStatic annotation to Kotlin builders (#771)
kbrooks Sep 3, 2021
d7ae176
Code refactor: migrate generators into separate classes
kobylynskyi Sep 3, 2021
894fbd4
Support RegEx in customAnnotationsMapping #783
kobylynskyi Sep 4, 2021
09cc22c
Fix minor checkstyle issues
kobylynskyi Sep 4, 2021
36e2679
Fix GraphQLCodegenOpenclassesTest
kobylynskyi Sep 4, 2021
1cb8024
Prepare for the next release version: 5.3.0
kobylynskyi Sep 4, 2021
4730207
Merge branch 'issue/gh-673' of https://github.com/meistermeier/graphq…
kobylynskyi Sep 4, 2021
aab0c52
Merge branch 'meistermeier-issue/gh-673' into develop
kobylynskyi Sep 4, 2021
06c8bd8
Minor refactor and code-style fixes
kobylynskyi Sep 4, 2021
cbd9f64
Bump version to 5.3.0 - release
kobylynskyi Sep 5, 2021
964094c
Update to next development version: 5.3.1-SNAPSHOT
kobylynskyi Sep 5, 2021
69dee51
Add serialVersionUID to generated classes that implement Serializable…
rolevinks Nov 7, 2021
96bdde7
Kotlin: Add option to add defaults to nullable fields (#863)
zmack Nov 11, 2021
4fb7dbf
Delete .dependabot directory
kobylynskyi Dec 2, 2021
7f5b3c8
Kotlin: fix default value (#882)
jxnu-liguobin Dec 2, 2021
d6bd6b4
[Kotlin] Ability to generate sealed interfaces (#869)
kbrooks Dec 2, 2021
97fef96
Add description of useObjectMapperForRequestSerialization to codegen-…
kobylynskyi Dec 3, 2021
323efd0
Parameterized field getters in type interface are missing parameters …
kobylynskyi Jan 16, 2022
d6f7d73
When using GraphQL federation, external parties can extend types and …
aldib Jan 20, 2022
eb6cec6
Merge branch 'master' into develop
kobylynskyi Jan 23, 2022
0443f98
Bump version to 5.4.0 - release
kobylynskyi Jan 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
id "org.sonarqube" version "3.2.0"
}

def graphqlCodegenVersion = '5.3.0' // This variable used in the automatic release process
def graphqlCodegenVersion = '5.4.0' // This variable used in the automatic release process

group = "io.github.kobylynskyi"
version = graphqlCodegenVersion
Expand Down
6 changes: 6 additions & 0 deletions docs/codegen-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ See [DirectiveAnnotationsMapping](#option-directiveannotationsmapping)* |
| `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!|
| `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.|
| `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.|
| `initializeNullableTypes` | Boolean | false | Adds a default null value to nullable arguments. Only supported in Kotlin.
| `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. |
| `typesAsInterfaces` | Set(String) | Empty | Types that must generated as interfaces should be defined here in format: `TypeName` or `@directive`. E.g.: `User`, `@asInterface`. |
| `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"]` |
| `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.|
| `unknownFieldsPropertyName` | String | userDefinedFields | Specifies the name of the property to be included in api classes to support unknown fields during serialization or deserialization|


### Option `graphqlSchemas`

Expand Down
4 changes: 2 additions & 2 deletions plugins/gradle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

```groovy
plugins {
id "io.github.kobylynskyi.graphql.codegen" version "5.3.0"
id "io.github.kobylynskyi.graphql.codegen" version "5.4.0"
}
```

Expand All @@ -31,7 +31,7 @@ buildscript {
}
}
dependencies {
classpath "io.github.kobylynskyi.graphql.codegen:graphql-codegen-gradle-plugin:5.3.0"
classpath "io.github.kobylynskyi.graphql.codegen:graphql-codegen-gradle-plugin:5.4.0"
}
}

Expand Down
8 changes: 5 additions & 3 deletions plugins/gradle/example-client-kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import io.github.kobylynskyi.graphql.codegen.gradle.GraphQLCodegenGradleTask
plugins {
id 'java'
id "org.jetbrains.kotlin.jvm" version "1.3.71"
id "io.github.kobylynskyi.graphql.codegen" version "5.3.0"
id "io.github.kobylynskyi.graphql.codegen" version "5.4.0"
}

def graphqlCodegenClientKotlinVersion = '5.3.0' // Variable used in the automatic release process
def graphqlCodegenClientKotlinVersion = '5.4.0' // Variable used in the automatic release process

group = 'io.github.dreamylost'
version = graphqlCodegenClientKotlinVersion
Expand All @@ -29,7 +29,7 @@ repositories {


dependencies {
implementation "io.github.kobylynskyi:graphql-java-codegen:5.3.0"
implementation "io.github.kobylynskyi:graphql-java-codegen:5.4.0"
implementation "javax.validation:validation-api:2.0.1.Final"
implementation "com.squareup.okhttp3:okhttp:4.2.2"
implementation "com.fasterxml.jackson.core:jackson-core:2.12.0"
Expand Down Expand Up @@ -57,11 +57,13 @@ task graphqlCodegenKotlinService(type: GraphQLCodegenGradleTask) {
apiPackageName = "io.github.dreamylost.api"
modelPackageName = "io.github.dreamylost.model"
generateModelOpenClasses = true
generateSealedInterfaces = true
customAnnotationsMapping = [
"Character": ["@com.fasterxml.jackson.annotation.JsonTypeInfo(use=com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, include=com.fasterxml.jackson.annotation.JsonTypeInfo.As.PROPERTY,property = \"__typename\")",
"@com.fasterxml.jackson.annotation.JsonSubTypes(value = arrayOf(" + System.lineSeparator() +
" com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = HumanTO::class, name = \"Human\"), " + System.lineSeparator() +
" com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = DroidTO::class, name = \"Droid\")))"],
]
modelNameSuffix = "TO"
supportUnknownFields = true
}
4 changes: 2 additions & 2 deletions plugins/gradle/example-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {

// use the latest available version:
// https://plugins.gradle.org/plugin/io.github.kobylynskyi.graphql.codegen
id "io.github.kobylynskyi.graphql.codegen" version "5.3.0"
id "io.github.kobylynskyi.graphql.codegen" version "5.4.0"
}

mainClassName = "io.github.kobylynskyi.order.Application"
Expand All @@ -22,7 +22,7 @@ dependencies {

// use the latest available version:
// https://search.maven.org/artifact/io.github.kobylynskyi/graphql-java-codegen
implementation "io.github.kobylynskyi:graphql-java-codegen:5.3.0"
implementation "io.github.kobylynskyi:graphql-java-codegen:5.4.0"

implementation "org.apache.httpcomponents:httpclient:4.5.13"
implementation "javax.validation:validation-api:2.0.1.Final"
Expand Down
5 changes: 4 additions & 1 deletion plugins/gradle/example-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
//
// use the latest available version:
// https://plugins.gradle.org/plugin/io.github.kobylynskyi.graphql.codegen
id "io.github.kobylynskyi.graphql.codegen" version "5.3.0"
id "io.github.kobylynskyi.graphql.codegen" version "5.4.0"
}

mainClassName = "io.github.kobylynskyi.product.Application"
Expand Down Expand Up @@ -48,6 +48,9 @@ graphqlCodegen {
}
modelNameSuffix = "TO"
generateApis = true
supportUnknownFields = true
unknownFieldsPropertyName = "additionalFields"

}

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@SpringBootApplication
public class Application {


public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ apply plugin: "java"
apply plugin: "idea"
apply plugin: "maven-publish"

def graphqlCodegenGradlePluginVersion = '5.3.0' // This variable used in the automatic release process
def graphqlCodegenGradlePluginVersion = '5.4.0' // This variable used in the automatic release process

group = "io.github.kobylynskyi"
version = graphqlCodegenGradlePluginVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ public class GraphQLCodegenGradleTask extends DefaultTask implements GraphQLCode
private List<String> configurationFiles;
private GeneratedLanguage generatedLanguage = MappingConfigConstants.DEFAULT_GENERATED_LANGUAGE;
private Boolean generateModelOpenClasses = MappingConfigConstants.DEFAULT_GENERATE_MODEL_OPEN_CLASSES;
private Boolean initializeNullableTypes = MappingConfigConstants.DEFAULT_INITIALIZE_NULLABLE_TYPES;
private Boolean generateSealedInterfaces = MappingConfigConstants.DEFAULT_GENERATE_SEALED_INTERFACES;

private Boolean supportUnknownFields = MappingConfigConstants.DEFAULT_SUPPORT_UNKNOWN_FIELDS;
private String unknownFieldsPropertyName = MappingConfigConstants.DEFAULT_UNKNOWN_FIELDS_PROPERTY_NAME;

public GraphQLCodegenGradleTask() {
setGroup("codegen");
Expand Down Expand Up @@ -178,6 +183,10 @@ public void generate() throws Exception {

mappingConfig.setGeneratedLanguage(generatedLanguage);
mappingConfig.setGenerateModelOpenClasses(generateModelOpenClasses);
mappingConfig.setInitializeNullableTypes(initializeNullableTypes);

mappingConfig.setSupportUnknownFields(isSupportUnknownFields());
mappingConfig.setUnknownFieldsPropertyName(getUnknownFieldsPropertyName());

instantiateCodegen(mappingConfig).generate();
}
Expand Down Expand Up @@ -844,4 +853,50 @@ public Boolean isGenerateModelOpenClasses() {
public void setGenerateModelOpenClasses(Boolean generateModelOpenClasses) {
this.generateModelOpenClasses = generateModelOpenClasses;
}

@Input
@Optional
@Override
public Boolean isInitializeNullableTypes() {
return initializeNullableTypes;
}

public void setInitializeNullableTypes(Boolean initializeNullableTypes) {
this.initializeNullableTypes = initializeNullableTypes;
}

@Input
@Optional
@Override
public Boolean isGenerateSealedInterfaces() {
return generateSealedInterfaces;
}

public void setGenerateSealedInterfaces(Boolean generateSealedInterfaces) {
this.generateSealedInterfaces = generateSealedInterfaces;
}

@Input
@Optional
@Override
public Boolean isSupportUnknownFields() {
return supportUnknownFields;
}

public void setSupportUnknownFields(boolean supportUnknownFields) {
this.supportUnknownFields = supportUnknownFields;
}

@Input
@Optional
@Override
public String getUnknownFieldsPropertyName() {
return unknownFieldsPropertyName;
}

public void setUnknownFieldsPropertyName(String unknownFieldsPropertyName) {
this.unknownFieldsPropertyName = unknownFieldsPropertyName;
}


}
2 changes: 1 addition & 1 deletion plugins/maven/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<plugin>
<groupId>io.github.kobylynskyi</groupId>
<artifactId>graphql-codegen-maven-plugin</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
<executions>
<execution>
<goals>
Expand Down
2 changes: 1 addition & 1 deletion plugins/maven/example-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>io.github.kobylynskyi</groupId>
<artifactId>graphql-codegen-maven-plugin-example-client</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
<name>graphql-codegen-maven-plugin-example-client</name>

<build>
Expand Down
2 changes: 1 addition & 1 deletion plugins/maven/example-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>io.github.kobylynskyi</groupId>
<artifactId>graphql-codegen-maven-plugin-example-server</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
<name>graphql-codegen-maven-plugin-example-server</name>

<build>
Expand Down
4 changes: 2 additions & 2 deletions plugins/maven/graphql-java-codegen-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>io.github.kobylynskyi</groupId>
<artifactId>graphql-codegen-maven-plugin</artifactId>
<version>5.3.1-SNAPSHOT</version>
<version>5.4.0</version>
<packaging>maven-plugin</packaging>

<name>graphql-codegen-maven-plugin</name>
Expand Down Expand Up @@ -72,7 +72,7 @@
<version.maven-gpg-plugin>3.0.1</version.maven-gpg-plugin>
<version.maven-shared-utils>3.3.4</version.maven-shared-utils>

<version.graphql-java-codegen>5.3.0</version.graphql-java-codegen>
<version.graphql-java-codegen>5.4.0</version.graphql-java-codegen>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ public class GraphQLCodegenMojo extends AbstractMojo implements GraphQLCodegenCo
@Parameter
private String[] configurationFiles;

@Parameter(defaultValue = MappingConfigConstants.DEFAULT_SUPPORT_UNKNOWN_FIELDS_STRING)
private boolean supportUnknownFields;

@Parameter(defaultValue = MappingConfigConstants.DEFAULT_UNKNOWN_FIELDS_PROPERTY_NAME)
private String unknownFieldsPropertyName;

/**
* The project being built.
*/
Expand All @@ -209,6 +215,12 @@ public class GraphQLCodegenMojo extends AbstractMojo implements GraphQLCodegenCo
@Parameter(defaultValue = MappingConfigConstants.DEFAULT_GENERATE_MODEL_OPEN_CLASSES_STRING)
private boolean generateModelOpenClasses;

@Parameter(defaultValue = MappingConfigConstants.DEFAULT_INITIALIZE_NULLABLE_TYPES_STRING)
private boolean initializeNullableTypes;

@Parameter(defaultValue = MappingConfigConstants.DEFAULT_GENERATE_SEALED_INTERFACES_STRING)
private boolean generateSealedInterfaces;

@Override
public void execute() throws MojoExecutionException {
addCompileSourceRootIfConfigured();
Expand Down Expand Up @@ -267,6 +279,11 @@ public void execute() throws MojoExecutionException {

mappingConfig.setGeneratedLanguage(generatedLanguage);
mappingConfig.setGenerateModelOpenClasses(isGenerateModelOpenClasses());
mappingConfig.setInitializeNullableTypes(isInitializeNullableTypes());
mappingConfig.setGenerateSealedInterfaces(isGenerateSealedInterfaces());

mappingConfig.setSupportUnknownFields(isSupportUnknownFields());
mappingConfig.setUnknownFieldsPropertyName(getUnknownFieldsPropertyName());

try {
instantiateCodegen(mappingConfig).generate();
Expand Down Expand Up @@ -603,6 +620,16 @@ public Boolean isGenerateModelOpenClasses() {
return generateModelOpenClasses;
}

@Override
public Boolean isInitializeNullableTypes() {
return initializeNullableTypes;
}

@Override
public Boolean isGenerateSealedInterfaces() {
return generateSealedInterfaces;
}

public ParentInterfacesConfig getParentInterfaces() {
return parentInterfaces;
}
Expand All @@ -611,6 +638,24 @@ public String[] getConfigurationFiles() {
return configurationFiles;
}

@Override
public Boolean isSupportUnknownFields() {
return supportUnknownFields;
}

public void setSupportUnknownFields(boolean supportUnknownFields) {
this.supportUnknownFields = supportUnknownFields;
}

@Override
public String getUnknownFieldsPropertyName() {
return unknownFieldsPropertyName;
}

public void setUnknownFieldsPropertyName(String unknownFieldsPropertyName) {
this.unknownFieldsPropertyName = unknownFieldsPropertyName;
}

private static Map<String, List<String>> convertToListsMap(Map<String, Properties> sourceMap) {
if (sourceMap == null) {
return new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ trait GraphQLCodegenKeys {

val generateModelOpenClasses = settingKey[Boolean]("The class type of the generated model. If true, generate normal classes, else generate case class.")

val generateSealedInterfaces = settingKey[Boolean]("If true, generate sealed interfaces for GraphQL unions and interfaces, else generate normal interfaces.")

val generateJacksonTypeIdResolver = settingKey[Boolean]("Specifies whether generated union interfaces should be annotated with a custom Jackson type id resolver generated in model package")

//for version
Expand All @@ -133,4 +135,7 @@ trait GraphQLCodegenKeys {
//some others for sbt
val generateCodegenTargetPath = settingKey[File]("Where to store generated files and add the generated code to the classpath, so that they can be referenced.")

val supportUnknownFields = settingKey[Boolean]("supportUnknownFields")
val unknownFieldsPropertyName = settingKey[String]("unknownFieldsPropertyName")

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class GraphQLCodegenPlugin(configuration: Configuration, private[codegen] val co
graphqlJavaCodegenVersion := None,
// suffix/prefix/strategies:
generateModelOpenClasses := MappingConfigConstants.DEFAULT_GENERATE_MODEL_OPEN_CLASSES,
generateSealedInterfaces := MappingConfigConstants.DEFAULT_GENERATE_SEALED_INTERFACES,
generatedLanguage := MappingConfigConstants.DEFAULT_GENERATED_LANGUAGE,
apiNamePrefix := None,
apiNameSuffix := MappingConfigConstants.DEFAULT_RESOLVER_SUFFIX,
Expand Down Expand Up @@ -116,7 +117,10 @@ class GraphQLCodegenPlugin(configuration: Configuration, private[codegen] val co
// parent interfaces configs:
parentInterfaces := parentInterfacesConfig,
generateAllMethodInProjection := MappingConfigConstants.DEFAULT_GENERATE_ALL_METHOD,
responseProjectionMaxDepth := MappingConfigConstants.DEFAULT_RESPONSE_PROJECTION_MAX_DEPTH
responseProjectionMaxDepth := MappingConfigConstants.DEFAULT_RESPONSE_PROJECTION_MAX_DEPTH,

supportUnknownFields := MappingConfigConstants.DEFAULT_SUPPORT_UNKNOWN_FIELDS,
unknownFieldsPropertyName := MappingConfigConstants.DEFAULT_UNKNOWN_FIELDS_PROPERTY_NAME
)

private def getMappingConfig(): Def.Initialize[MappingConfig] = Def.setting {
Expand Down Expand Up @@ -171,6 +175,10 @@ class GraphQLCodegenPlugin(configuration: Configuration, private[codegen] val co
mappingConfig.setGeneratedLanguage((generatedLanguage in GraphQLCodegenConfig).value)
mappingConfig.setGenerateModelOpenClasses((generateModelOpenClasses in GraphQLCodegenConfig).value)
mappingConfig.setGenerateJacksonTypeIdResolver((generateJacksonTypeIdResolver in GraphQLCodegenConfig).value);

mappingConfig.setSupportUnknownFields((supportUnknownFields in GraphQLCodegenConfig).value)
mappingConfig.setUnknownFieldsPropertyName((unknownFieldsPropertyName in GraphQLCodegenConfig).value)

mappingConfig
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.3.0")
addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.4.0")
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "5.3.0"
version in ThisBuild := "5.4.0"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.3.0")
addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.4.0")
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "5.3.0"
version in ThisBuild := "5.4.0"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sys.props.get("plugin.version").orElse(Some("5.3.0")) match {
sys.props.get("plugin.version").orElse(Some("5.4.0")) match {
case Some(x) => addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % x)
case _ => sys.error("""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "5.3.0"
version in ThisBuild := "5.4.0"
Loading