https://kotlinlang.org logo
#graphql-kotlin
Title
# graphql-kotlin
d

Das135

07/20/2020, 9:05 AM
Please, is it possible to somehow "hide" any types when generating GraphQL schema? I am using Jetbrains Exposed library to ORM mapping, I have DAO object and entity class (having functions like
.wrapRow
etc..
Copy code
object TableObject : IdTable<Int>("tableName") {
    val property1 = long("column1")
    val property2 = long("column2")
}

class MappedEntity(id: EntityID<Int>): Entity<Int>(id){
    companion object : EntityClass<Int, MappedEntity>(TableObject)

    var entityProperty1 by TableObject.property1
    var entityProperty2 by TableObject.property2
}
I want to return
MappedEntity
in GraphQL schema, but there is problem with
com.expediagroup.graphql.exceptions.TypeNotSupportedException: Cannot convert org.jetbrains.exposed.sql.ResultRow? since it is not a valid GraphQL type or outside the supported packages
. Do I need to map this entity to another class, or is there way to use MappedEntity class in GraphQL schema?
d

Dariusz Kuc

07/20/2020, 1:24 PM
you can exclude types from being present in the schema by annotating them with
@GraphQLIgnore
but that implies they have to be part of your code base
if they are outside your code base (as in your use case above) you can manually process them using schema generator hooks (but that might be somewhat tedious)
I think the simplest workaround is to map them to some data class within your code base
1
👌 1
r

Robert

07/24/2020, 12:20 PM
Don't share Entitiy & Graphql Model in the first place, would be an option.
👍 1
25 Views