https://kotlinlang.org logo
Title
v

vio

03/16/2022, 8:25 PM
hi all! does
graphql-kotlin-server
support scalar definitions for kotlin
value classes
?
d

Dariusz Kuc

03/16/2022, 10:02 PM
👋 they are in the 6.x (still alpha) but its not yet documented TLDR you would need to do something similar as we did for handling the
ID
(https://opensource.expediagroup.com/graphql-kotlin/docs/schema-generator/writing-schemas/scalars#primitive-types)
👍 1
v

vio

03/17/2022, 3:07 PM
thank you 🙏 trying it out now
sorry, could it be that I'm missing something when I try to set this up? my schema doesn't seem to pick up the unboxing the value class:
@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()
d

Dariusz Kuc

03/17/2022, 9:21 PM
I'll take a look tomorrow
:thank-you: 1
hi 👋 sorry for the delay, it looks like inline value class may require some additional changes to make it work
v

vio

03/24/2022, 9:49 AM
hi, thank you for checking it out 🙌
v

vio

03/25/2022, 4:39 PM
awesome, thank you very much 🙏 everything works 🎉
👍 1