Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Closes #36
Unwrap input type list
  • Loading branch information
Bojan Tomic committed Jul 9, 2017
commit eda1c4e1f02ad0437233d0a8123a5103b7812589
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
import graphql.language.ListType
import graphql.language.NonNullType
import graphql.schema.DataFetcher
import graphql.schema.DataFetchingEnvironment
Expand Down Expand Up @@ -44,6 +45,7 @@ class ResolverDataFetcher(val sourceResolver: SourceResolver, method: Method, va
val isNonNull = definition.type is NonNullType
val isOptional = rawType == Optional::class.java
val isMap = Map::class.java.isAssignableFrom(rawTypeWithoutOptional)
val isList = definition.type is ListType

val typeReference = object: TypeReference<Any>() {
override fun getType() = genericType
Expand All @@ -68,6 +70,10 @@ class ResolverDataFetcher(val sourceResolver: SourceResolver, method: Method, va

return@add mapper.convertValue(value, typeReference)
}

if (isList) {
return@add mapper.convertValue(value, typeReference)
}

value
})
Expand Down