@@ -14,6 +14,7 @@ import graphql.schema.DataFetcher
14
14
import graphql.schema.DataFetchingEnvironment
15
15
import graphql.schema.GraphQLTypeUtil.isScalar
16
16
import kotlinx.coroutines.future.future
17
+ import org.slf4j.LoggerFactory
17
18
import java.lang.reflect.Method
18
19
import java.util.*
19
20
import kotlin.coroutines.intrinsics.suspendCoroutineUninterceptedOrReturn
@@ -31,6 +32,8 @@ internal class MethodFieldResolver(
31
32
val method : Method
32
33
) : FieldResolver(field, search, options, search.type) {
33
34
35
+ private val log = LoggerFactory .getLogger(javaClass)
36
+
34
37
private val additionalLastArgument =
35
38
try {
36
39
(method.kotlinFunction?.valueParameters?.size
@@ -97,8 +100,15 @@ internal class MethodFieldResolver(
97
100
when (this .method.parameterTypes.last()) {
98
101
null -> throw ResolverError (" Expected at least one argument but got none, this is most likely a bug with graphql-java-tools" )
99
102
options.contextClass -> args.add { environment ->
100
- environment.graphQlContext[options.contextClass]
101
- ? : environment.getContext() // TODO: remove deprecated use in next major release
103
+ val context: Any? = environment.graphQlContext[options.contextClass]
104
+ if (context != null ) {
105
+ context
106
+ } else {
107
+ log.warn(" Generic context class has been deprecated by graphql-java. " +
108
+ " To continue using a custom context class as the last parameter in resolver methods " +
109
+ " please insert it into the new GraphQLContext class when building the ExecutionInput." )
110
+ environment.getContext() // TODO: remove deprecated use in next major release
111
+ }
102
112
}
103
113
GraphQLContext ::class .java -> args.add { environment -> environment.graphQlContext }
104
114
else -> args.add { environment -> environment }
0 commit comments