Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ internal class MethodFieldResolver(field: FieldDefinition, search: FieldResolver

override fun scanForMatches(): List<TypeClassMatcher.PotentialMatch> {
val batched = isBatched(method, search)
val unwrappedGenericType = genericType.unwrapGenericType(method.kotlinFunction?.returnType?.javaType ?: method.returnType)
val unwrappedGenericType = genericType.unwrapGenericType(method.kotlinFunction?.returnType?.javaType ?: method.genericReturnType)
val returnValueMatch = TypeClassMatcher.PotentialMatch.returnValue(field.type, unwrappedGenericType, genericType, SchemaClassScanner.ReturnValueReference(method), batched)

return field.inputValueDefinitions.mapIndexed { i, inputDefinition ->
Expand Down
18 changes: 18 additions & 0 deletions src/test/groovy/com/coxautodev/graphql/tools/EndToEndSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,24 @@ class EndToEndSpec extends Specification {
]
}

def "generated schema supports generic properties"() {
when:
def data = Utils.assertNoGraphQlErrors(gql) {
'''
{
itemWithGenericProperties {
keys
}
}
'''
}

then:
data.itemWithGenericProperties == [
keys: ["A", "B"]
]
}

def "generated schema supports batched datafetchers"() {
when:
def data = Utils.assertNoGraphQlErrors(batchedGql) {
Expand Down
7 changes: 7 additions & 0 deletions src/test/kotlin/com/coxautodev/graphql/tools/EndToEndSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type Query {
itemsWithOptionalInputExplicit(itemsInput: ItemSearchInput): [Item!]
enumInputType(type: Type!): Type!
customScalarMapInputType(customScalarMap: customScalarMap): customScalarMap
itemWithGenericProperties: ItemWithGenericProperties!

defaultArgument(arg: Boolean = true): Boolean!
defaultEnumListArgument(types: [Type] = [TYPE_1]): [Type]
Expand Down Expand Up @@ -199,6 +200,10 @@ type Tag {
id: Int!
name: String!
}

type ItemWithGenericProperties {
keys: [String!]!
}
"""


Expand Down Expand Up @@ -254,6 +259,7 @@ class Query: GraphQLQueryResolver, ListListResolver<String>() {
fun itemsWithOptionalInputExplicit(input: Optional<ItemSearchInput>) = if(input.isPresent) items(input.get()) else items
fun enumInputType(type: Type) = type
fun customScalarMapInputType(customScalarMap: Map<String, Any>) = customScalarMap
fun itemWithGenericProperties() = ItemWithGenericProperties(listOf("A", "B"))

fun defaultArgument(arg: Boolean) = arg
fun defaultEnumListArgument(types: List<Type>) = types
Expand Down Expand Up @@ -355,6 +361,7 @@ data class NewItemInput(val name: String, val type: Type)
data class ComplexNullable(val first: String, val second: String, val third: String)
data class ComplexInputType(val first: String, val second: List<List<ComplexInputTypeTwo>?>?)
data class ComplexInputTypeTwo(val first: String)
data class ItemWithGenericProperties(val keys: List<String>)

val customScalarId = GraphQLScalarType("ID", "Overrides built-in ID", object : Coercing<UUID, String> {
override fun serialize(input: Any): String? = when (input) {
Expand Down