Skip to content

Commit

Permalink
Fix return type of ZHttpAdapter.makeHttpService (#1723)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostdogpr authored May 13, 2023
1 parent f74cbad commit 0c17b43
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 11 deletions.
6 changes: 4 additions & 2 deletions adapters/zio-http/src/main/scala/caliban/ZHttpAdapter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ object ZHttpAdapter {

def makeHttpService[R, E](interpreter: HttpInterpreter[R, E])(implicit
serverOptions: ZioHttpServerOptions[R] = ZioHttpServerOptions.default[R]
): HttpApp[R, Throwable] =
ZioHttpInterpreter(serverOptions).toHttp(interpreter.serverEndpoints[R, ZioStreams](ZioStreams))
): App[R] =
ZioHttpInterpreter(serverOptions)
.toHttp(interpreter.serverEndpoints[R, ZioStreams](ZioStreams))
.withDefaultErrorResponse

def makeWebSocketService[R, E](
interpreter: WebSocketInterpreter[R, E]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ object ZHttpAdapterSpec extends ZIOSpecDefault {
case _ -> !! / "ws" / "graphql" =>
ZHttpAdapter.makeWebSocketService(WebSocketInterpreter(interpreter))
}
.withDefaultErrorResponse
)
.forkScoped
_ <- Live.live(Clock.sleep(3 seconds))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ object FederatedApp extends ZIOAppDefault {
.collectHttp[Request] { case _ -> !! / "api" / "graphql" =>
ZHttpAdapter.makeHttpService(HttpInterpreter(interpreter))
}
.withDefaultErrorResponse
)
.provideSome[CharacterService](Server.live, config)
} yield ()
Expand All @@ -35,7 +34,6 @@ object FederatedApp extends ZIOAppDefault {
.collectHttp[Request] { case _ -> !! / "api" / "graphql" =>
ZHttpAdapter.makeHttpService(HttpInterpreter(interpreter))
}
.withDefaultErrorResponse
)
.provideSome[EpisodeService](Server.live, config)
} yield ()
Expand Down
3 changes: 1 addition & 2 deletions examples/src/main/scala/example/stitching/ExampleApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ import caliban.ZHttpAdapter
object ExampleApp extends ZIOAppDefault {
import sttp.tapir.json.circe._

private val graphiql = Handler.fromStream(ZStream.fromResource("graphiql.html")).toHttp
private val graphiql = Handler.fromStream(ZStream.fromResource("graphiql.html")).toHttp.withDefaultErrorResponse

override def run =
(for {
Expand All @@ -120,7 +120,6 @@ object ExampleApp extends ZIOAppDefault {
case _ -> !! / "ws" / "graphql" => ZHttpAdapter.makeWebSocketService(WebSocketInterpreter(interpreter))
case _ -> !! / "graphiql" => graphiql
}
.withDefaultErrorResponse
)
} yield ())
.provide(
Expand Down
3 changes: 1 addition & 2 deletions examples/src/main/scala/example/ziohttp/AuthExampleApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ object Authed extends GenericSchema[Auth] {
}

object AuthExampleApp extends ZIOAppDefault {
private val graphiql = Handler.fromStream(ZStream.fromResource("graphiql.html")).toHttp
private val graphiql = Handler.fromStream(ZStream.fromResource("graphiql.html")).toHttp.withDefaultErrorResponse

override def run: URIO[Any, ExitCode] =
(for {
Expand All @@ -97,7 +97,6 @@ object AuthExampleApp extends ZIOAppDefault {
case _ -> !! / "ws" / "graphql" => Auth.WebSockets.live(interpreter)
case _ -> !! / "graphiql" => graphiql
}
.withDefaultErrorResponse
)
_ <- ZIO.logInfo(s"Server started on port $port")
_ <- ZIO.never
Expand Down
3 changes: 1 addition & 2 deletions examples/src/main/scala/example/ziohttp/ExampleApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import zio.http._
object ExampleApp extends ZIOAppDefault {
import sttp.tapir.json.circe._

private val graphiql = Handler.fromStream(ZStream.fromResource("graphiql.html")).toHttp
private val graphiql = Handler.fromStream(ZStream.fromResource("graphiql.html")).toHttp.withDefaultErrorResponse

override def run: ZIO[Any, Throwable, Unit] =
(for {
Expand All @@ -25,7 +25,6 @@ object ExampleApp extends ZIOAppDefault {
case _ -> !! / "ws" / "graphql" => ZHttpAdapter.makeWebSocketService(WebSocketInterpreter(interpreter))
case _ -> !! / "graphiql" => graphiql
}
.withDefaultErrorResponse
)
_ <- Console.printLine("Server online at http://localhost:8088/")
_ <- Console.printLine("Press RETURN to stop...") *> Console.readLine
Expand Down

0 comments on commit 0c17b43

Please sign in to comment.