From e6629f813312a9559af4d4fea1bfa4f81504e0a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A6=E5=A2=83=E8=BF=B7=E7=A6=BB?= Date: Sat, 5 Aug 2023 21:35:08 +0800 Subject: [PATCH 1/3] test on kotlin is ok --- .../graphql/codegen/mapper/ValueMapper.java | 6 ++++++ .../kotlin/GraphQLCodegenAnnotationsTest.java | 13 +++++++++++++ .../kt/customTypesMapping-directive.graphqls | 10 ++++++++++ 3 files changed, 29 insertions(+) create mode 100644 src/test/resources/schemas/kt/customTypesMapping-directive.graphqls diff --git a/src/main/java/com/kobylynskyi/graphql/codegen/mapper/ValueMapper.java b/src/main/java/com/kobylynskyi/graphql/codegen/mapper/ValueMapper.java index 87f161d12..e4702f9f1 100644 --- a/src/main/java/com/kobylynskyi/graphql/codegen/mapper/ValueMapper.java +++ b/src/main/java/com/kobylynskyi/graphql/codegen/mapper/ValueMapper.java @@ -17,6 +17,7 @@ import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -122,6 +123,11 @@ public String map(MappingContext mappingContext, Value value, Type graphQL private String mapEnum(MappingContext mappingContext, EnumValue value, Type graphQLType) { if (graphQLType == null) { + Map customTypesMapping = mappingContext.getCustomTypesMapping(); + if(customTypesMapping.containsKey(value.getName())) { + return customTypesMapping.get(value.getName()); + } + return value.getName(); } if (graphQLType instanceof TypeName) { diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenAnnotationsTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenAnnotationsTest.java index 127abb4f7..ee416a9d8 100644 --- a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenAnnotationsTest.java +++ b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenAnnotationsTest.java @@ -119,6 +119,19 @@ void generate_CustomAnnotationMappings_FieldType() throws Exception { " val createdDateTime: org.joda.time.DateTime?"); } + @Test + void generate_CustomAnnotationMappings_With_Annotations() throws Exception { + mappingConfig.setCustomTypesMapping(new HashMap<>(singletonMap("CAMS", "com.intuit.identity.manage.enum.CamsGroup::class"))); + mappingConfig.setDirectiveAnnotationsMapping(new HashMap<>(singletonMap("NotNull", + singletonList("@javax.validation.constraints.NotNull(message = {{message}}, groups = {{groups}})")))); + + generate("src/test/resources/schemas/kt/customTypesMapping-directive.graphqls"); + + File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles()); + assertFileContainsElements(files, "TrustAccountInput.kt", + "@field:javax.validation.constraints.NotNull(message = \"test\", groups = com.intuit.identity.manage.enum.CamsGroup::class)"); + } + private void generate(String path) throws IOException { new KotlinGraphQLCodegen(singletonList(path), outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate(); diff --git a/src/test/resources/schemas/kt/customTypesMapping-directive.graphqls b/src/test/resources/schemas/kt/customTypesMapping-directive.graphqls new file mode 100644 index 000000000..c500183a6 --- /dev/null +++ b/src/test/resources/schemas/kt/customTypesMapping-directive.graphqls @@ -0,0 +1,10 @@ +directive @NotNull(message : String, groups: ValidationGroup) on INPUT_FIELD_DEFINITION + +schema { + query: Query +} + +input TrustAccountInput +{ + accountId: String! @NotNull(message: "test", groups: CAMS) +} \ No newline at end of file From 0b7faf693b1764b5473e874ae380874f9889f3f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A6=E5=A2=83=E8=BF=B7=E7=A6=BB?= Date: Sat, 5 Aug 2023 21:49:37 +0800 Subject: [PATCH 2/3] fix style --- .../com/kobylynskyi/graphql/codegen/mapper/ValueMapper.java | 2 +- .../codegen/kotlin/GraphQLCodegenAnnotationsTest.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/kobylynskyi/graphql/codegen/mapper/ValueMapper.java b/src/main/java/com/kobylynskyi/graphql/codegen/mapper/ValueMapper.java index e4702f9f1..aa187a18b 100644 --- a/src/main/java/com/kobylynskyi/graphql/codegen/mapper/ValueMapper.java +++ b/src/main/java/com/kobylynskyi/graphql/codegen/mapper/ValueMapper.java @@ -124,7 +124,7 @@ public String map(MappingContext mappingContext, Value value, Type graphQL private String mapEnum(MappingContext mappingContext, EnumValue value, Type graphQLType) { if (graphQLType == null) { Map customTypesMapping = mappingContext.getCustomTypesMapping(); - if(customTypesMapping.containsKey(value.getName())) { + if (customTypesMapping.containsKey(value.getName())) { return customTypesMapping.get(value.getName()); } diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenAnnotationsTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenAnnotationsTest.java index ee416a9d8..fa86b3c28 100644 --- a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenAnnotationsTest.java +++ b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenAnnotationsTest.java @@ -121,7 +121,8 @@ void generate_CustomAnnotationMappings_FieldType() throws Exception { @Test void generate_CustomAnnotationMappings_With_Annotations() throws Exception { - mappingConfig.setCustomTypesMapping(new HashMap<>(singletonMap("CAMS", "com.intuit.identity.manage.enum.CamsGroup::class"))); + mappingConfig.setCustomTypesMapping(new HashMap<>( + singletonMap("CAMS", "com.intuit.identity.manage.enum.CamsGroup::class"))); mappingConfig.setDirectiveAnnotationsMapping(new HashMap<>(singletonMap("NotNull", singletonList("@javax.validation.constraints.NotNull(message = {{message}}, groups = {{groups}})")))); @@ -129,7 +130,8 @@ void generate_CustomAnnotationMappings_With_Annotations() throws Exception { File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles()); assertFileContainsElements(files, "TrustAccountInput.kt", - "@field:javax.validation.constraints.NotNull(message = \"test\", groups = com.intuit.identity.manage.enum.CamsGroup::class)"); + "@field:javax.validation.constraints.NotNull(message = \"test\", " + + "groups = com.intuit.identity.manage.enum.CamsGroup::class)"); } private void generate(String path) throws IOException { From 41b4d381dbf7eb87e68c678fbcbfd3018fcaa58b Mon Sep 17 00:00:00 2001 From: Bogdan Kobylynskyi <92bogdan@gmail.com> Date: Tue, 8 Aug 2023 18:25:10 +0300 Subject: [PATCH 3/3] Pull all changes from the latest main (#1303) * Revert sonar version back to 4.0.0.2929 * Revert graphql-java back to 20.2 (#1302) * Bump org.apache.maven:maven-core (#1301) Bumps [org.apache.maven:maven-core](https://github.com/apache/maven) from 3.9.3 to 3.9.4. - [Release notes](https://github.com/apache/maven/releases) - [Commits](https://github.com/apache/maven/compare/maven-3.9.3...maven-3.9.4) --- updated-dependencies: - dependency-name: org.apache.maven:maven-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump org.apache.maven:maven-plugin-api (#1300) Bumps [org.apache.maven:maven-plugin-api](https://github.com/apache/maven) from 3.9.3 to 3.9.4. - [Release notes](https://github.com/apache/maven/releases) - [Commits](https://github.com/apache/maven/compare/maven-3.9.3...maven-3.9.4) --- updated-dependencies: - dependency-name: org.apache.maven:maven-plugin-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump org.springframework.boot:spring-boot-starter-data-mongodb (#1296) Bumps [org.springframework.boot:spring-boot-starter-data-mongodb](https://github.com/spring-projects/spring-boot) from 2.7.13 to 2.7.14. - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v2.7.13...v2.7.14) --- updated-dependencies: - dependency-name: org.springframework.boot:spring-boot-starter-data-mongodb dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump org.springframework.boot:spring-boot-starter-data-mongodb (#1295) Bumps [org.springframework.boot:spring-boot-starter-data-mongodb](https://github.com/spring-projects/spring-boot) from 2.7.13 to 2.7.14. - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v2.7.13...v2.7.14) --- updated-dependencies: - dependency-name: org.springframework.boot:spring-boot-starter-data-mongodb dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump org.springframework.boot:spring-boot-starter-data-mongodb (#1292) Bumps [org.springframework.boot:spring-boot-starter-data-mongodb](https://github.com/spring-projects/spring-boot) from 2.7.13 to 2.7.14. - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v2.7.13...v2.7.14) --- updated-dependencies: - dependency-name: org.springframework.boot:spring-boot-starter-data-mongodb dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump org.springframework.boot:spring-boot-starter-web (#1291) Bumps [org.springframework.boot:spring-boot-starter-web](https://github.com/spring-projects/spring-boot) from 2.7.13 to 2.7.14. - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v2.7.13...v2.7.14) --- updated-dependencies: - dependency-name: org.springframework.boot:spring-boot-starter-web dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 4 ++-- plugins/gradle/example-server/build.gradle | 2 +- .../gradle/graphql-java-codegen-gradle-plugin/build.gradle | 2 +- plugins/maven/example-client/pom.xml | 2 +- plugins/maven/example-server/pom.xml | 4 ++-- plugins/maven/graphql-java-codegen-maven-plugin/pom.xml | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 8aad9b09e..2e11e264a 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { id "java-library" id "signing" id "maven-publish" - id "org.sonarqube" version "4.3.0.3225" + id "org.sonarqube" version "4.0.0.2929" } def graphqlCodegenVersion = '5.8.1-SNAPSHOT' // This variable used in the automatic release process @@ -20,7 +20,7 @@ repositories { dependencies { compileOnly "org.freemarker:freemarker:2.3.32" - compileOnly "com.graphql-java:graphql-java:21.0" + compileOnly "com.graphql-java:graphql-java:20.2" compileOnly "com.fasterxml.jackson.core:jackson-databind:2.15.2" compileOnly "com.typesafe:config:1.4.2" diff --git a/plugins/gradle/example-server/build.gradle b/plugins/gradle/example-server/build.gradle index 5f12f23b7..1e548a470 100644 --- a/plugins/gradle/example-server/build.gradle +++ b/plugins/gradle/example-server/build.gradle @@ -13,7 +13,7 @@ mainClassName = "io.github.kobylynskyi.product.Application" dependencies { implementation "org.springframework.boot:spring-boot-starter-web:2.7.14" - implementation "org.springframework.boot:spring-boot-starter-data-mongodb:2.7.13" + implementation "org.springframework.boot:spring-boot-starter-data-mongodb:2.7.14" implementation "com.graphql-java-kickstart:graphql-spring-boot-starter:11.0.0" implementation "com.graphql-java-kickstart:graphiql-spring-boot-starter:11.1.0" diff --git a/plugins/gradle/graphql-java-codegen-gradle-plugin/build.gradle b/plugins/gradle/graphql-java-codegen-gradle-plugin/build.gradle index d4ecadeb8..662558d80 100644 --- a/plugins/gradle/graphql-java-codegen-gradle-plugin/build.gradle +++ b/plugins/gradle/graphql-java-codegen-gradle-plugin/build.gradle @@ -27,7 +27,7 @@ dependencies { implementation "io.github.kobylynskyi:graphql-java-codegen:${version}" implementation "org.freemarker:freemarker:2.3.32" - implementation "com.graphql-java:graphql-java:21.0" + implementation "com.graphql-java:graphql-java:20.2" implementation "com.fasterxml.jackson.core:jackson-databind:2.15.2" implementation "com.typesafe:config:1.4.2" diff --git a/plugins/maven/example-client/pom.xml b/plugins/maven/example-client/pom.xml index 35e794736..19477a584 100644 --- a/plugins/maven/example-client/pom.xml +++ b/plugins/maven/example-client/pom.xml @@ -128,7 +128,7 @@ org.springframework.boot spring-boot-starter-data-mongodb - 2.7.13 + 2.7.14 diff --git a/plugins/maven/example-server/pom.xml b/plugins/maven/example-server/pom.xml index 97f8eb3d7..7c8a95cb7 100644 --- a/plugins/maven/example-server/pom.xml +++ b/plugins/maven/example-server/pom.xml @@ -76,12 +76,12 @@ org.springframework.boot spring-boot-starter-web - 2.7.13 + 2.7.14 org.springframework.boot spring-boot-starter-data-mongodb - 2.7.13 + 2.7.14 diff --git a/plugins/maven/graphql-java-codegen-maven-plugin/pom.xml b/plugins/maven/graphql-java-codegen-maven-plugin/pom.xml index ea454b7aa..3cacce50e 100644 --- a/plugins/maven/graphql-java-codegen-maven-plugin/pom.xml +++ b/plugins/maven/graphql-java-codegen-maven-plugin/pom.xml @@ -56,8 +56,8 @@ - 3.9.3 - 3.9.3 + 3.9.4 + 3.9.4 3.9.0 3.9.0 3.11.0 @@ -121,7 +121,7 @@ com.graphql-java graphql-java - 21.0 + 20.2 com.fasterxml.jackson.core