vio
03/16/2022, 8:25 PMgraphql-kotlin-server
support scalar definitions for kotlin value classes
?Dariusz Kuc
03/16/2022, 10:02 PMID
(https://opensource.expediagroup.com/graphql-kotlin/docs/schema-generator/writing-schemas/scalars#primitive-types)vio
03/17/2022, 3:07 PM@JvmInline
value class BookId(
val v: String
)
the value unboxer definition:
open class BookIdValueUnboxer : ValueUnboxer {
override fun unbox(`object`: Any?): Any? = if (`object` is BookId) {
// log.debug { "Unboxing value: $`object`" }
`object`.v
} else {
`object`
}
}
and the registration to the GraphQL instance:
GraphQL
.newGraphQL(schema)
.valueUnboxer(BookIdValueUnboxer())
.build()
Dariusz Kuc
03/17/2022, 9:21 PMvio
03/24/2022, 9:49 AMDariusz Kuc
03/24/2022, 9:34 PMvio
03/25/2022, 4:39 PM