Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala 3: Exception returning Future values from GraphQL Endpoint #906

Open
PsyfireX opened this issue Sep 5, 2022 · 1 comment
Open
Labels

Comments

@PsyfireX
Copy link

PsyfireX commented Sep 5, 2022

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
    }
@yanns yanns added the scala3 label Sep 5, 2022
@PsyfireX PsyfireX changed the title Scala 3: Exception returning values from GraphQL Endpoint Scala 3: Exception returning Future values from GraphQL Endpoint Sep 6, 2022
@muuki88
Copy link

muuki88 commented Nov 30, 2022

Error messages sound aweful familiar to #449

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants