@@ -3,6 +3,7 @@ package com.coxautodev.graphql.tools
3
3
import com.coxautodev.graphql.tools.SchemaParserOptions.GenericWrapper
4
4
import com.esotericsoftware.reflectasm.MethodAccess
5
5
import com.fasterxml.jackson.core.type.TypeReference
6
+ import graphql.TrivialDataFetcher
6
7
import graphql.execution.batched.Batched
7
8
import graphql.language.FieldDefinition
8
9
import graphql.language.NonNullType
@@ -13,9 +14,6 @@ import kotlinx.coroutines.future.future
13
14
import java.lang.reflect.Method
14
15
import java.util.*
15
16
import kotlin.coroutines.intrinsics.suspendCoroutineUninterceptedOrReturn
16
- import kotlin.reflect.full.valueParameters
17
- import kotlin.reflect.jvm.javaType
18
- import kotlin.reflect.jvm.kotlinFunction
19
17
20
18
/* *
21
19
* @author Andrew Potter
@@ -105,7 +103,16 @@ internal class MethodFieldResolver(field: FieldDefinition, search: FieldResolver
105
103
return if (batched) {
106
104
BatchedMethodFieldResolverDataFetcher (getSourceResolver(), this .method, args, options)
107
105
} else {
108
- MethodFieldResolverDataFetcher (getSourceResolver(), this .method, args, options)
106
+ if (args.size == 0
107
+ && this .method.getParameterCount() == 0
108
+ && this .method.getName().startsWith(" get" )
109
+ && this .search.type is java.lang.reflect.Class
110
+ && (this .search.type as java.lang.reflect.Class ).getMethod(this .method.getName()) != null ) {
111
+ TrivialMethodFieldResolverDataFetcher (getSourceResolver(), this .method, args, options);
112
+ } else {
113
+ MethodFieldResolverDataFetcher (getSourceResolver(), this .method, args, options)
114
+ }
115
+
109
116
}
110
117
}
111
118
@@ -191,6 +198,10 @@ open class MethodFieldResolverDataFetcher(private val sourceResolver: SourceReso
191
198
}
192
199
}
193
200
201
+ open class TrivialMethodFieldResolverDataFetcher (private val sourceResolver : SourceResolver , method : Method , private val args : List <ArgumentPlaceholder >, private val options : SchemaParserOptions ) : MethodFieldResolverDataFetcher(sourceResolver, method, args, options), TrivialDataFetcher<Any> {
202
+
203
+ }
204
+
194
205
private suspend inline fun MethodAccess.invokeSuspend (target : Any , methodIndex : Int , args : Array <Any ?>): Any? {
195
206
return suspendCoroutineUninterceptedOrReturn { continuation ->
196
207
invoke(target, methodIndex, * args + continuation)
0 commit comments