Skip to content

Commit f488214

Browse files
authored
Merge pull request #999 from kobylynskyi/develop
5.5.0 Release
2 parents 7364f7d + 7b81f74 commit f488214

File tree

49 files changed

+632
-146
lines changed

Some content is hidden

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

49 files changed

+632
-146
lines changed

.github/workflows/github.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ jobs:
8282

8383
sonar:
8484
needs: build
85+
if: github.event_name != 'pull_request'
8586
runs-on: ubuntu-latest
8687
steps:
8788
- uses: actions/checkout@v2
@@ -117,4 +118,5 @@ jobs:
117118
- name: Generate and publish Sonar report
118119
run: ./gradlew sonarqube -Dsonar.projectKey=kobylynskyi_graphql-java-codegen -Dsonar.organization=kobylynskyi -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_LOGIN }} --stacktrace
119120
env:
120-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
121+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
122+

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.4.1' // This variable used in the automatic release process
12+
def graphqlCodegenVersion = '5.5.0' // This variable used in the automatic release process
1313

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

docs/codegen-options.md

Lines changed: 92 additions & 93 deletions
Large diffs are not rendered by default.

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.4.1"
20+
id "io.github.kobylynskyi.graphql.codegen" version "5.5.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.4.1"
34+
classpath "io.github.kobylynskyi.graphql.codegen:graphql-codegen-gradle-plugin:5.5.0"
3535
}
3636
}
3737

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

Lines changed: 3 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.6.21"
7-
id "io.github.kobylynskyi.graphql.codegen" version "5.4.1"
7+
id "io.github.kobylynskyi.graphql.codegen" version "5.5.0"
88
}
99

10-
def graphqlCodegenClientKotlinVersion = '5.4.1' // Variable used in the automatic release process
10+
def graphqlCodegenClientKotlinVersion = '5.5.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.4.1"
32+
implementation "io.github.kobylynskyi:graphql-java-codegen:5.5.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.13.3"

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.4.1"
10+
id "io.github.kobylynskyi.graphql.codegen" version "5.5.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.4.1"
25+
implementation "io.github.kobylynskyi:graphql-java-codegen:5.5.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: 1 addition & 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.4.1"
9+
id "io.github.kobylynskyi.graphql.codegen" version "5.5.0"
1010
}
1111

1212
mainClassName = "io.github.kobylynskyi.product.Application"

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.4.1' // This variable used in the automatic release process
19+
def graphqlCodegenGradlePluginVersion = '5.5.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: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ public class GraphQLCodegenGradleTask extends DefaultTask implements GraphQLCode
8787
private Set<String> fieldsWithResolvers = new HashSet<>();
8888
private Set<String> fieldsWithoutResolvers = new HashSet<>();
8989
private Set<String> typesAsInterfaces = new HashSet<>();
90+
private Set<String> resolverArgumentAnnotations = new HashSet<>();
91+
private Set<String> parametrizedResolverAnnotations = new HashSet<>();
9092
private final RelayConfig relayConfig = new RelayConfig();
9193

9294

@@ -109,6 +111,8 @@ public class GraphQLCodegenGradleTask extends DefaultTask implements GraphQLCode
109111
private Boolean supportUnknownFields = MappingConfigConstants.DEFAULT_SUPPORT_UNKNOWN_FIELDS;
110112
private String unknownFieldsPropertyName = MappingConfigConstants.DEFAULT_UNKNOWN_FIELDS_PROPERTY_NAME;
111113

