Skip to content

Using Kotlin extension functions in Resolvers #272

Open
@roschlau

Description

@roschlau

I'm using the graphql tools from Kotlin, and I would love to use extension functions in my resolver classes for readability:

package some.package

class Service(
    val name: String,
    val url: String
)

class ServiceResolver() : GraphQLResolver<Service> {
    fun Service.healthy() = TODO("Check $url/health for 200 response")
}

From my experience with Kotlin, the extension function there should have exactly the same bytecode signature as a normal function with a Service object as the first parameter, however, loading the schema fails with a FieldResolverError, stating that a function with the signature of some.package.ServiceResolver.version(some.package.Service) can't be found.

This code worked before, when I was using com.graphql-java:graphql-java-tools:5.2.0, but after updating to version 5.6.0 that's now located in the com.graphql-java-kickstart group, I have to rewrite all extension functions like this to regular functions accepting a parameter to get it working again. Is there anyway using extension functions could be supported again?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions