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

Tools scala3 zio r17 #1248

Closed
wants to merge 154 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
6e465d0
Now working with RC21
pmeheut Jan 5, 2022
9f51745
Working in Scala 3 without scalafmt
pmeheut Jan 9, 2022
851f9ac
Now using scalafmt-interfaces, no more direct dependencies
pmeheut Jan 9, 2022
41de445
Now working with RC21
pmeheut Jan 5, 2022
8a9bdbd
Working in Scala 3 without scalafmt
pmeheut Jan 9, 2022
388e067
Now using scalafmt-interfaces, no more direct dependencies
pmeheut Jan 9, 2022
bc0937a
Merge branch 'tools_scala3' of github.com:pmeheut/caliban into tools_…
pmeheut Jan 9, 2022
d05ee75
Now using BuildInfo to load the correct version of scalafmt in Formatter
pmeheut Jan 10, 2022
7a565ed
Cleaned a few imports
pmeheut Jan 10, 2022
7da7c34
Fixed foromatting
pmeheut Jan 10, 2022
4adf826
Fixed formatting for build.sbt too
pmeheut Jan 10, 2022
768de78
removed a commented line in build.sbt
pmeheut Jan 10, 2022
b098573
Update laminext:core, laminext:fetch, ... to 0.14.3 (#1249)
scala-steward Jan 11, 2022
f14d1d2
added case in BigInt & BigDecimal default ScalarDecoder to account fo…
nicoburniske Jan 12, 2022
55dab61
Update play, play-akka-http-server to 2.8.13 (#1251)
scala-steward Jan 12, 2022
f2f2fd1
use fully-qualified name for Vector in generated code (#1254)
cornerman Jan 12, 2022
3a51a82
Update scala-library to 2.13.8 (#1257)
scala-steward Jan 14, 2022
93749dc
Fix typo
ghostdogpr Jan 14, 2022
cf566e9
[ci skip] update docs
ghostdogpr Jan 14, 2022
77b1829
Update config.yml (#1259)
ghostdogpr Jan 14, 2022
856a83b
feat: Relay cursors/connections (#1196)
frekw Jan 14, 2022
af5f53d
[ci skip] update docs
ghostdogpr Jan 14, 2022
9ca2e33
Resolve directive argument variables (#1263)
ghostdogpr Jan 17, 2022
bbde4aa
support uuid as arg encoder (#1266)
smiklos Jan 19, 2022
ba17d6a
Configure mdoc and fix documentation (#1268)
iRevive Jan 23, 2022
7c65281
[ci skip] update docs
ghostdogpr Jan 23, 2022
9a980eb
Update http4s-blaze-server to 0.23.8 (#1273)
scala-steward Jan 25, 2022
d46b7cc
docs module: do not enforce a specific scala version (#1274)
iRevive Jan 26, 2022
0714e10
Render directives at the top of the schema (#1270)
Fluxx Jan 28, 2022
fbb5e65
Update sbt-mdoc to 2.3.0 (#1276)
scala-steward Jan 28, 2022
49536fc
Add missing directive rendering for derrived types (#1275)
Fluxx Jan 28, 2022
5fb2862
Update cats-effect to 3.3.5 (#1277)
scala-steward Jan 29, 2022
e68647f
Update version in docs
ghostdogpr Jan 29, 2022
186ab5c
Fix typo
ghostdogpr Jan 29, 2022
e03f4ff
[ci skip] update docs
ghostdogpr Jan 29, 2022
566a72f
Fix typos
ghostdogpr Jan 29, 2022
82f6a4c
Merge branch 'master' of https://github.com/ghostdogpr/caliban
ghostdogpr Jan 29, 2022
485b75f
Retrigger docs
ghostdogpr Jan 29, 2022
84130d4
[ci skip] update docs
ghostdogpr Jan 29, 2022
5e8903d
Update http4s-blaze-server to 0.23.9 (#1278)
scala-steward Jan 29, 2022
c3471e4
Flatten SelectionBuilder zipping (#1212)
ghostdogpr Jan 30, 2022
d546773
Improve docs
ghostdogpr Jan 30, 2022
9fcd78b
[ci skip] update docs
ghostdogpr Jan 30, 2022
a1673fe
Add contextual interop between cats-effect and ZIO (#1246)
iRevive Jan 31, 2022
ab56de5
Adding parser logic for inputs and enums with empty bodies (#1283)
jyoo980 Feb 1, 2022
8f6e6a7
Update sbt to 1.6.2 (#1284)
scala-steward Feb 1, 2022
cd6ceb7
Update scala3-library, ... to 3.1.1 (#1285)
scala-steward Feb 2, 2022
4c809fd
Update http4s-blaze-server to 0.23.10 (#1286)
scala-steward Feb 3, 2022
b1801ce
fix: flaky Relay test (#1287)
frekw Feb 4, 2022
03aa1b6
Improve adapter ergonomics (#1288)
paulpdaniels Feb 6, 2022
d4d3876
Add schema reporting (#1280)
paulpdaniels Feb 6, 2022
6e4344a
Fix problems
ghostdogpr Feb 6, 2022
f1a05a1
[ci skip] update docs
ghostdogpr Feb 6, 2022
8071867
CompileTime plugin: Add missing links in doc (#1289)
guizmaii Feb 9, 2022
5214993
Update zio-interop-cats to 3.2.9.1 (#1290)
scala-steward Feb 13, 2022
593f4c8
Update sbt-scalajs, scalajs-compiler, ... to 1.9.0 (#1292)
scala-steward Feb 14, 2022
c521ba0
Update akka-http to 10.2.8 (#1291)
scala-steward Feb 14, 2022
8776f4a
Support passing interfaces to Types.makeObject (#1294)
Fluxx Feb 15, 2022
2e23b2d
Update tapir-akka-http-server, tapir-core, ... to 0.19.4 (#1297)
scala-steward Feb 16, 2022
0daae33
Update sbt-buildinfo to 0.11.0 (#1300)
scala-steward Feb 18, 2022
d52dd1f
Update compilerplugin, scalapb-runtime to 0.11.9 (#1301)
scala-steward Feb 22, 2022
5278247
Make sure relay validation errors gets propagated to the user (#1302)
SvenW Feb 23, 2022
d1ca0a8
Update sbt-mdoc to 2.3.1 (#1303)
scala-steward Feb 24, 2022
e818972
Handle Long as String (#1304)
mdulac Feb 25, 2022
228d64e
Fix relay connection from list (#1307)
dojusa Feb 25, 2022
11439b5
Make sure the subscription stream is interruptible (#1308)
ghostdogpr Feb 25, 2022
1ab9aa8
Update cats-effect to 3.3.6 (#1309)
scala-steward Feb 28, 2022
b537c4c
chore: update zio-http (#1216)
uryyyyyyy Mar 1, 2022
8e40261
Add forward and backward pagination (#1310)
dojusa Mar 1, 2022
8f3802d
Fix custom directive parsing in Scala 3 impl (#1313)
sergeykolbasov Mar 1, 2022
432d45b
Update version in docs
ghostdogpr Mar 1, 2022
7dda52b
[ci skip] update docs
ghostdogpr Mar 1, 2022
689c220
Contextual cats interop. Documentation (#1279)
iRevive Mar 1, 2022
1fb3ae0
[ci skip] update docs
ghostdogpr Mar 1, 2022
f6ffe4c
Update tapir-akka-http-server, tapir-core, ... to 0.20.1 (#1314)
scala-steward Mar 3, 2022
c5ecce5
Update akka-http to 10.2.9 (#1316)
scala-steward Mar 4, 2022
314ed9c
Add `Field.targets` to expose the type conditions of a field (#1315)
frekw Mar 5, 2022
2ea5345
Update cats-effect to 3.3.7 (#1318)
scala-steward Mar 8, 2022
ca596c9
Update compilerplugin, scalapb-runtime to 0.11.10 (#1320)
scala-steward Mar 13, 2022
b907058
Update http4s-blaze-server to 0.23.11 (#1323)
scala-steward Mar 19, 2022
9a8685d
Update cats-effect to 3.3.8 (#1324)
scala-steward Mar 19, 2022
043f87f
support lower-case content-type header (#1321)
frekw Mar 20, 2022
30d018e
Update sbt-scalajs-crossproject to 1.2.0 (#1327)
scala-steward Mar 22, 2022
fae36be
Update cats-effect to 3.3.9 (#1328)
scala-steward Mar 25, 2022
dcc406e
Update play, play-akka-http-server to 2.8.14 (#1329)
scala-steward Mar 25, 2022
9e4bf81
Update sbt-mdoc to 2.3.2 (#1330)
scala-steward Mar 27, 2022
d11ab23
Update README.md
ghostdogpr Mar 31, 2022
680ba02
Update README.md
ghostdogpr Mar 31, 2022
21f83f3
Update play, play-akka-http-server to 2.8.15 (#1331)
scala-steward Mar 31, 2022
fe1134e
Update cats-parse to 0.3.7 (#1332)
scala-steward Apr 2, 2022
ff8e93d
Update cats-effect to 3.3.10 (#1333)
scala-steward Apr 3, 2022
9154ee9
Update cats-effect to 3.3.11 (#1336)
scala-steward Apr 5, 2022
28dcbbc
Fix parsing of empty comment lines in Scala 3 (#1337)
sergeykolbasov Apr 8, 2022
6952cc2
Fix formatting
ghostdogpr Apr 8, 2022
48195e8
Update zio, zio-streams, zio-test, ... to 1.0.14 (#1340)
scala-steward Apr 13, 2022
d1408aa
make websocket stream interruptible in TapirAdapter (#1342)
moonkev Apr 14, 2022
fe93e6e
Add federation V2 (#1344)
paulpdaniels Apr 19, 2022
e12ed3d
Update zio-interop-reactivestreams to 1.3.10 (#1346)
scala-steward Apr 21, 2022
0771d76
Add BusinessChat.io to the list of adopters (#1349)
anasbarg Apr 25, 2022
b9b28ec
Add Conduktor to the list of adopters (#1350)
guizmaii Apr 25, 2022
95c5baf
Sort adopters alphabetically
ghostdogpr Apr 25, 2022
f55ee86
Fix rendering of object arguments to directives (#1353)
joheriks May 2, 2022
a9ddd2f
Update monix to 3.4.1 (#1357)
scala-steward May 7, 2022
4284606
adding Anduin Transactions to the adopter list (#1358)
ngbinh May 9, 2022
4d57c45
Update zio-interop-reactivestreams to 1.3.12 (#1359)
scala-steward May 13, 2022
739789d
Validate input types (#1347)
frekw May 13, 2022
d7fc993
Update tapir: 0.20.1 -> 0.20.2; zhttp: 1.0.0.0-RC25 -> 1.0.0.0-RC27 (…
strokyl May 18, 2022
4143637
Fix cache poisoning (#1362)
paulpdaniels May 20, 2022
4dfd73c
Update circe-core, circe-generic, ... to 0.14.2 (#1364)
scala-steward May 20, 2022
1818fa0
Support generated views with more than 22 fields (#1363)
ollyw May 20, 2022
543ebc6
Update cats-effect to 3.3.12 (#1366)
scala-steward May 21, 2022
6d39ce3
Add federation v2 docs (#1348)
paulpdaniels May 21, 2022
032c103
[ci skip] update docs
ghostdogpr May 21, 2022
cb36337
Update version in docs
ghostdogpr May 21, 2022
2eafac4
[ci skip] update docs
ghostdogpr May 21, 2022
680d4c9
upgrade zio-config to 2.0.0 (#1367)
chaoky May 23, 2022
fdca29b
Update http4s-blaze-server to 0.23.12 (#1368)
scala-steward May 25, 2022
108dc38
Properly validate floating point numbers on input (#1370)
moonkev May 27, 2022
72c37e3
Escape quotes in description strings (#1372)
joheriks May 31, 2022
c68232b
Improve persisted query performance by caching the document (#1371)
paulpdaniels May 31, 2022
a71d787
Escape special characters in normally quoted strings (#1373)
joheriks May 31, 2022
748776b
Correct field types for interface fields on union (#1375)
guymers Jun 2, 2022
c6deb1b
Coerce non-null values into lists of size one (#1376)
guymers Jun 4, 2022
63150a0
Client auto-gen Option conflict (#1377)
alterationx10 Jun 9, 2022
abaee7a
add support for graphql-transport-ws (#1354)
paulpdaniels Jun 12, 2022
50b1a65
Set api mappings for ZIO (#1381)
guymers Jun 19, 2022
d0b2ae7
Upgrade Scala.js to 1.10.0 (#1383)
gerdreiss Jun 20, 2022
1c2e72f
update documenation to align with updated ZQuery (#1384)
iida-hayato Jun 22, 2022
c2e272c
[ci skip] update docs
ghostdogpr Jun 22, 2022
a41cfc6
update tapir to 1.0.1 (#1386)
rolang Jun 23, 2022
18897f7
Update compilerplugin, scalapb-runtime to 0.11.11 (#1391)
scala-steward Jul 6, 2022
74e4dcd
Update play, play-akka-http-server to 2.8.16 (#1392)
scala-steward Jul 6, 2022
74eb595
Update zio, zio-streams, zio-test, ... to 1.0.15 (#1393)
scala-steward Jul 6, 2022
1c1aff4
Update scala-java-time to 2.4.0 (#1399)
scala-steward Jul 6, 2022
2730fde
Update sbt-scalajs, scalajs-compiler, ... to 1.10.1 (#1400)
scala-steward Jul 6, 2022
ceec49c
Update cats-effect to 3.3.13 (#1403)
scala-steward Jul 6, 2022
b3247ac
Update cats-parse to 0.3.8 (#1404)
scala-steward Jul 6, 2022
73ee88f
Update scala-library to 2.12.16 (#1401)
scala-steward Jul 6, 2022
089d895
Update scala3-library, ... to 3.1.3 (#1402)
scala-steward Jul 6, 2022
b3c36b4
Working again on codegen for scala3 and its tests
pmeheut Jul 8, 2022
7e1c4a7
Working again on codegen for scala3 and its tests
pmeheut Jul 8, 2022
fe82868
Scala 3 codegen plugin now working
pmeheut Jul 10, 2022
8e83cb9
Update sbt to 1.7.0 (#1406)
scala-steward Jul 11, 2022
2f24c8c
Update cats-effect to 3.3.14 (#1409)
scala-steward Jul 15, 2022
d0b6eb2
Update sbt to 1.7.1 (#1408)
scala-steward Jul 15, 2022
83ffede
Update zio, zio-streams, zio-test, ... to 1.0.16 (#1411)
scala-steward Jul 17, 2022
61351e2
build.sbt files are back to normal
pmeheut Jul 19, 2022
74582a8
Working again on codegen for scala3 and its tests
pmeheut Jul 8, 2022
f5f9228
Working again on codegen for scala3 and its tests
pmeheut Jul 8, 2022
998eaf3
Scala 3 codegen plugin now working
pmeheut Jul 10, 2022
6fbf71a
build.sbt files are back to normal
pmeheut Jul 19, 2022
aeec0df
Merge branch 'tools_to_merge_1' of github.com:pmeheut/caliban into to…
pmeheut Jul 19, 2022
cbb3420
Switched to scala 3.1.3 in codegen-sbt/src/sbt-test/compiletime-codeg…
pmeheut Jul 19, 2022
932cc36
Tapir to 1.0.2
pmeheut Jul 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 31 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ jobs:
- checkout
- restore_cache:
key: sbtcache
- run: sbt ++2.13.6! check
- run: sbt ++3.1.0! check
- run: sbt ++2.13.8 check
- run: sbt ++3.1.3 check
- save_cache:
key: sbtcache
paths:
Expand All @@ -22,7 +22,7 @@ jobs:
- checkout
- restore_cache:
key: sbtcache
- run: sbt ++2.12.14! core/test http4s/test akkaHttp/test play/test zioHttp/test examples/compile catsInterop/compile benchmarks/compile tools/test codegenSbt/test clientJVM/test monixInterop/compile tapirInterop/test federation/test
- run: sbt ++2.12.16! core/test http4s/test akkaHttp/test play/test zioHttp/test examples/compile catsInterop/compile benchmarks/compile tools/test codegenSbt/test clientJVM/test monixInterop/compile tapirInterop/test federation/test reporting/test
- save_cache:
key: sbtcache
paths:
Expand All @@ -36,7 +36,7 @@ jobs:
- checkout
- restore_cache:
key: sbtcache
- run: sbt ++2.12.14! core/test http4s/test akkaHttp/test play/test zioHttp/test examples/compile catsInterop/compile benchmarks/compile tools/test codegenSbt/test clientJVM/test monixInterop/compile tapirInterop/test federation/test
- run: sbt ++2.12.16 core/test http4s/test akkaHttp/test play/test zioHttp/test examples/compile catsInterop/compile benchmarks/compile tools/test codegenSbt/test clientJVM/test monixInterop/compile tapirInterop/test federation/test reporting/test
- save_cache:
key: sbtcache
paths:
Expand All @@ -50,7 +50,7 @@ jobs:
- checkout
- restore_cache:
key: sbtcache
- run: sbt ++2.12.14! codegenSbt/scripted
- run: sbt ++2.12.16 codegenSbt/scripted
- save_cache:
key: sbtcache
paths:
Expand All @@ -64,7 +64,7 @@ jobs:
- checkout
- restore_cache:
key: sbtcache
- run: sbt ++2.13.7! core/test http4s/test akkaHttp/test play/test zioHttp/test examples/compile catsInterop/compile monixInterop/compile tapirInterop/test clientJVM/test federation/test
- run: sbt ++2.13.8 core/test http4s/test akkaHttp/test play/test zioHttp/test examples/compile catsInterop/compile monixInterop/compile tapirInterop/test clientJVM/test federation/test reporting/test
- save_cache:
key: sbtcache
paths:
Expand All @@ -78,7 +78,7 @@ jobs:
- checkout
- restore_cache:
key: sbtcache
- run: sbt ++3.1.0! core/test catsInterop/compile monixInterop/compile clientJVM/test clientJS/compile zioHttp/test tapirInterop/test http4s/test federation/test
- run: sbt ++3.1.3 core/test catsInterop/compile monixInterop/compile clientJVM/test clientJS/compile zioHttp/test tapirInterop/test http4s/test federation/test reporting/test
- save_cache:
key: sbtcache
paths:
Expand All @@ -92,7 +92,23 @@ jobs:
- checkout
- restore_cache:
key: sbtcache
- run: sbt ++2.13.7! clientJS/test clientLaminextJS/Test/fastLinkJS
- run: sbt ++2.13.8 clientJS/test clientLaminextJS/Test/fastLinkJS
- save_cache:
key: sbtcache
paths:
- "~/.ivy2/cache"
- "~/.sbt"
- "~/.m2"
test213_docs:
docker:
- image: cimg/openjdk:11.0-node
steps:
- checkout
- restore_cache:
key: sbtcache
- run: |
sbt ++2.13.8 docs/mdoc
sbt "++2.13.8 doc"
- save_cache:
key: sbtcache
paths:
Expand Down Expand Up @@ -175,6 +191,12 @@ workflows:
filters:
tags:
only: /^v[0-9]+(\.[0-9]+)*$/
- test213_docs:
requires:
- lint
filters:
tags:
only: /^v[0-9]+(\.[0-9]+)*$/
- test3_jdk:
requires:
- lint
Expand All @@ -189,6 +211,7 @@ workflows:
- scripted212_jdk
- test213_jdk
- test213_js
- test213_docs
- test3_jdk
filters:
branches:
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ Here is a partial list of companies using Caliban in production.

Want to see your company here? [Submit a PR](https://github.com/ghostdogpr/caliban/edit/master/README.md)!

* [Anduin Transactions](https://www.anduintransact.com)
* [AutoScout24](https://www.autoscout24.de)
* [BusinessChat.io](https://businesschat.io)
* [Carvana](https://www.carvana.com)
* [Conduktor](https://www.conduktor.io)
* [Credimi](https://www.credimi.com)
* [Devsisters](https://www.devsisters.com)
* [Fugo.ai](https://www.fugo.ai)
Expand Down
44 changes: 33 additions & 11 deletions adapters/akka-http/src/main/scala/caliban/AkkaHttpAdapter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package caliban
import akka.http.scaladsl.server.Route
import akka.stream.scaladsl.{ Flow, Sink, Source }
import akka.stream.{ Materializer, OverflowStrategy }
import caliban.AkkaHttpAdapter.convertWebSocketEndpoint
import caliban.execution.QueryExecution
import caliban.interop.tapir.TapirAdapter.{ zioMonadError, CalibanPipe, ZioWebSockets }
import caliban.interop.tapir.{ RequestInterceptor, TapirAdapter, WebSocketHooks }
Expand All @@ -14,15 +15,16 @@ import sttp.tapir.Codec.JsonCodec
import sttp.tapir.PublicEndpoint
import sttp.tapir.model.ServerRequest
import sttp.tapir.server.ServerEndpoint
import sttp.tapir.server.akkahttp.AkkaHttpServerInterpreter
import sttp.tapir.server.akkahttp.{ AkkaHttpServerInterpreter, AkkaHttpServerOptions }
import zio._
import zio.duration._
import zio.random.Random
import zio.stream.ZStream

import scala.concurrent.{ ExecutionContext, Future }

object AkkaHttpAdapter {
class AkkaHttpAdapter private (private val options: AkkaHttpServerOptions)(implicit ec: ExecutionContext) {
private val akkaInterpreter = AkkaHttpServerInterpreter(options)(ec)

def makeHttpService[R, E](
interpreter: GraphQLInterpreter[R, E],
Expand All @@ -42,7 +44,7 @@ object AkkaHttpAdapter {
queryExecution,
requestInterceptor
)
AkkaHttpServerInterpreter().toRoute(endpoints.map(TapirAdapter.convertHttpEndpointToFuture(_)))
akkaInterpreter.toRoute(endpoints.map(TapirAdapter.convertHttpEndpointToFuture(_)))
}

def makeHttpUploadService[R, E](
Expand All @@ -64,7 +66,7 @@ object AkkaHttpAdapter {
queryExecution,
requestInterceptor
)
AkkaHttpServerInterpreter().toRoute(TapirAdapter.convertHttpEndpointToFuture(endpoint))
akkaInterpreter.toRoute(TapirAdapter.convertHttpEndpointToFuture(endpoint))
}

def makeWebSocketService[R, E](
Expand All @@ -91,27 +93,46 @@ object AkkaHttpAdapter {
requestInterceptor,
webSocketHooks
)
AkkaHttpServerInterpreter().toRoute(
akkaInterpreter.toRoute(
convertWebSocketEndpoint(
endpoint.asInstanceOf[
ServerEndpoint.Full[Unit, Unit, ServerRequest, StatusCode, CalibanPipe, ZioWebSockets, RIO[R, *]]
ServerEndpoint.Full[Unit, Unit, (ServerRequest, String), StatusCode, CalibanPipe, ZioWebSockets, RIO[R, *]]
]
)
)
}
}

object AkkaHttpAdapter {

def default(implicit ec: ExecutionContext): AkkaHttpAdapter =
apply(AkkaHttpServerOptions.default)

def apply(options: AkkaHttpServerOptions)(implicit ec: ExecutionContext): AkkaHttpAdapter =
new AkkaHttpAdapter(options)

type AkkaPipe = Flow[GraphQLWSInput, GraphQLWSOutput, Any]
type AkkaPipe = Flow[GraphQLWSInput, Either[GraphQLWSClose, GraphQLWSOutput], Any]

def convertWebSocketEndpoint[R](
endpoint: ServerEndpoint.Full[Unit, Unit, ServerRequest, StatusCode, CalibanPipe, ZioWebSockets, RIO[R, *]]
endpoint: ServerEndpoint.Full[Unit, Unit, (ServerRequest, String), StatusCode, CalibanPipe, ZioWebSockets, RIO[
R,
*
]]
)(implicit
ec: ExecutionContext,
runtime: Runtime[R],
materializer: Materializer
): ServerEndpoint[AkkaStreams with WebSockets, Future] =
ServerEndpoint[Unit, Unit, ServerRequest, StatusCode, AkkaPipe, AkkaStreams with WebSockets, Future](
ServerEndpoint[Unit, Unit, (ServerRequest, String), StatusCode, AkkaPipe, AkkaStreams with WebSockets, Future](
endpoint.endpoint
.asInstanceOf[PublicEndpoint[ServerRequest, StatusCode, Pipe[GraphQLWSInput, GraphQLWSOutput], Any]],
.asInstanceOf[
PublicEndpoint[
(ServerRequest, String),
StatusCode,
Pipe[GraphQLWSInput, Either[GraphQLWSClose, GraphQLWSOutput]],
Any
]
],
_ => _ => Future.successful(Right(())),
_ =>
_ =>
Expand All @@ -128,7 +149,8 @@ object AkkaHttpAdapter {
sink = Sink.foreachAsync[GraphQLWSInput](1)(input =>
runtime.unsafeRunToFuture(inputQueue.offer(input).unit).future
)
(queue, source) = Source.queue[GraphQLWSOutput](0, OverflowStrategy.fail).preMaterialize()
(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.unsafeRun(fiber.interrupt))
Expand Down
45 changes: 23 additions & 22 deletions adapters/akka-http/src/test/scala/caliban/AkkaHttpAdapterSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,56 @@ package caliban
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.server.Directives._
import akka.stream.Materializer
import caliban.interop.tapir.TestData.sampleCharacters
import caliban.interop.tapir.TestService.TestService
import caliban.interop.tapir.{ TapirAdapterSpec, TestApi, TestService }
import caliban.interop.tapir.{ FakeAuthorizationInterceptor, TapirAdapterSpec, TestApi, TestService }
import caliban.uploads.Uploads
import sttp.client3.UriContext
import sttp.tapir.json.circe._
import zio._
import zio.clock.Clock
import zio.console.Console
import zio.duration._
import zio.internal.Platform
import zio.random.Random
import zio.test.{ DefaultRunnableSpec, TestFailure, ZSpec }

import scala.concurrent.ExecutionContextExecutor
import scala.language.postfixOps

object AkkaHttpAdapterSpec extends DefaultRunnableSpec {

implicit val system: ActorSystem = ActorSystem()
implicit val executionContext: ExecutionContextExecutor = system.dispatcher
implicit val runtime: Runtime[TestService with Console with Clock with Random with Uploads] =
Runtime.unsafeFromLayer(
TestService.make(sampleCharacters) ++ Console.live ++ Clock.live ++ Random.live ++ Uploads.empty,
Platform.default
)

val apiLayer: ZLayer[zio.ZEnv, Throwable, Has[Unit]] =
val apiLayer: ZLayer[zio.ZEnv, Throwable, TestService] =
(for {
runtime <- ZManaged.runtime[TestService with Console with Clock with Random with Uploads]
system <- ZManaged.make(Task.effectTotal(ActorSystem()))(sys => ZIO.fromFuture(_ => sys.terminate()).ignore)
ec = system.dispatcher
mat = Materializer(system)
service <- ZManaged.service[TestService.Service]
interpreter <- TestApi.api.interpreter.toManaged_
adapter = AkkaHttpAdapter.default(ec)
route = path("api" / "graphql") {
AkkaHttpAdapter.makeHttpService(interpreter)
adapter.makeHttpService(interpreter, requestInterceptor = FakeAuthorizationInterceptor.bearer)(
runtime,
implicitly,
implicitly
)
} ~ path("upload" / "graphql") {
AkkaHttpAdapter.makeHttpUploadService(interpreter)
adapter.makeHttpUploadService(interpreter)(runtime, implicitly, implicitly, implicitly)
} ~ path("ws" / "graphql") {
AkkaHttpAdapter.makeWebSocketService(interpreter)
adapter.makeWebSocketService(interpreter)(ec, runtime, mat, implicitly, implicitly)
}
_ <- ZIO
.fromFuture(_ => Http().newServerAt("localhost", 8088).bind(route))
.toManaged(server =>
ZIO.fromFuture(_ => server.unbind()).ignore *> ZIO.fromFuture(_ => system.terminate()).ignore
)
_ <- ZIO.fromFuture { _ =>
implicit val s: ActorSystem = system
Http().newServerAt("localhost", 8088).bind(route)
}
.toManaged(server => ZIO.fromFuture(_ => server.unbind()).ignore)
_ <- clock.sleep(3 seconds).toManaged_
} yield ())
} yield service)
.provideCustomLayer(TestService.make(sampleCharacters) ++ Uploads.empty ++ Clock.live)
.toLayer

def spec: ZSpec[ZEnv, Any] = {
val suite: ZSpec[Has[Unit], Throwable] =
val suite: ZSpec[TestService, Throwable] =
TapirAdapterSpec.makeSuite(
"AkkaHttpAdapterSpec",
uri"http://localhost:8088/api/graphql",
Expand Down
Loading