Hi all! How to make scalar YearMonth and Year clas...
# kgraphql
y
Hi all! How to make scalar YearMonth and Year classes of Kotlin? I make stringscalar like in docs, but have error
j
What error are you getting?
The documentation has been updated now.
The documentation for that issue has been updated now, and you would see that the deserialize function has 2 parameters instead of only one.
y
Cannot construct instance of
java.time.Year
(although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)\n at [Source: de.undercouch.bson4jackson.io.LittleEndianInputStream@3e1f80b; pos: 135]
Copy code
stringScalar<Year> {
    coercion = object : StringScalarCoercion<Year> {
        override fun serialize(instance: Year): String = instance.value.toString()
        override fun deserialize(raw: String, valueNode: ValueNode?): Year = Year.of(raw.toInt())
    }
}
Help, please!
j
Seems like your issue is not related to KGraphQL?
what is your setup? are you using ktor or something else?
I just tried this and works without any problems
y
sorry, maybe its database problem. It's writing to database well, but can't read from Year, YearMonth and etc java.Time classes