@@ -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
@@ -105,7 +106,17 @@ internal class MethodFieldResolver(field: FieldDefinition, search: FieldResolver
105
106
return if (batched) {
106
107
BatchedMethodFieldResolverDataFetcher (getSourceResolver(), this .method, args, options)
107
108
} else {
108
- MethodFieldResolverDataFetcher (getSourceResolver(), this .method, args, options)
109
+ if (args.size == 0
110
+ && this .method.parameterCount == 0
111
+ && this .method.name.startsWith(" get" )
112
+ && this .search.type is java.lang.Class <* >
113
+ && (this .search.type as java.lang.Class <* >).getMethod(this .method.getName()) != null
114
+ ) {
115
+ TrivialMethodFieldResolverDataFetcher (getSourceResolver(), this .method, args, options)
116
+ } else {
117
+ MethodFieldResolverDataFetcher (getSourceResolver(), this .method, args, options)
118
+ }
119
+
109
120
}
110
121
}
111
122
@@ -191,6 +202,10 @@ open class MethodFieldResolverDataFetcher(private val sourceResolver: SourceReso
191
202
}
192
203
}
193
204
205
+ 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> {
206
+
207
+ }
208
+
194
209
private suspend inline fun MethodAccess.invokeSuspend (target : Any , methodIndex : Int , args : Array <Any ?>): Any? {
195
210
return suspendCoroutineUninterceptedOrReturn { continuation ->
196
211
invoke(target, methodIndex, * args + continuation)
0 commit comments