114+
private Boolean skip = false;
115+
112116
public GraphQLCodegenGradleTask() {
113117
setGroup("codegen");
114118
setDescription("Generates Java POJOs and interfaces based on GraphQL schemas");
@@ -164,6 +168,10 @@ public void generate() throws Exception {
164168
fieldsWithoutResolvers != null ? fieldsWithoutResolvers : new HashSet<>());
165169
mappingConfig.setTypesAsInterfaces(
166170
typesAsInterfaces != null ? typesAsInterfaces : new HashSet<>());
171+
mappingConfig.setResolverArgumentAnnotations(
172+
resolverArgumentAnnotations != null ? resolverArgumentAnnotations : new HashSet<>());
173+
mappingConfig.setParametrizedResolverAnnotations(
174+
parametrizedResolverAnnotations != null ? parametrizedResolverAnnotations : new HashSet<>());
167175
mappingConfig.setRelayConfig(relayConfig);
168176

169177
mappingConfig.setGenerateClient(generateClient);
@@ -188,6 +196,11 @@ public void generate() throws Exception {
188196
mappingConfig.setSupportUnknownFields(isSupportUnknownFields());
189197
mappingConfig.setUnknownFieldsPropertyName(getUnknownFieldsPropertyName());
190198

199+
if (Boolean.TRUE.equals(skip)) {
200+
getLogger().info("Skipping code generation");
201+
return;
202+
}
203+
191204
instantiateCodegen(mappingConfig).generate();
192205
}
193206

@@ -689,6 +702,28 @@ public void setTypesAsInterfaces(Set<String> typesAsInterfaces) {
689702
this.typesAsInterfaces = typesAsInterfaces;
690703
}
691704

705+
@Input
706+
@Optional
707+
@Override
708+
public Set<String> getResolverArgumentAnnotations() {
709+
return resolverArgumentAnnotations;
710+
}
711+
712+
public void setResolverArgumentAnnotations(Set<String> resolverArgumentAnnotations) {
713+
this.resolverArgumentAnnotations = resolverArgumentAnnotations;
714+
}
715+
716+
@Input
717+
@Optional
718+
@Override
719+
public Set<String> getParametrizedResolverAnnotations() {
720+
return parametrizedResolverAnnotations;
721+
}
722+
723+
public void setParametrizedResolverAnnotations(Set<String> parametrizedResolverAnnotations) {
724+
this.parametrizedResolverAnnotations = parametrizedResolverAnnotations;
725+
}
726+
692727
@Nested
693728
@Optional
694729
@Override
@@ -897,6 +932,15 @@ public String getUnknownFieldsPropertyName() {
897932
public void setUnknownFieldsPropertyName(String unknownFieldsPropertyName) {
898933
this.unknownFieldsPropertyName = unknownFieldsPropertyName;
899934
}
900-
935+
936+
@Input
937+
@Optional
938+
public Boolean isSkip() {
939+
return skip;
940+
}
941+
942+
public void setSkip(Boolean skip) {
943+
this.skip = skip;
944+
}
901945

902946
}

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.4.1</version>
23+
<version>5.5.0</version>
2424
<executions>
2525
<execution>
2626
<goals>

plugins/maven/example-client/pom.xml

Lines changed: 1 addition & 1 deletion
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.4.1</version>
7+
<version>5.5.0</version>
88
<name>graphql-codegen-maven-plugin-example-client</name>
99

1010
<build>

plugins/maven/example-server/pom.xml

Lines changed: 1 addition & 1 deletion
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.4.1</version>
7+
<version>5.5.0</version>
88
<name>graphql-codegen-maven-plugin-example-server</name>
99

1010
<build>

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

Lines changed: 2 additions & 2 deletions
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.4.1</version>
6+
<version>5.5.0</version>
77
<packaging>maven-plugin</packaging>
88

99
<name>graphql-codegen-maven-plugin</name>
@@ -72,7 +72,7 @@
7272
<version.maven-gpg-plugin>3.0.1</version.maven-gpg-plugin>
7373
<version.maven-shared-utils>3.3.4</version.maven-shared-utils>
7474

75-
<version.graphql-java-codegen>5.4.1</version.graphql-java-codegen>
75+
<version.graphql-java-codegen>5.5.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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ public class GraphQLCodegenMojo extends AbstractMojo implements GraphQLCodegenCo
185185
@Parameter
186186
private String[] typesAsInterfaces;
187187

188+
@Parameter
189+
private String[] resolverArgumentAnnotations;
190+
191+
@Parameter
192+
private String[] parametrizedResolverAnnotations;
193+
188194
@Parameter(defaultValue = MappingConfigConstants.DEFAULT_RESPONSE_PROJECTION_MAX_DEPTH_STRING)
189195
private int responseProjectionMaxDepth;
190196

@@ -221,6 +227,9 @@ public class GraphQLCodegenMojo extends AbstractMojo implements GraphQLCodegenCo
221227
@Parameter(defaultValue = MappingConfigConstants.DEFAULT_GENERATE_SEALED_INTERFACES_STRING)
222228
private boolean generateSealedInterfaces;
223229

230+
@Parameter(defaultValue = "false")
231+
private boolean skip;
232+
224233
@Override
225234
public void execute() throws MojoExecutionException {
226235
addCompileSourceRootIfConfigured();
@@ -271,6 +280,8 @@ public void execute() throws MojoExecutionException {
271280
mappingConfig.setResponseProjectionMaxDepth(responseProjectionMaxDepth);
272281
mappingConfig.setUseObjectMapperForRequestSerialization(mapToHashSet(useObjectMapperForRequestSerialization));
273282
mappingConfig.setTypesAsInterfaces(mapToHashSet(typesAsInterfaces));
283+
mappingConfig.setResolverArgumentAnnotations(mapToHashSet(resolverArgumentAnnotations));
284+
mappingConfig.setParametrizedResolverAnnotations(mapToHashSet(parametrizedResolverAnnotations));
274285

275286
mappingConfig.setResolverParentInterface(getResolverParentInterface());
276287
mappingConfig.setQueryResolverParentInterface(getQueryResolverParentInterface());
@@ -285,6 +296,11 @@ public void execute() throws MojoExecutionException {
285296
mappingConfig.setSupportUnknownFields(isSupportUnknownFields());
286297
mappingConfig.setUnknownFieldsPropertyName(getUnknownFieldsPropertyName());
287298

299+
if (skip) {
300+
getLog().info("Skipping code generation");
301+
return;
302+
}
303+
288304
try {
289305
instantiateCodegen(mappingConfig).generate();
290306
} catch (Exception e) {
@@ -590,6 +606,16 @@ public Set<String> getTypesAsInterfaces() {
590606
return mapToHashSet(typesAsInterfaces);
591607
}
592608

609+
@Override
610+
public Set<String> getResolverArgumentAnnotations() {
611+
return mapToHashSet(resolverArgumentAnnotations);
612+
}
613+
614+
@Override
615+
public Set<String> getParametrizedResolverAnnotations() {
616+
return mapToHashSet(parametrizedResolverAnnotations);
617+
}
618+
593619
@Override
594620
public String getQueryResolverParentInterface() {
595621
return parentInterfaces.getQueryResolver();

plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/GraphQLCodegenPlugin.scala

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ class GraphQLCodegenPlugin(configuration: Configuration, private[codegen] val co
120120
responseProjectionMaxDepth := MappingConfigConstants.DEFAULT_RESPONSE_PROJECTION_MAX_DEPTH,
121121

122122
supportUnknownFields := MappingConfigConstants.DEFAULT_SUPPORT_UNKNOWN_FIELDS,
123-
unknownFieldsPropertyName := MappingConfigConstants.DEFAULT_UNKNOWN_FIELDS_PROPERTY_NAME
123+
unknownFieldsPropertyName := MappingConfigConstants.DEFAULT_UNKNOWN_FIELDS_PROPERTY_NAME,
124+
125+
skip := false
124126
)
125127

126128
private def getMappingConfig(): Def.Initialize[MappingConfig] = Def.setting {
@@ -234,11 +236,15 @@ class GraphQLCodegenPlugin(configuration: Configuration, private[codegen] val co
234236
throw new LanguageNotSupportedException(language)
235237
}
236238
}
237-
result = instantiateCodegen(getMappingConfig().value).generate.asScala
238-
for (file result) {
239-
sLog.value.info(s"${file.getName}")
239+
if (skip.value) {
240+
sLog.value.info("Skipping code generation")
241+
} else {
242+
result = instantiateCodegen(getMappingConfig().value).generate.asScala
243+
for (file result) {
244+
sLog.value.info(s"${file.getName}")
245+
}
246+
sLog.value.success(s"Total files: ${result.length}")
240247
}
241-
sLog.value.success(s"Total files: ${result.length}")
242248
} catch {
243249
case e: Exception
244250
(logLevel in configuration).?.value.orElse(state.value.get(logLevel.key)) match {
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.4.1")
1+
addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.5.0")
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version in ThisBuild := "5.4.1"
1+
version in ThisBuild := "5.5.0"
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.4.1")
1+
addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.5.0")
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version in ThisBuild := "5.4.1"
1+
version in ThisBuild := "5.5.0"

plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
sys.props.get("plugin.version").orElse(Some("5.4.1")) match {
1+
sys.props.get("plugin.version").orElse(Some("5.5.0")) match {
22
case Some(x) => addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % x)
33
case _ => sys.error("""|The system property 'plugin.version' is not defined.
44
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version in ThisBuild := "5.4.1"
1+
version in ThisBuild := "5.5.0"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version in ThisBuild := "5.4.1"
1+
version in ThisBuild := "5.5.0"

src/main/java/com/kobylynskyi/graphql/codegen/GraphQLCodegen.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.Collection;
2323
import java.util.List;
2424
import java.util.Map;
25+
import java.util.stream.Collectors;
2526

2627
import static java.util.stream.Collectors.toList;
2728

@@ -96,6 +97,15 @@ private static void sanitizeValues(MappingConfig mappingConfig) {
9697
mappingConfig.setModelValidationAnnotation(
9798
Utils.replaceLeadingAtSign(mappingConfig.getModelValidationAnnotation()));
9899

100+
if (mappingConfig.getResolverArgumentAnnotations() != null) {
101+
mappingConfig.setResolverArgumentAnnotations(mappingConfig.getResolverArgumentAnnotations().stream()
102+
.map(Utils::replaceLeadingAtSign).collect(Collectors.toSet()));
103+
}
104+
if (mappingConfig.getParametrizedResolverAnnotations() != null) {
105+
mappingConfig.setParametrizedResolverAnnotations(mappingConfig.getParametrizedResolverAnnotations().stream()
106+
.map(Utils::replaceLeadingAtSign).collect(Collectors.toSet()));
107+
}
108+
99109
Map<String, List<String>> customAnnotationsMapping = mappingConfig.getCustomAnnotationsMapping();
100110
if (customAnnotationsMapping != null) {
101111
for (Map.Entry<String, List<String>> entry : customAnnotationsMapping.entrySet()) {

src/main/java/com/kobylynskyi/graphql/codegen/generators/FreeMarkerTemplateFilesCreator.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import java.io.File;
1111
import java.io.FileWriter;
12+
import java.io.IOException;
1213
import java.nio.file.FileAlreadyExistsException;
1314
import java.util.Map;
1415

@@ -37,12 +38,18 @@ public static File create(MappingContext mappingContext,
3738
String fileName = dataModel.get(DataModelFields.CLASS_NAME) + language.getFileExtension();
3839
File fileOutputDir = getFileTargetDirectory(dataModel, mappingContext.getOutputDirectory());
3940
File javaSourceFile = new File(fileOutputDir, fileName);
41+
4042
try {
4143
if (!javaSourceFile.createNewFile()) {
4244
throw new FileAlreadyExistsException("File already exists: " + javaSourceFile.getPath());
4345
}
46+
} catch (IOException e) {
47+
throw new UnableToCreateFileException(e);
48+
}
49+
50+
try (FileWriter fileWriter = new FileWriter(javaSourceFile)) {
4451
Template template = FreeMarkerTemplatesRegistry.getTemplateWithLang(language, templateType);
45-
template.process(dataModel, new FileWriter(javaSourceFile));
52+
template.process(dataModel, fileWriter);
4653
} catch (Exception e) {
4754
throw new UnableToCreateFileException(e);
4855
}

0 commit comments

Comments
 (0)