@@ -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.ListType
@@ -116,7 +117,17 @@ internal class MethodFieldResolver(field: FieldDefinition, search: FieldResolver
116
117
return if (batched) {
117
118
BatchedMethodFieldResolverDataFetcher (getSourceResolver(), this .method, args, options)
118
119
} else {
119
- MethodFieldResolverDataFetcher (getSourceResolver(), this .method, args, options)
120
+ if (args.size == 0
121
+ && this .method.parameterCount == 0
122
+ && this .method.name.startsWith(" get" )
123
+ && this .search.type is java.lang.Class <* >
124
+ && (this .search.type as java.lang.Class <* >).getMethod(this .method.getName()) != null
125
+ ) {
126
+ TrivialMethodFieldResolverDataFetcher (getSourceResolver(), this .method, args, options)
127
+ } else {
128
+ MethodFieldResolverDataFetcher (getSourceResolver(), this .method, args, options)
129
+ }
130
+
120
131
}
121
132
}
122
133
@@ -221,6 +232,10 @@ open class MethodFieldResolverDataFetcher(private val sourceResolver: SourceReso
221
232
}
222
233
}
223
234
235
+ 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> {
236
+
237
+ }
238
+
224
239
private suspend inline fun MethodAccess.invokeSuspend (target : Any , methodIndex : Int , args : Array <Any ?>): Any? {
225
240
return suspendCoroutineUninterceptedOrReturn { continuation ->
226
241
invoke(target, methodIndex, * args + continuation)
0 commit comments