Skip to content

Commit a5db848

Browse files
authored
Merge pull request #342 from rrva/non-nullable-scalars-2
Treat non-nullable scalars as scalars fix #335
2 parents 0ee4f39 + 95cc3af commit a5db848

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)