graphql-spring-boot icon indicating copy to clipboard operation
graphql-spring-boot copied to clipboard

Webflux ClassCastException for Flux response type

Open Sam-Kruglov opened this issue 4 years ago • 5 comments

If a resolver has Flux<...> return type and schema has [...] return type then it will crash on this line:

com/graphql-java-kickstart/graphql-java-tools/5.7.1/graphql-java-tools-5.7.1-sources.jar!/com/coxautodev/graphql/tools/TypeClassMatcher.kt:78

is ListType -> {
   // realType is ParameterizedTypeImpl but isListType is false
    if (realType is ParameterizedType && isListType(realType, potentialMatch)) {
        match(potentialMatch, graphQLType.type, realType.actualTypeArguments.first())
   // cast exception
    } else if ((realType as Class<*>).isArray) {
        match(potentialMatch, graphQLType.type, realType.componentType)
    } else {
        throw error(potentialMatch, "Java class is not a List or generic type information was lost: $realType")
    }
}

It works if such query is actually a subscription of return type ... and the resolver of Publisher<...>

Sam-Kruglov avatar Jan 11 '20 19:01 Sam-Kruglov