Skip to content

Commit

Permalink
Bump graphql-java-extended-scalars from 18.0 to 18.1
Browse files Browse the repository at this point in the history
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](graphql-java/graphql-java-extended-scalars@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] <[email protected]>
  • Loading branch information
dependabot[bot] authored and josephlbarnett committed May 12, 2022
1 parent 2933146 commit e317363
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -137,6 +139,20 @@ internal val LOCAL_DATETIME_SCALAR = GraphQLScalarType.newScalar()
)
.coercing(
object : Coercing<LocalDateTime, String> {
// 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)
Expand All @@ -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}")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class LeakyCauldronHooksTest {
fun testLocalDateTime() {
val result = graphQL.execute("""query {localDateTime(l:"2019-10-30T00:01")}""")
.getData<Map<String, String>>()
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 {
Expand All @@ -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
Expand All @@ -190,7 +190,7 @@ class LeakyCauldronHooksTest {
.query("""query(${'$'}input: LocalDateTime!) {localDateTime(l:${'$'}input)}""")
.variables(mapOf("input" to "2019-10-30T00:01")).build()
).getData<Map<String, String>>()
assertThat(result["localDateTime"]).isEqualTo("2019-10-31T01:01:00")
assertThat(result["localDateTime"]).isEqualTo("2019-10-31T01:01:00.000")
}

@Test
Expand Down Expand Up @@ -233,7 +233,7 @@ class LeakyCauldronHooksTest {
fun testOffsetDateTime() {
val result = graphQL.execute("""query {offsetDateTime(o:"2019-10-30T00:01-07:00")}""")
.getData<Map<String, String>>()
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")}""")
}

Expand All @@ -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<Map<String, String>>()
assertThat(result["offsetDateTime"]).isEqualTo("2019-10-31T07:01:00Z")
assertThat(result["offsetDateTime"]).isEqualTo("2019-10-31T07:01:00.000Z")
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions json/src/main/kotlin/com/trib3/json/ObjectMapperProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())

Expand Down
2 changes: 1 addition & 1 deletion parent-pom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<version.flyway>8.5.10</version.flyway>
<version.graphql-kotlin>5.4.1</version.graphql-kotlin>
<version.graphql-java>17.3</version.graphql-java>
<version.graphql-java-extended-scalars>18.0</version.graphql-java-extended-scalars>
<version.graphql-java-extended-scalars>18.1</version.graphql-java-extended-scalars>
<version.graphql-java.tools>5.2.4</version.graphql-java.tools>
<version.graphql-java.dataloader>3.1.2</version.graphql-java.dataloader>
<version.graphql-java.servlet>6.1.3</version.graphql-java.servlet>
Expand Down

0 comments on commit e317363

Please sign in to comment.