diff --git a/akka-http/src/main/scala/caliban/AkkaHttpAdapter.scala b/akka-http/src/main/scala/caliban/AkkaHttpAdapter.scala index 2b2ae8851..23606dcb8 100644 --- a/akka-http/src/main/scala/caliban/AkkaHttpAdapter.scala +++ b/akka-http/src/main/scala/caliban/AkkaHttpAdapter.scala @@ -44,6 +44,11 @@ object AkkaHttpAdapter extends FailFastCirceSupport { .future ) + def makeHttpServiceM[R, E]( + interpreter: URIO[R, GraphQLInterpreter[R, E]] + )(implicit ec: ExecutionContext, runtime: Runtime[R]): Route = + makeHttpService(runtime.unsafeRun(interpreter)) + def makeHttpService[R, E]( interpreter: GraphQLInterpreter[R, E] )(implicit ec: ExecutionContext, runtime: Runtime[R]): Route = { diff --git a/examples/src/main/scala/caliban/akkahttp/ExampleApp.scala b/examples/src/main/scala/caliban/akkahttp/ExampleApp.scala index 3dafd27e1..048451562 100644 --- a/examples/src/main/scala/caliban/akkahttp/ExampleApp.scala +++ b/examples/src/main/scala/caliban/akkahttp/ExampleApp.scala @@ -34,7 +34,7 @@ object ExampleApp extends App with GenericSchema[Console with Clock] { case class Mutations(deleteCharacter: CharacterArgs => URIO[Console, Boolean]) case class Subscriptions(characterDeleted: ZStream[Console, Nothing, String]) - val interpreter = defaultRuntime.unsafeRun( + val interpreter = ExampleService .make(sampleCharacters) .map(service => { @@ -49,7 +49,6 @@ object ExampleApp extends App with GenericSchema[Console with Clock] { ) ).interpreter }) - ) /** * curl -X POST \ @@ -62,7 +61,7 @@ object ExampleApp extends App with GenericSchema[Console with Clock] { */ val route = path("api" / "graphql") { - AkkaHttpAdapter.makeHttpService(interpreter) + AkkaHttpAdapter.makeHttpServiceM(interpreter) } ~ path("graphiql") { getFromResource("graphiql.html") }