Scala `Seq` is not recognised as list
earlgreyz opened this issue · comments
Description
After switching code generation from Java to Scala schema parser build fails with the following exception:
java.lang.ClassCastException: class graphql.kickstart.tools.util.ParameterizedTypeImpl cannot be cast to class java.lang.Class
It seemed caused by isListType
inside TypeClassMatcher
only checking for java.lang.Iterable
causing scala Seq
to not be considered a list type.
Expected behavior
SchemaParser build returns parses the schema properly.
Actual behavior
SchemaParser build throws java.lang.ClassCastException
.
Steps to reproduce the bug
Given example schema
# schema.graphqls
query {
topics(prefix: String!): [Topic!]!
}
type Topic {
topic: String!
}
Scala classes autogenerated with: https://github.com/kobylynskyi/graphql-java-codegen
// Topic.scala
case class Topic(topic: String)
// QueryResolver.scala
trait QueryResolver extends graphql.kickstart.tools.GraphQLQueryResolver {
def topics(prefix: String): java.util.concurrent.CompletionStage[scala.Seq[Topic]]
}
Actual query resolver implementation
// QueryResolverImpl.scala
class QueryResolverImpl extends QueryResolver {
override def topics(prefix: String): java.util.concurrent.CompletionStage[scala.Seq[Topic]] = ???
}
Trying to build schema will fail with an exception
object Test extends App {
val schema = SchemaParser.newParser()
.files("schema.graphqls")
.resolvers(new QueryResolverImpl())
.build()
.makeExecutableSchema()
}
I don't believe we generally support Scala.
Is this the only obstacle?
Closing for now.