diff --git a/core/src/main/scala/caliban/execution/Executor.scala b/core/src/main/scala/caliban/execution/Executor.scala index 2329f4387..73d6cf0f0 100644 --- a/core/src/main/scala/caliban/execution/Executor.scala +++ b/core/src/main/scala/caliban/execution/Executor.scala @@ -58,6 +58,9 @@ object Executor { case QueryExecution.Batched => ZQuery.foreachBatched(in)(as) case QueryExecution.Parallel => ZQuery.foreachPar(in)(as) case QueryExecution.Sequential => ZQuery.foreach(in)(as) + case QueryExecution.Mixed => + if (isTopLevelField) ZQuery.foreachPar(in)(as) + else ZQuery.foreachBatched(in)(as) } } diff --git a/core/src/main/scala/caliban/execution/QueryExecution.scala b/core/src/main/scala/caliban/execution/QueryExecution.scala index 7716b4abb..d79ccc08f 100644 --- a/core/src/main/scala/caliban/execution/QueryExecution.scala +++ b/core/src/main/scala/caliban/execution/QueryExecution.scala @@ -19,7 +19,13 @@ object QueryExecution { /** * Run effectful fields sequentially but batch effects wrapped with `ZQuery.fromRequest`. - * This mode is recommended when most of your effects are relying on ZQuery as it avoids forking unnecessary fibers. + * This mode is recommended when most of your effects are backed by ZQuery DataSources as it avoids forking unnecessary fibers. */ case object Batched extends QueryExecution + + /** + * Run effectful top-level fields in [[Parallel]] mode and nested fields in [[Batched]] mode. + * This mode is recommended when most of your effects are backed by ZQuery DataSources but want to guarantee that top-level fields are always executed in parallel. + */ + case object Mixed extends QueryExecution }