diff --git a/build.sbt b/build.sbt index 99fa7a0730..d85bc91d17 100644 --- a/build.sbt +++ b/build.sbt @@ -29,7 +29,7 @@ val zioInteropCats2Version = "22.0.0.0" val zioInteropCats3Version = "23.0.0.8" val zioInteropReactiveVersion = "2.0.2" val zioConfigVersion = "3.0.7" -val zqueryVersion = "0.5.1" +val zqueryVersion = "0.6.0" val zioJsonVersion = "0.6.2" val zioHttpVersion = "3.0.0-RC4" val zioOpenTelemetryVersion = "3.0.0-RC15" diff --git a/core/src/main/scala/caliban/execution/Executor.scala b/core/src/main/scala/caliban/execution/Executor.scala index a92b67a4dc..ee7754e08c 100644 --- a/core/src/main/scala/caliban/execution/Executor.scala +++ b/core/src/main/scala/caliban/execution/Executor.scala @@ -274,7 +274,7 @@ object Executor { ZStream.succeed(resp) ++ makeDeferStream(more, cache) }) - ZStream.mergeAll(1)(defers.map(run): _*) + ZStream.mergeAllUnbounded()(defers.map(run): _*) } def runIncrementalQuery( diff --git a/examples/src/main/scala/example/optimizations/OptimizedTest.scala b/examples/src/main/scala/example/optimizations/OptimizedTest.scala index 4bbcfc8346..1460c258d5 100644 --- a/examples/src/main/scala/example/optimizations/OptimizedTest.scala +++ b/examples/src/main/scala/example/optimizations/OptimizedTest.scala @@ -1,8 +1,8 @@ package example.optimizations -import caliban.schema.Schema -import caliban.schema.ArgBuilder.auto._ import caliban._ +import caliban.schema.ArgBuilder.auto._ +import caliban.schema.Schema import example.optimizations.CommonData._ import zio.Console.printLine import zio.query.DataSource.fromFunctionBatchedZIO @@ -57,44 +57,48 @@ object OptimizedTest extends ZIOAppDefault { val UserDataSource: DataSource[Any, GetUser] = DataSource.Batched.make("UserDataSource") { requests => requests.toList match { case head :: Nil => - printLine("getUser").orDie.as(CompletedRequestMap.empty.insert(head)(Exit.succeed(fakeUser(head.id)))) + printLine("getUser").orDie.as(CompletedRequestMap.empty.insert(head, Exit.succeed(fakeUser(head.id)))) case list => printLine("getUsers").orDie.as(list.foldLeft(CompletedRequestMap.empty) { case (map, req) => - map.insert(req)(Exit.succeed(fakeUser(req.id))) + map.insert(req, Exit.succeed(fakeUser(req.id))) }) } } case class GetEvent(id: Int) extends Request[Nothing, EventData] val EventDataSource: DataSource[Any, GetEvent] = - fromFunctionBatchedZIO("EventDataSource")(requests => printLine("getEvents").as(requests.map(r => fakeEvent(r.id)))) + fromFunctionBatchedZIO("EventDataSource")(requests => + printLine("getEvents").orDie.as(requests.map(r => fakeEvent(r.id))) + ) case class GetViewerMetadataForEvents(id: Int) extends Request[Nothing, ViewerMetadata] val ViewerMetadataDataSource: DataSource[Any, GetViewerMetadataForEvents] = fromFunctionBatchedZIO("ViewerMetadataDataSource") { requests => - printLine("getViewerMetadataForEvents").as(requests.map(_ => ViewerMetadata(""))) + printLine("getViewerMetadataForEvents").orDie.as(requests.map(_ => ViewerMetadata(""))) } case class GetVenue(id: Int) extends Request[Nothing, Venue] val VenueDataSource: DataSource[Any, GetVenue] = - fromFunctionBatchedZIO("VenueDataSource")(requests => printLine("getVenues").as(requests.map(_ => Venue("venue")))) + fromFunctionBatchedZIO("VenueDataSource")(requests => + printLine("getVenues").orDie.as(requests.map(_ => Venue("venue"))) + ) case class GetTags(ids: List[Int]) extends Request[Nothing, List[Tag]] val TagsDataSource: DataSource[Any, GetTags] = fromFunctionBatchedZIO("TagsDataSource") { requests => - printLine("getTags").as(requests.map(_.ids.map(id => Tag(id.toString)))) + printLine("getTags").orDie.as(requests.map(_.ids.map(id => Tag(id.toString)))) } case class GetViewerFriendIdsAttendingEvent(id: Int, first: Int) extends Request[Nothing, List[Int]] val ViewerFriendDataSource: DataSource[Any, GetViewerFriendIdsAttendingEvent] = fromFunctionBatchedZIO("ViewerFriendDataSource") { requests => - printLine("getViewerFriendIdsAttendingEvent").as(requests.map(r => (1 to r.first).toList)) + printLine("getViewerFriendIdsAttendingEvent").orDie.as(requests.map(r => (1 to r.first).toList)) } case class GetUpcomingEventIdsForUser(id: Int, first: Int) extends Request[Nothing, List[Int]] val UpcomingEventDataSource: DataSource[Any, GetUpcomingEventIdsForUser] = fromFunctionBatchedZIO("UpcomingEventDataSource") { requests => - printLine("getUpcomingEventIdsForUser").as(requests.map(r => (1 to r.first).toList)) + printLine("getUpcomingEventIdsForUser").orDie.as(requests.map(r => (1 to r.first).toList)) } def getUser(id: Int): ConsoleQuery[UserData] = ZQuery.fromRequest(GetUser(id))(UserDataSource) diff --git a/tracing/src/test/scala/caliban/tracing/TracingWrapperSpec.scala b/tracing/src/test/scala/caliban/tracing/TracingWrapperSpec.scala index 871c7ee019..cdd257a9e5 100644 --- a/tracing/src/test/scala/caliban/tracing/TracingWrapperSpec.scala +++ b/tracing/src/test/scala/caliban/tracing/TracingWrapperSpec.scala @@ -17,7 +17,7 @@ object TracingWrapperSpec extends ZIOSpecDefault { override val identifier: String = "NamesDatasource" override def run(requests: Chunk[GetName])(implicit trace: zio.Trace): ZIO[Any, Nothing, CompletedRequestMap] = ZIO.succeed(requests.foldLeft(CompletedRequestMap.empty) { case (map, req) => - map.insert(req)(Exit.succeed(req.name)) + map.insert(req, Exit.succeed(req.name)) }) }