diff --git a/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DataFetcherInvoker.kt b/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DataFetcherInvoker.kt index f1673ebf6..d5b7979e5 100644 --- a/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DataFetcherInvoker.kt +++ b/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DataFetcherInvoker.kt @@ -22,6 +22,7 @@ import graphql.schema.DataFetchingEnvironment import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.reactor.mono import org.springframework.core.BridgeMethodResolver +import org.springframework.core.KotlinDetector import org.springframework.core.MethodParameter import org.springframework.core.ParameterNameDiscoverer import org.springframework.core.annotation.SynthesizingMethodParameter @@ -44,7 +45,7 @@ class DataFetcherInvoker internal constructor( ) : DataFetcher { private val bridgedMethod: Method = BridgeMethodResolver.findBridgedMethod(method) - private val kotlinFunction: KFunction<*>? = bridgedMethod.kotlinFunction + private val kotlinFunction: KFunction<*>? = if (KotlinDetector.isKotlinType(bridgedMethod.declaringClass)) bridgedMethod.kotlinFunction else null private val completableFutureWrapper = CompletableFutureWrapper(taskExecutor) private val methodParameters: List = bridgedMethod.parameters.map { parameter -> @@ -65,7 +66,7 @@ class DataFetcherInvoker internal constructor( return ReflectionUtils.invokeMethod(bridgedMethod, dgsComponent) } - if (dgsComponent.javaClass.getDeclaredAnnotation(Metadata::class.java) != null && kotlinFunction != null) { + if (kotlinFunction != null) { return invokeKotlinMethod(kotlinFunction, environment) }