Roy Åne Sylthe
06/09/2020, 9:30 AMjava.time.LocalDate
(no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)`
object DateCoercing : Coercing<Date, String> {
override fun parseValue(input: Any?): Date = try {
LocalDate.parse(serialize(input))
} catch (e: DateTimeParseException) {
throw CoercingParseValueException("...", e)
}
override fun parseLiteral(input: Any?): Date? = try {
(input as? StringValue)?.value?.let { LocalDate.parse(it) }
} catch (e: DateTimeParseException) {
throw CoercingParseLiteralException("...", e)
}
override fun serialize(dataFetcherResult: Any?): String = dataFetcherResult.toString()
}
I've tried most of the common solutions found by Googling to no avail...Robert
06/09/2020, 11:36 AMjava.util.Date
and java.time.LocalDate
is that intendend?Roy Åne Sylthe
06/09/2020, 12:36 PMDariusz Kuc
06/09/2020, 1:47 PMDariusz Kuc
06/09/2020, 1:48 PMRoy Åne Sylthe
06/09/2020, 1:49 PM@Component
class CustomSchemaGeneratorHooks : SchemaGeneratorHooks {
override fun willGenerateGraphQLType(type: KType): GraphQLType? = when (type.classifier as? KClass<*>) {
Date::class -> graphqlDateType
else -> null
}
}
val graphqlDateType: GraphQLType? = GraphQLScalarType.newScalar()
.name("Date")
.description("...")
.coercing(DateCoercing)
.build()
This should be picked up automatically, correct?Dariusz Kuc
06/09/2020, 1:51 PMDate::class
yet you are trying to coerce java.time.LocalDate
are you sure you are not mixing the two?Roy Åne Sylthe
06/09/2020, 1:53 PMjava.time.Instant
as a custom scalar that I've given the alias DateTime
.Dariusz Kuc
06/09/2020, 2:39 PMDariusz Kuc
06/09/2020, 2:39 PMDariusz Kuc
06/09/2020, 2:40 PMRoy Åne Sylthe
06/10/2020, 8:02 AMLenny
06/10/2020, 9:02 PMDate::class.java
in the when
expression? i keep doing the wrong thing and immediately forgetting which after i figure it outLenny
06/10/2020, 9:10 PM::class
… got it wrong againDariusz Kuc
06/10/2020, 9:14 PMRoy Åne Sylthe
06/11/2020, 9:22 AMDariusz Kuc
06/11/2020, 1:58 PM