Skip to content

Commit

Permalink
customTypesMapping and directiveAnnotationsMapping replace enumer…
Browse files Browse the repository at this point in the history
…ation values when used together (#1298)

* test on kotlin is ok

* fix style

* 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](apache/maven@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] <support@github.com>
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](apache/maven@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] <support@github.com>
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](spring-projects/spring-boot@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] <support@github.com>
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](spring-projects/spring-boot@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] <support@github.com>
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](spring-projects/spring-boot@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] <support@github.com>
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](spring-projects/spring-boot@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] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Bogdan Kobylynskyi <92bogdan@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 8, 2023
1 parent 37ffc68 commit e6f58ec
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
Expand Down Expand Up @@ -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<String, String> customTypesMapping = mappingContext.getCustomTypesMapping();
if (customTypesMapping.containsKey(value.getName())) {
return customTypesMapping.get(value.getName());
}

return value.getName();
}
if (graphQLType instanceof TypeName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,21 @@ 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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit e6f58ec

Please sign in to comment.