File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed
src/main/kotlin/graphql/kickstart/tools Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -16,22 +16,15 @@ internal abstract class DictionaryTypeResolver(
16
16
private val dictionary : BiMap <JavaType , TypeDefinition <* >>,
17
17
private val types : Map <String , GraphQLObjectType >
18
18
) : TypeResolver {
19
- private fun <T > getTypeName (clazz : Class <T >): String? {
20
- val name = dictionary[clazz]?.name
21
-
22
- if (name == null && clazz.superclass != null ) {
23
- return getTypeName(clazz.superclass)
24
- }
25
-
26
- return name
19
+ private fun <T > getTypeDefinition (clazz : Class <T >): TypeDefinition <* >? {
20
+ return dictionary[clazz]
21
+ ? : (if (clazz.superclass == null ) null else getTypeDefinition(clazz.superclass))
22
+ ? : clazz.interfaces.mapNotNull { getTypeDefinition(it) }.firstOrNull()
27
23
}
28
24
29
25
override fun getType (env : TypeResolutionEnvironment ): GraphQLObjectType ? {
30
26
val clazz = env.getObject<Any >().javaClass
31
- val name = clazz.interfaces.fold(getTypeName(clazz), { name, interfaceClazz ->
32
- name ? : getTypeName(interfaceClazz)
33
- }) ? : clazz.simpleName
34
-
27
+ val name = getTypeDefinition(clazz)?.name ? : clazz.simpleName
35
28
return types[name] ? : throw TypeResolverError (getError(name))
36
29
}
37
30
You can’t perform that action at this time.
0 commit comments