Hello. I am trying to add exposed to my ktor serve...
# graphql-kotlin
m
Hello. I am trying to add exposed to my ktor server with graphql-kotlin, fetch data from a database and use it with graal-vm. I followed the supercharged-graphql example and it all works untill I tried to use a class that inherits from org.jetbrains.exposed.dao.IntEntity. Looks like this:
Copy code
object ProductTable : IntIdTable() {
    val name = varchar("name", 80)
    val price = double("price")
}

class ProductEntity(id: EntityID<Int>) : IntEntity(id) {
    companion object : IntEntityClass<ProductEntity>(ProductTable)

    var name by ProductTable.name
    var price by ProductTable.price
}
...
class ProductQuery : Query {
  private val repository = ProductRepository()
  suspend fun products(): List<Product> = repository.findAll()
}
...
class ProductRepository {
  suspend fun findAll(): List<Product> = query {
    val products = ProductEntity.all().map { entityToProduct(it) }

    products
  }
}
When I build a native image and run it against a query that is calling this oblect, I get this error:
kotlin.reflect.jvm.internal.KotlinReflectionInternalError: Could not compute caller for function: public constructor ProductEntity(id: org.jetbrains.exposed.dao.id.EntityID<<http://kotlin.Int|kotlin.Int>>) defined in si.schlamberger.climbholds.db.product.ProductEntity[DeserializedClassConstructorDescriptor@733818e6] (member = null)
d
👋 I haven't looked into that code in a while but this looks like missing reflection metadata for the `IntEntity`/`IntIdTable` I'm guessing that reflection metadata generator does not generate the metadata because `IntEntity`/`IntIdTable` are outside of the graphql packages. This is just a guess though.
m
Looks like it's a Exosed issue: https://github.com/JetBrains/Exposed/pull/2039
d
unsure
without a repro and debugging through the issue hard to say
m
If I remove DAO related code an use just DSL it works. Will try again when the above merge is released.