From 3605837c5c20e57b4d40663e634dc9dffbbb3c39 Mon Sep 17 00:00:00 2001 From: Pierre Ricadat Date: Tue, 26 Dec 2023 14:35:28 +0900 Subject: [PATCH] Remove exit code from examples --- examples/src/main/scala/example/client/ExampleApp.scala | 6 ++---- .../src/main/scala/example/federation/v2/FederatedApp.scala | 3 +-- examples/src/main/scala/example/quick/AuthExampleApp.scala | 3 +-- examples/src/main/scala/example/stitching/ExampleApp.scala | 3 +-- examples/src/main/scala/example/tapir/ExampleApp.scala | 6 +++--- .../src/main/scala/example/ziohttp/AuthExampleApp.scala | 3 +-- 6 files changed, 9 insertions(+), 15 deletions(-) diff --git a/examples/src/main/scala/example/client/ExampleApp.scala b/examples/src/main/scala/example/client/ExampleApp.scala index 702ed4db8f..39bed2a077 100644 --- a/examples/src/main/scala/example/client/ExampleApp.scala +++ b/examples/src/main/scala/example/client/ExampleApp.scala @@ -21,7 +21,7 @@ object ExampleApp extends ZIOAppDefault { case class Character(name: String, nicknames: List[String], origin: Origin, role: Option[Role]) - override def run = { + def run = { val character = { import example.client.Client.Character._ (name ~ @@ -62,8 +62,6 @@ object ExampleApp extends ZIOAppDefault { val call1 = sendRequest(mutation.toRequest(uri)) val call2 = sendRequest(query.toRequest(uri, useVariables = true)) - (call1 *> call2) - .provideLayer(HttpClientZioBackend.layer()) - .exitCode + (call1 *> call2).provideLayer(HttpClientZioBackend.layer()) } } diff --git a/examples/src/main/scala/example/federation/v2/FederatedApp.scala b/examples/src/main/scala/example/federation/v2/FederatedApp.scala index 73cdccb662..3f2864a944 100644 --- a/examples/src/main/scala/example/federation/v2/FederatedApp.scala +++ b/examples/src/main/scala/example/federation/v2/FederatedApp.scala @@ -13,8 +13,7 @@ object FederatedApp extends ZIOAppDefault { val episodeServer = FederatedApi.Episodes.api.runServer(8089, "/api/graphql") - override def run = + def run = (characterServer race episodeServer) .provide(EpisodeService.make(sampleEpisodes), CharacterService.make(sampleCharacters)) - .exitCode } diff --git a/examples/src/main/scala/example/quick/AuthExampleApp.scala b/examples/src/main/scala/example/quick/AuthExampleApp.scala index 15ecf853fd..ebc4923e9f 100644 --- a/examples/src/main/scala/example/quick/AuthExampleApp.scala +++ b/examples/src/main/scala/example/quick/AuthExampleApp.scala @@ -58,7 +58,7 @@ object Authed extends GenericSchema[Auth] { object AuthExampleApp extends ZIOAppDefault { - override def run: URIO[Any, ExitCode] = + def run = (for { exampleApi <- ZIO.service[GraphQL[Any]] handlers <- (exampleApi |+| Authed.api).handlers.map(_ @@ Auth.middleware) @@ -78,5 +78,4 @@ object AuthExampleApp extends ZIOAppDefault { Auth.http, Server.defaultWithPort(8090) ) - .exitCode } diff --git a/examples/src/main/scala/example/stitching/ExampleApp.scala b/examples/src/main/scala/example/stitching/ExampleApp.scala index 536fd06db1..35c774dedd 100644 --- a/examples/src/main/scala/example/stitching/ExampleApp.scala +++ b/examples/src/main/scala/example/stitching/ExampleApp.scala @@ -107,7 +107,7 @@ object ExampleApp extends ZIOAppDefault { private val graphiql = Handler.fromResource("graphiql.html").sandbox - override def run = + def run = (for { api <- StitchingExample.api interpreter <- api.interpreter @@ -129,5 +129,4 @@ object ExampleApp extends ZIOAppDefault { Configuration.fromEnvironment, Server.default ) - .exitCode } diff --git a/examples/src/main/scala/example/tapir/ExampleApp.scala b/examples/src/main/scala/example/tapir/ExampleApp.scala index 39173759a5..ff33a4ed0e 100644 --- a/examples/src/main/scala/example/tapir/ExampleApp.scala +++ b/examples/src/main/scala/example/tapir/ExampleApp.scala @@ -43,8 +43,8 @@ object ExampleApp extends CatsApp { private implicit val network: Network[MyTask] = Network.forAsync - override def run = - (for { + def run = + for { interpreter <- graphql.interpreter _ <- EmberServerBuilder .default[MyTask] @@ -60,5 +60,5 @@ object ExampleApp extends CatsApp { .toScopedZIO _ <- Console.printLine("Server online at http://localhost:8088/\nPress RETURN to stop...") _ <- Console.readLine - } yield ()).exitCode + } yield () } diff --git a/examples/src/main/scala/example/ziohttp/AuthExampleApp.scala b/examples/src/main/scala/example/ziohttp/AuthExampleApp.scala index c263db4db5..8466e9f099 100644 --- a/examples/src/main/scala/example/ziohttp/AuthExampleApp.scala +++ b/examples/src/main/scala/example/ziohttp/AuthExampleApp.scala @@ -84,7 +84,7 @@ object Authed extends GenericSchema[Auth] { object AuthExampleApp extends ZIOAppDefault { private val graphiql = Handler.fromResource("graphiql.html").sandbox - override def run: URIO[Any, ExitCode] = + def run = (for { exampleApi <- ZIO.service[GraphQL[Any]] interpreter <- (exampleApi |+| Authed.api).interpreter @@ -107,5 +107,4 @@ object AuthExampleApp extends ZIOAppDefault { ZLayer.succeed(Server.Config.default.port(8088)), Server.live ) - .exitCode }