Skip to content

Commit

Permalink
Remove align.preset = most from scalafmt
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindberg committed May 8, 2024
1 parent a0b0287 commit b690087
Show file tree
Hide file tree
Showing 265 changed files with 3,700 additions and 3,700 deletions.
1 change: 0 additions & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
version = "3.8.1"
runner.dialect = scala213
maxColumn = 120
align.preset = most
continuationIndent.defnSite = 2
assumeStandardLibraryStripMargin = true
docstrings.style = Asterisk
Expand Down
18 changes: 9 additions & 9 deletions adapters/akka-http/src/main/scala/caliban/AkkaHttpAdapter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ object AkkaHttpAdapter {
.flatMap { case (protocol, pipe) =>
val io =
for {
inputQueue <- Queue.unbounded[GraphQLWSInput]
input = ZStream.fromQueue(inputQueue)
output = pipe(input)
ec <- ZIO.executor.map(_.asExecutionContext)
sink =
inputQueue <- Queue.unbounded[GraphQLWSInput]
input = ZStream.fromQueue(inputQueue)
output = pipe(input)
ec <- ZIO.executor.map(_.asExecutionContext)
sink =
Sink.foreachAsync[GraphQLWSInput](1)(input =>
Unsafe
.unsafe(implicit u => runtime.unsafe.runToFuture(inputQueue.offer(input).unit).future)
Expand All @@ -183,10 +183,10 @@ object AkkaHttpAdapter {
Source
.queue[Either[GraphQLWSClose, GraphQLWSOutput]](0, OverflowStrategy.fail)
.preMaterialize()
fiber <- output.foreach(msg => ZIO.fromFuture(_ => queue.offer(msg))).forkDaemon
flow = Flow.fromSinkAndSourceCoupled(sink, source).watchTermination() { (_, f) =>
f.onComplete(_ => runtime.unsafe.run(fiber.interrupt).getOrThrowFiberFailure())(ec)
}
fiber <- output.foreach(msg => ZIO.fromFuture(_ => queue.offer(msg))).forkDaemon
flow = Flow.fromSinkAndSourceCoupled(sink, source).watchTermination() { (_, f) =>
f.onComplete(_ => runtime.unsafe.run(fiber.interrupt).getOrThrowFiberFailure())(ec)
}
} yield (protocol, flow)

io
Expand Down
42 changes: 21 additions & 21 deletions adapters/akka-http/src/test/scala/caliban/AkkaHttpAdapterSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,28 @@ object AkkaHttpAdapterSpec extends ZIOSpecDefault {

private val apiLayer = envLayer >>> ZLayer.scoped {
for {
runtime <- ZIO.runtime[TestService with Uploads]
system <- ZIO.succeed(ActorSystem()).withFinalizer(sys => ZIO.fromFuture(_ => sys.terminate()).ignore)
ec = system.dispatcher
mat = Materializer(system)
runtime <- ZIO.runtime[TestService with Uploads]
system <- ZIO.succeed(ActorSystem()).withFinalizer(sys => ZIO.fromFuture(_ => sys.terminate()).ignore)
ec = system.dispatcher
mat = Materializer(system)
interpreter <- TestApi.api.interpreter
adapter = AkkaHttpAdapter.default(ec)
route = path("api" / "graphql") {
adapter
.makeHttpService(
HttpInterpreter(interpreter).intercept(FakeAuthorizationInterceptor.bearer[TestService & Uploads])
)(runtime, mat)
} ~ path("upload" / "graphql") {
adapter.makeHttpUploadService(HttpUploadInterpreter(interpreter))(runtime, mat, implicitly, implicitly)
} ~ path("ws" / "graphql") {
adapter.makeWebSocketService(WebSocketInterpreter(interpreter))(runtime, mat)
}
_ <- ZIO.fromFuture { _ =>
implicit val s: ActorSystem = system
Http().newServerAt("localhost", 8086).bind(route)
}.withFinalizer(server => ZIO.fromFuture(_ => server.unbind()).ignore)
_ <- Live.live(Clock.sleep(3 seconds))
service <- ZIO.service[TestService]
adapter = AkkaHttpAdapter.default(ec)
route = path("api" / "graphql") {
adapter
.makeHttpService(
HttpInterpreter(interpreter).intercept(FakeAuthorizationInterceptor.bearer[TestService & Uploads])
)(runtime, mat)
} ~ path("upload" / "graphql") {
adapter.makeHttpUploadService(HttpUploadInterpreter(interpreter))(runtime, mat, implicitly, implicitly)
} ~ path("ws" / "graphql") {
adapter.makeWebSocketService(WebSocketInterpreter(interpreter))(runtime, mat)
}
_ <- ZIO.fromFuture { _ =>
implicit val s: ActorSystem = system
Http().newServerAt("localhost", 8086).bind(route)
}.withFinalizer(server => ZIO.fromFuture(_ => server.unbind()).ignore)
_ <- Live.live(Clock.sleep(3 seconds))
service <- ZIO.service[TestService]
} yield service
}

Expand Down
4 changes: 2 additions & 2 deletions adapters/http4s/src/main/scala/caliban/Http4sAdapter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object Http4sAdapter {
def makeHttpServiceF[F[_]: Async, R, E](
interpreter: HttpInterpreter[R, E]
)(implicit interop: ToEffect[F, R]): HttpRoutes[F] = {
val endpoints = interpreter.serverEndpoints[R, Fs2Streams[F]](Fs2Streams[F])
val endpoints = interpreter.serverEndpoints[R, Fs2Streams[F]](Fs2Streams[F])
val endpointsF = endpoints.map(convertHttpEndpointToF[F, R])
Http4sServerInterpreter().toRoutes(endpointsF)
}
Expand All @@ -47,7 +47,7 @@ object Http4sAdapter {
requestCodec: JsonCodec[GraphQLRequest],
mapCodec: JsonCodec[Map[String, Seq[String]]]
): HttpRoutes[F] = {
val endpoint = interpreter.serverEndpoint[R, Fs2Streams[F]](Fs2Streams[F])
val endpoint = interpreter.serverEndpoint[R, Fs2Streams[F]](Fs2Streams[F])
val endpointF = convertHttpEndpointToF[F, R](endpoint)
Http4sServerInterpreter().toRoutes(endpointF)
}
Expand Down
52 changes: 26 additions & 26 deletions adapters/http4s/src/test/scala/caliban/Http4sAdapterSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import scala.language.postfixOps

object Http4sAdapterSpec extends ZIOSpecDefault {

type Env = TestService with Uploads
type Env = TestService with Uploads
type TestTask[A] = RIO[Env, A]

private implicit val network: Network[TestTask] = Network.forAsync[TestTask]
Expand All @@ -44,31 +44,31 @@ object Http4sAdapterSpec extends ZIOSpecDefault {
) = envLayer >>> ZLayer.scoped {
for {
interpreter <- TestApi.api.interpreter
_ <- EmberServerBuilder
.default[TestTask]
.withHost(host"localhost")
.withPort(port"8087")
.withHttpWebSocketApp(wsBuilder =>
Router[TestTask](
"/api/graphql" -> CORS.policy(
Http4sAdapter.makeHttpService[Env, CalibanError](
HttpInterpreter(interpreter).intercept(FakeAuthorizationInterceptor.bearer[Env])
)
),
"/upload/graphql" -> CORS.policy(
Http4sAdapter.makeHttpUploadService[Env, CalibanError](HttpUploadInterpreter(interpreter))
),
"/ws/graphql" -> CORS.policy(
Http4sAdapter
.makeWebSocketService[Env, Env, CalibanError](wsBuilder, WebSocketInterpreter(interpreter))
)
).orNotFound
)
.build
.toScopedZIO
.forkScoped
_ <- Live.live(Clock.sleep(3 seconds))
service <- ZIO.service[TestService]
_ <- EmberServerBuilder
.default[TestTask]
.withHost(host"localhost")
.withPort(port"8087")
.withHttpWebSocketApp(wsBuilder =>
Router[TestTask](
"/api/graphql" -> CORS.policy(
Http4sAdapter.makeHttpService[Env, CalibanError](
HttpInterpreter(interpreter).intercept(FakeAuthorizationInterceptor.bearer[Env])
)
),
"/upload/graphql" -> CORS.policy(
Http4sAdapter.makeHttpUploadService[Env, CalibanError](HttpUploadInterpreter(interpreter))
),
"/ws/graphql" -> CORS.policy(
Http4sAdapter
.makeWebSocketService[Env, Env, CalibanError](wsBuilder, WebSocketInterpreter(interpreter))
)
).orNotFound
)
.build
.toScopedZIO
.forkScoped
_ <- Live.live(Clock.sleep(3 seconds))
service <- ZIO.service[TestService]
} yield service
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ object PekkoHttpAdapter {
.flatMap { case (protocol, pipe) =>
val io =
for {
inputQueue <- Queue.unbounded[GraphQLWSInput]
input = ZStream.fromQueue(inputQueue)
output = pipe(input)
ec <- ZIO.executor.map(_.asExecutionContext)
sink =
inputQueue <- Queue.unbounded[GraphQLWSInput]
input = ZStream.fromQueue(inputQueue)
output = pipe(input)
ec <- ZIO.executor.map(_.asExecutionContext)
sink =
Sink.foreachAsync[GraphQLWSInput](1)(input =>
Unsafe
.unsafe(implicit u => runtime.unsafe.runToFuture(inputQueue.offer(input).unit).future)
Expand All @@ -183,10 +183,10 @@ object PekkoHttpAdapter {
Source
.queue[Either[GraphQLWSClose, GraphQLWSOutput]](0, OverflowStrategy.fail)
.preMaterialize()
fiber <- output.foreach(msg => ZIO.fromFuture(_ => queue.offer(msg))).forkDaemon
flow = Flow.fromSinkAndSourceCoupled(sink, source).watchTermination() { (_, f) =>
f.onComplete(_ => runtime.unsafe.run(fiber.interrupt).getOrThrowFiberFailure())(ec)
}
fiber <- output.foreach(msg => ZIO.fromFuture(_ => queue.offer(msg))).forkDaemon
flow = Flow.fromSinkAndSourceCoupled(sink, source).watchTermination() { (_, f) =>
f.onComplete(_ => runtime.unsafe.run(fiber.interrupt).getOrThrowFiberFailure())(ec)
}
} yield (protocol, flow)

io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,28 @@ object PekkoHttpAdapterSpec extends ZIOSpecDefault {

private val apiLayer = envLayer >>> ZLayer.scoped {
for {
runtime <- ZIO.runtime[TestService with Uploads]
system <- ZIO.succeed(ActorSystem()).withFinalizer(sys => ZIO.fromFuture(_ => sys.terminate()).ignore)
ec = system.dispatcher
mat = Materializer(system)
runtime <- ZIO.runtime[TestService with Uploads]
system <- ZIO.succeed(ActorSystem()).withFinalizer(sys => ZIO.fromFuture(_ => sys.terminate()).ignore)
ec = system.dispatcher
mat = Materializer(system)
interpreter <- TestApi.api.interpreter
adapter = PekkoHttpAdapter.default(ec)
route = path("api" / "graphql") {
adapter
.makeHttpService(
HttpInterpreter(interpreter).intercept(FakeAuthorizationInterceptor.bearer[TestService & Uploads])
)(runtime, mat)
} ~ path("upload" / "graphql") {
adapter.makeHttpUploadService(HttpUploadInterpreter(interpreter))(runtime, mat, implicitly, implicitly)
} ~ path("ws" / "graphql") {
adapter.makeWebSocketService(WebSocketInterpreter(interpreter))(runtime, mat)
}
_ <- ZIO.fromFuture { _ =>
implicit val s: ActorSystem = system
Http().newServerAt("localhost", 8085).bind(route)
}.withFinalizer(server => ZIO.fromFuture(_ => server.unbind()).ignore)
_ <- Live.live(Clock.sleep(3 seconds))
service <- ZIO.service[TestService]
adapter = PekkoHttpAdapter.default(ec)
route = path("api" / "graphql") {
adapter
.makeHttpService(
HttpInterpreter(interpreter).intercept(FakeAuthorizationInterceptor.bearer[TestService & Uploads])
)(runtime, mat)
} ~ path("upload" / "graphql") {
adapter.makeHttpUploadService(HttpUploadInterpreter(interpreter))(runtime, mat, implicitly, implicitly)
} ~ path("ws" / "graphql") {
adapter.makeWebSocketService(WebSocketInterpreter(interpreter))(runtime, mat)
}
_ <- ZIO.fromFuture { _ =>
implicit val s: ActorSystem = system
Http().newServerAt("localhost", 8085).bind(route)
}.withFinalizer(server => ZIO.fromFuture(_ => server.unbind()).ignore)
_ <- Live.live(Clock.sleep(3 seconds))
service <- ZIO.service[TestService]
} yield service
}

Expand Down
18 changes: 9 additions & 9 deletions adapters/play/src/main/scala/caliban/PlayAdapter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -182,22 +182,22 @@ object PlayAdapter extends PlayAdapter(None) {
.flatMap { case (protocol, pipe) =>
val io =
for {
inputQueue <- Queue.unbounded[GraphQLWSInput]
input = ZStream.fromQueue(inputQueue)
output = pipe(input)
ec <- ZIO.executor.map(_.asExecutionContext)
sink =
inputQueue <- Queue.unbounded[GraphQLWSInput]
input = ZStream.fromQueue(inputQueue)
output = pipe(input)
ec <- ZIO.executor.map(_.asExecutionContext)
sink =
Sink.foreachAsync[GraphQLWSInput](1)(input =>
Unsafe.unsafe(implicit u => runtime.unsafe.runToFuture(inputQueue.offer(input).unit).future)
)
(queue, source) =
Source
.queue[Either[GraphQLWSClose, GraphQLWSOutput]](0, OverflowStrategy.fail)
.preMaterialize()
fiber <- output.foreach(msg => ZIO.fromFuture(_ => queue.offer(msg))).forkDaemon
flow = Flow.fromSinkAndSourceCoupled(sink, source).watchTermination() { (_, f) =>
f.onComplete(_ => runtime.unsafe.run(fiber.interrupt).getOrThrowFiberFailure())(ec)
}
fiber <- output.foreach(msg => ZIO.fromFuture(_ => queue.offer(msg))).forkDaemon
flow = Flow.fromSinkAndSourceCoupled(sink, source).watchTermination() { (_, f) =>
f.onComplete(_ => runtime.unsafe.run(fiber.interrupt).getOrThrowFiberFailure())(ec)
}
} yield (protocol, flow)

io
Expand Down
62 changes: 31 additions & 31 deletions adapters/play/src/test/scala/caliban/PlayAdapterSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,38 @@ object PlayAdapterSpec extends ZIOSpecDefault {

private val apiLayer = envLayer >>> ZLayer.scoped {
for {
system <- ZIO.succeed(ActorSystem()).withFinalizer(sys => ZIO.fromFuture(_ => sys.terminate()).ignore)
mat = Materializer(system)
runtime <- ZIO.runtime[TestService with Uploads]
system <- ZIO.succeed(ActorSystem()).withFinalizer(sys => ZIO.fromFuture(_ => sys.terminate()).ignore)
mat = Materializer(system)
runtime <- ZIO.runtime[TestService with Uploads]
interpreter <- TestApi.api.interpreter
router = Router.from {
case req @ (GET(p"/api/graphql") | POST(p"/api/graphql")) =>
PlayAdapter
.makeHttpService(
HttpInterpreter(interpreter)
.intercept(FakeAuthorizationInterceptor.bearer[TestService & Uploads])
)(runtime, mat)
.apply(req)
case req @ POST(p"/upload/graphql") =>
PlayAdapter
.makeHttpUploadService(HttpUploadInterpreter(interpreter))(runtime, mat, implicitly, implicitly)
.apply(req)
case req @ GET(p"/ws/graphql") =>
PlayAdapter.makeWebSocketService(WebSocketInterpreter(interpreter))(runtime, mat).apply(req)
}
_ <- ZIO
.attempt(
PekkoHttpServer.fromRouterWithComponents(
ServerConfig(
mode = Mode.Dev,
port = Some(8088),
address = "127.0.0.1"
)
)(_ => router.routes)
)
.withFinalizer(server => ZIO.attempt(server.stop()).ignore)
_ <- Live.live(Clock.sleep(3 seconds))
service <- ZIO.service[TestService]
router = Router.from {
case req @ (GET(p"/api/graphql") | POST(p"/api/graphql")) =>
PlayAdapter
.makeHttpService(
HttpInterpreter(interpreter)
.intercept(FakeAuthorizationInterceptor.bearer[TestService & Uploads])
)(runtime, mat)
.apply(req)
case req @ POST(p"/upload/graphql") =>
PlayAdapter
.makeHttpUploadService(HttpUploadInterpreter(interpreter))(runtime, mat, implicitly, implicitly)
.apply(req)
case req @ GET(p"/ws/graphql") =>
PlayAdapter.makeWebSocketService(WebSocketInterpreter(interpreter))(runtime, mat).apply(req)
}
_ <- ZIO
.attempt(
PekkoHttpServer.fromRouterWithComponents(
ServerConfig(
mode = Mode.Dev,
port = Some(8088),
address = "127.0.0.1"
)
)(_ => router.routes)
)
.withFinalizer(server => ZIO.attempt(server.stop()).ignore)
_ <- Live.live(Clock.sleep(3 seconds))
service <- ZIO.service[TestService]
} yield service
}

Expand Down
10 changes: 5 additions & 5 deletions adapters/quick/src/main/scala/caliban/QuickAdapter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ final class QuickAdapter[-R] private (requestHandler: QuickRequestHandler[R]) {
uploadPath: Option[String] = None,
webSocketPath: Option[String] = None
): HttpApp[R] = {
val apiRoutes = List(
val apiRoutes = List(
RoutePattern(Method.POST, apiPath) -> handlers.api,
RoutePattern(Method.GET, apiPath) -> handlers.api
RoutePattern(Method.GET, apiPath) -> handlers.api
)
val graphiqlRoute = graphiqlPath.toList.map { uiPath =>
RoutePattern(Method.GET, uiPath) -> GraphiQLHandler.handler(apiPath, uiPath)
}
val uploadRoute = uploadPath.toList.map { uPath =>
val uploadRoute = uploadPath.toList.map { uPath =>
RoutePattern(Method.POST, uPath) -> handlers.upload
}
val wsRoute = webSocketPath.toList.map { wsPath =>
val wsRoute = webSocketPath.toList.map { wsPath =>
RoutePattern(Method.ANY, wsPath) -> handlers.webSocket
}
Routes.fromIterable(apiRoutes ::: graphiqlRoute ::: uploadRoute ::: wsRoute).toHttpApp
Expand Down Expand Up @@ -103,7 +103,7 @@ object QuickAdapter {
): ZLayer[GraphQL[R] & ExecutionConfiguration, CalibanError.ValidationError, QuickAdapter[R]] =
ZLayer.fromZIO(
for {
config <- ZIO.service[ExecutionConfiguration]
config <- ZIO.service[ExecutionConfiguration]
interpreter <- ZIO.serviceWithZIO[GraphQL[R]](_.interpreter)
} yield QuickAdapter(interpreter).configure(config)
)
Expand Down

0 comments on commit b690087

Please sign in to comment.