Open ronjunevaldoz opened 2 years ago
Should the ObjectId of a model not rather be defined in graphql using a scalar and mapping it to a string?
Solved with
schema {
configure {
genericTypeResolver = object: DefaultGenericTypeResolver() {
override fun resolveMonad(type: KType): KType = when {
type.jvmErasure.isSubclassOf(Id::class) -> type.arguments[0].type!!.withNullability(type.isMarkedNullable)
else -> super.resolveMonad(type)
}
override fun unbox(obj: Any): Any? = when(obj) {
is Id<*> -> obj.toString()
else -> super.unbox(obj)
}
}
}
}
Having an error
com.apurebase.kgraphql.schema.SchemaException: An Object type must define one or more fields. Found none on type Id
Mongo User Document Model
Schema Type