https://kotlinlang.org logo
#kgraphql
Title
# kgraphql
y

Yuri Kornienko

04/09/2020, 7:29 AM
Hi all! How to make scalar YearMonth and Year classes of Kotlin? I make stringscalar like in docs, but have error
j

jeggy

04/09/2020, 12:38 PM
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

Yuri Kornienko

04/13/2020, 5:37 PM
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

jeggy

04/13/2020, 5:55 PM
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

Yuri Kornienko

04/15/2020, 9:25 AM
sorry, maybe its database problem. It's writing to database well, but can't read from Year, YearMonth and etc java.Time classes
3 Views