@@ -80,7 +80,7 @@ internal class MethodFieldResolver(
80
80
return @add Optional .empty<Any >()
81
81
}
82
82
83
- if (isValueMustBeConvert (value, definition, parameterType, environment)) {
83
+ if (value != null && shouldValueBeConverted (value, definition, parameterType, environment)) {
84
84
return @add mapper.convertValue(value, object : TypeReference <Any >() {
85
85
override fun getType () = parameterType
86
86
})
@@ -106,26 +106,25 @@ internal class MethodFieldResolver(
106
106
}
107
107
}
108
108
109
- private fun isValueMustBeConvert (value : Any? , definition : InputValueDefinition , parameterType : JavaType , environment : DataFetchingEnvironment ): Boolean {
110
- return value != null
111
- && (! parameterType.unwrap().isAssignableFrom(value.javaClass)
112
- || ! isConcreteScalarType(environment, definition.type, parameterType))
109
+ private fun shouldValueBeConverted (value : Any , definition : InputValueDefinition , parameterType : JavaType , environment : DataFetchingEnvironment ): Boolean {
110
+ return ! parameterType.unwrap().isAssignableFrom(value.javaClass) || ! isConcreteScalarType(environment, definition.type, parameterType)
113
111
}
114
112
115
113
/* *
116
- * A concrete scalar type is a scalar type where values are always coerce to the same Java type.
117
- * The ID scalar type is not concrete because values can be coerce to many Java types (eg. String, Long, UUID).
118
- * All values of a non concrete scalar type must be convert to the method field type.
114
+ * A concrete scalar type is a scalar type where values always coerce to the same Java type. The ID scalar type is not concrete
115
+ * because values can be coerced to multiple different Java types (eg. String, Long, UUID). All values of a non-concrete scalar
116
+ * type must be converted to the target method parameter type.
119
117
*/
120
- private fun isConcreteScalarType (environment : DataFetchingEnvironment , type : Type <* >, genericParameterType : JavaType ): Boolean =
121
- when (type) {
118
+ private fun isConcreteScalarType (environment : DataFetchingEnvironment , type : Type <* >, genericParameterType : JavaType ): Boolean {
119
+ return when (type) {
122
120
is ListType -> List ::class .java.isAssignableFrom(this .genericType.getRawClass(genericParameterType))
123
- && isConcreteScalarType(environment, type.type, this .genericType.unwrapGenericType(genericParameterType))
121
+ && isConcreteScalarType(environment, type.type, this .genericType.unwrapGenericType(genericParameterType))
124
122
is TypeName -> environment.graphQLSchema?.getType(type.name)?.let { isScalar(it) && type.name != " ID" }
125
- ? : false
123
+ ? : false
126
124
is NonNullType -> isConcreteScalarType(environment, type.type, genericParameterType)
127
125
else -> false
128
126
}
127
+ }
129
128
130
129
override fun scanForMatches (): List <TypeClassMatcher .PotentialMatch > {
131
130
val unwrappedGenericType = genericType.unwrapGenericType(try {
0 commit comments