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(
1616 private val dictionary : BiMap <JavaType , TypeDefinition <* >>,
1717 private val types : Map <String , GraphQLObjectType >
1818) : 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()
2723 }
2824
2925 override fun getType (env : TypeResolutionEnvironment ): GraphQLObjectType ? {
3026 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
3528 return types[name] ? : throw TypeResolverError (getError(name))
3629 }
3730
You can’t perform that action at this time.
0 commit comments