Skip to content

Commit 95cc3af

Browse files
committed
Treat non-nullable scalars as scalars
When using a non-nullable scalar as input type a regression was introduced by the upgrade of jackson. A jackson exception occurs internally in the MethodFieldResolver because the correct deserialiser/serialiser cannot be found. Somehow this was hidden when using earlier versions of jackson where this just worked anyhow, but due to changes in jackson this bug is uncovered. The correct way is of course to fix this in isScalarType to cover non-nullable scalars, and not rely on functionality in jackson which no longer seems to be supported.
1 parent 0ee4f39 commit 95cc3af

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/main/kotlin/com/coxautodev/graphql/tools/MethodFieldResolver.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import graphql.language.Type
1111
import graphql.language.TypeName
1212
import graphql.schema.DataFetcher
1313
import graphql.schema.DataFetchingEnvironment
14-
import graphql.schema.GraphQLTypeUtil.isScalar
14+
import graphql.schema.GraphQLTypeUtil.*
1515
import kotlinx.coroutines.GlobalScope
1616
import kotlinx.coroutines.future.future
1717
import java.lang.reflect.Method
@@ -121,12 +121,14 @@ internal class MethodFieldResolver(field: FieldDefinition, search: FieldResolver
121121
}
122122

123123
private fun isScalarType(environment: DataFetchingEnvironment, type: Type<*>, genericParameterType: JavaType): Boolean =
124-
when (type) {
125-
is ListType ->
124+
when {
125+
type is ListType ->
126126
List::class.java.isAssignableFrom(this.genericType.getRawClass(genericParameterType))
127127
&& isScalarType(environment, type.type, this.genericType.unwrapGenericType(genericParameterType))
128-
is TypeName ->
128+
type is TypeName ->
129129
environment.graphQLSchema?.getType(type.name)?.let { isScalar(it) } ?: false
130+
type is NonNullType && type.type is TypeName ->
131+
environment.graphQLSchema?.getType((type.type as TypeName).name)?.let { isScalar(unwrapNonNull(it)) } ?: false
130132
else ->
131133
false
132134
}

0 commit comments

Comments
 (0)