Skip to content

Conversation

@ESchouten
Copy link

When a custom InputTypeDef is provided, the kqlInput is correctly set, but the inputType is not.

Due to kotlins reflection behaviour, which returns functions with generic types instead of the underlying types, overriding the input type seems mandatory. https://youtrack.jetbrains.com/issue/KT-42746
Doing so enables the use of generics discussed in #139

Example:

inline fun <reified T : Any, reified U : Any, V: UseCase<T, U>> SchemaBuilder.connection(usecase: V) {
    query(usecase::class.simpleName!!) {
        resolver { request: T, ctx: Context ->
            usecase.execute(request, ctx.get<User>())
        }.returns<U>().apply {
            addInputValues(listOf(InputValueDef(T::class, "request")))
        }
    }
}

Copy link
Member

@jeggy jeggy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this and it works great! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants