sangria-graphql/sangria

Scala 3: Exception returning Future values from GraphQL Endpoint

PsyfireX opened this issue · 1 comments

When attempting to return values from a GraphQL endpoint using Sangria and Scala 3, I get the following exception:

    @GraphQLField
    def ping(in: String): Future[String] = {
      implicit val ec: scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global
      Future.apply(in)
    }
"class scala.concurrent.impl.Promise$Transformation cannot be cast to class java.lang.String (scala.concurrent.impl.Promise$Transformation is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap') 
 java.lang.ClassCastException: class scala.concurrent.impl.Promise$Transformation cannot be cast to class java.lang.String (scala.concurrent.impl.Promise$Transformation is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap') 
 sangria.execution.Resolver.resolveValue(Resolver.scala:1274) 
 sangria.execution.Resolver.$anonfun$20(Resolver.scala:813) 
 scala.collection.immutable.Vector1.map(Vector.scala:1872) 
 scala.collection.immutable.Vector1.map(Vector.scala:375) 
 sangria.execution.Resolver.resolveActionsPar(Resolver.scala:1113) 
 sangria.execution.Resolver.resolveFieldsPar(Resolver.scala:49) 
 sangria.execution.Executor.executeOperation(Executor.scala:275) 
 sangria.execution.Executor.$anonfun$5$$anonfun$2$$anonfun$1$$anonfun$1$$anonfun$1(Executor.scala:206) 
 scala.concurrent.impl.Promise$Transformation.run(Promise.scala:470) 
 java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) 
 java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) 
 java.base/java.lang.Thread.run(Thread.java:834)"

I am able to successfully get a schema from the running GraphQL server.

Since this particular error relies on having a running GraphQL server, it'll be a little difficult for me to create a miniature isolated code sample. I might make an attempt at creating an isolated sample, but that would take some time. If you cannot reproduce, let me know here on the ticket. (I'll try to monitor the ticket).


It appears to only happen when returning a Future. The following returns just fine.

    @GraphQLField
    def ping2(in: String): String = {
      in
    }

Error messages sound aweful familiar to #449