Skip to content

Commit 02e1d07

Browse files
committed
Handle raw Map type
1 parent 7a0c8cd commit 02e1d07

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,17 @@ internal class PropertyMapResolver(field: FieldDefinition, search: FieldResolver
1414

1515
var mapGenericValue : JavaType = getMapGenericType(relativeTo)
1616

17+
/**
18+
* Takes a type which implements Map and tries to find the
19+
* value type of that map. For some reason, mapClass is losing
20+
* its generics somewhere along the way and is always a raw
21+
* type
22+
*/
1723
fun getMapGenericType(mapClass : JavaType) : JavaType {
1824
val resolvedType = TypeResolver().resolve(mapClass)
1925

20-
return resolvedType.typeParametersFor(Map::class.java)[1]
26+
val typeParameters = resolvedType.typeParametersFor(Map::class.java)
27+
return typeParameters.elementAtOrElse(1) { Object::class.java }
2128
}
2229

2330
override fun createDataFetcher(): DataFetcher<*> {

0 commit comments

Comments
 (0)