From e3173639c3a1c64b92322f527f99e1f483d349aa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 May 2022 07:05:31 +0000 Subject: [PATCH] Bump graphql-java-extended-scalars from 18.0 to 18.1 Bumps [graphql-java-extended-scalars](https://github.com/graphql-java/graphql-java-extended-scalars) from 18.0 to 18.1. - [Release notes](https://github.com/graphql-java/graphql-java-extended-scalars/releases) - [Commits](https://github.com/graphql-java/graphql-java-extended-scalars/compare/v18.0...v18.1) --- updated-dependencies: - dependency-name: com.graphql-java:graphql-java-extended-scalars dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .../graphql/execution/LeakyCauldronHooks.kt | 18 +++++++++++++++++- .../execution/LeakyCauldronHooksTest.kt | 10 +++++----- .../com/trib3/json/ObjectMapperProvider.kt | 4 ++-- parent-pom/pom.xml | 2 +- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/graphql/src/main/kotlin/com/trib3/graphql/execution/LeakyCauldronHooks.kt b/graphql/src/main/kotlin/com/trib3/graphql/execution/LeakyCauldronHooks.kt index 777d77537..56c9ba047 100644 --- a/graphql/src/main/kotlin/com/trib3/graphql/execution/LeakyCauldronHooks.kt +++ b/graphql/src/main/kotlin/com/trib3/graphql/execution/LeakyCauldronHooks.kt @@ -22,6 +22,8 @@ import java.time.OffsetDateTime import java.time.Year import java.time.YearMonth import java.time.format.DateTimeFormatter +import java.time.format.DateTimeFormatterBuilder +import java.time.temporal.ChronoField import java.util.UUID import javax.annotation.Nullable import javax.inject.Inject @@ -137,6 +139,20 @@ internal val LOCAL_DATETIME_SCALAR = GraphQLScalarType.newScalar() ) .coercing( object : Coercing { + // define iso formatter with required fractional seconds per https://www.graphql-scalars.com/date-time/ + @Suppress("MagicNumber") // const expression + private val ISO_FORMATTER = DateTimeFormatterBuilder() + .parseCaseInsensitive() + .append(DateTimeFormatter.ISO_LOCAL_DATE) + .appendLiteral('T') + .appendValue(ChronoField.HOUR_OF_DAY, 2) + .appendLiteral(':') + .appendValue(ChronoField.MINUTE_OF_HOUR, 2) + .appendLiteral(':') + .appendValue(ChronoField.SECOND_OF_MINUTE, 2) + .appendFraction(ChronoField.NANO_OF_SECOND, 3, 3, true) + .toFormatter() + private fun parse(input: String, exceptionConstructor: (String, Throwable) -> Exception): LocalDateTime { return try { LocalDateTime.parse(input) @@ -158,7 +174,7 @@ internal val LOCAL_DATETIME_SCALAR = GraphQLScalarType.newScalar() override fun serialize(dataFetcherResult: Any): String { return when (dataFetcherResult) { - is LocalDateTime -> DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(dataFetcherResult) + is LocalDateTime -> ISO_FORMATTER.format(dataFetcherResult) else -> throw CoercingSerializeException("can't serialize ${dataFetcherResult::class}") } } diff --git a/graphql/src/test/kotlin/com/trib3/graphql/execution/LeakyCauldronHooksTest.kt b/graphql/src/test/kotlin/com/trib3/graphql/execution/LeakyCauldronHooksTest.kt index 6004969bb..6a3f60f5d 100644 --- a/graphql/src/test/kotlin/com/trib3/graphql/execution/LeakyCauldronHooksTest.kt +++ b/graphql/src/test/kotlin/com/trib3/graphql/execution/LeakyCauldronHooksTest.kt @@ -171,7 +171,7 @@ class LeakyCauldronHooksTest { fun testLocalDateTime() { val result = graphQL.execute("""query {localDateTime(l:"2019-10-30T00:01")}""") .getData>() - assertThat(result["localDateTime"]).isEqualTo("2019-10-31T01:01:00") + assertThat(result["localDateTime"]).isEqualTo("2019-10-31T01:01:00.000") assertValidationErrors("""query {localDateTime(l:123)}""", """query {localDateTime(l:"123")}""") assertThat { @@ -180,7 +180,7 @@ class LeakyCauldronHooksTest { assertThat { LOCAL_DATETIME_SCALAR.coercing.serialize(LocalDateTime.of(2019, 10, 31, 1, 1)) - }.isSuccess().isEqualTo("2019-10-31T01:01:00") + }.isSuccess().isEqualTo("2019-10-31T01:01:00.000") } @Test @@ -190,7 +190,7 @@ class LeakyCauldronHooksTest { .query("""query(${'$'}input: LocalDateTime!) {localDateTime(l:${'$'}input)}""") .variables(mapOf("input" to "2019-10-30T00:01")).build() ).getData>() - assertThat(result["localDateTime"]).isEqualTo("2019-10-31T01:01:00") + assertThat(result["localDateTime"]).isEqualTo("2019-10-31T01:01:00.000") } @Test @@ -233,7 +233,7 @@ class LeakyCauldronHooksTest { fun testOffsetDateTime() { val result = graphQL.execute("""query {offsetDateTime(o:"2019-10-30T00:01-07:00")}""") .getData>() - assertThat(result["offsetDateTime"]).isEqualTo("2019-10-31T07:01:00Z") + assertThat(result["offsetDateTime"]).isEqualTo("2019-10-31T07:01:00.000Z") assertValidationErrors("""query {offsetDateTime(o:123)}""", """query {offsetDateTime(o:"123")}""") } @@ -244,7 +244,7 @@ class LeakyCauldronHooksTest { .query("""query(${'$'}input: DateTime!) {offsetDateTime(o:${'$'}input)}""") .variables(mapOf("input" to "2019-10-30T00:01-07:00")).build() ).getData>() - assertThat(result["offsetDateTime"]).isEqualTo("2019-10-31T07:01:00Z") + assertThat(result["offsetDateTime"]).isEqualTo("2019-10-31T07:01:00.000Z") } @Test diff --git a/json/src/main/kotlin/com/trib3/json/ObjectMapperProvider.kt b/json/src/main/kotlin/com/trib3/json/ObjectMapperProvider.kt index fae3a27fa..e57fe48e4 100644 --- a/json/src/main/kotlin/com/trib3/json/ObjectMapperProvider.kt +++ b/json/src/main/kotlin/com/trib3/json/ObjectMapperProvider.kt @@ -8,7 +8,7 @@ import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair import com.fasterxml.jackson.module.guice.GuiceAnnotationIntrospector import com.fasterxml.jackson.module.guice.GuiceInjectableValues -import com.fasterxml.jackson.module.kotlin.KotlinModule +import com.fasterxml.jackson.module.kotlin.registerKotlinModule import com.google.inject.Injector import com.trib3.json.ObjectMapperProvider.Companion.OBJECT_MAPPER_MIXINS import com.trib3.json.jackson.ThreeTenExtraModule @@ -49,7 +49,7 @@ class ObjectMapperProvider @Inject constructor( mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) mapper.disable(DeserializationFeature.FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY) mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) - mapper.registerModule(KotlinModule.Builder().build()) + mapper.registerKotlinModule() mapper.registerModule(MetricsModule(TimeUnit.SECONDS, TimeUnit.SECONDS, false)) mapper.registerModule(ThreeTenExtraModule()) diff --git a/parent-pom/pom.xml b/parent-pom/pom.xml index b9cb95b95..e08f35c7b 100644 --- a/parent-pom/pom.xml +++ b/parent-pom/pom.xml @@ -69,7 +69,7 @@ 8.5.10 5.4.1 17.3 - 18.0 + 18.1 5.2.4 3.1.2 6.1.3