Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide better errors for KType errors #155

Open
jeggy opened this issue Jul 7, 2021 · 1 comment
Open

Provide better errors for KType errors #155

jeggy opened this issue Jul 7, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@jeggy
Copy link
Member

jeggy commented Jul 7, 2021

Here's an example error of when using a Exposed class: Exception in thread "main" com.apurebase.kgraphql.schema.SchemaException: Generic types are not supported by GraphQL, found kotlin.collections.Map<org.jetbrains.exposed.sql.Expression<*>, kotlin.Int> thrown from SchemaCompilation.kt:168

Instead of throwing this error, it would be great to provide a error message which recursively provides full information of exactly where this issue is coming from.

In a Exposed sample, the reason would be because of the type is extending the Entity<Int> type, and a field on this class is ResultRow and it's here the field fieldIndex of the type Map<Expression<*>, Int> lies, which is causing this to fail.

@jeggy jeggy added the enhancement New feature or request label Jul 7, 2021
@Martmists-GH
Copy link

Martmists-GH commented Jul 7, 2023

For the specific case of Exposed's DAO, it'd be nice to only use the properties defined on the class itself using KClass<T>.declaredMemberProperties. While this does mean you lose some benefits of inheritance, there exist solutions to it, e.g.

open class A {
    open val x: Int = 1
}

class B : A() {
    override val x: Int  // Redeclares x, but doesn't redefine it, meaning it acts as effectively a no-op and still shows up in declaredMemberProperties
        get() = super.x
}

This way, properties of Entity<T> are not included unless expressly so, fixing a lot of the issues currently happening with Exposed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants