From 8ac4934b99171c273487371a1acce52df095f45c Mon Sep 17 00:00:00 2001 From: Kyri Petrou Date: Sun, 17 Dec 2023 21:08:02 +1100 Subject: [PATCH] Use `mapChunksZIO` on streams instead of `mapZIO` --- core/src/main/scala/caliban/execution/Executor.scala | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/src/main/scala/caliban/execution/Executor.scala b/core/src/main/scala/caliban/execution/Executor.scala index 1311fde84a..e3ab4139c7 100644 --- a/core/src/main/scala/caliban/execution/Executor.scala +++ b/core/src/main/scala/caliban/execution/Executor.scala @@ -239,12 +239,11 @@ object Executor { case ReducedStep.ListStep(steps, areItemsNullable) => makeListQuery(steps, areItemsNullable) case ReducedStep.StreamStep(stream) => ZQuery - .environment[R] - .map(env => + .environmentWith[R](env => ResponseValue.StreamValue( - stream - .mapZIO(loop(_).catchAll(_ => ZQuery.succeed(NullValue)).run) - .provideEnvironment(env) + stream.mapChunksZIO { chunk => + collectAll(chunk, isTopLevelField)(loop(_).catchAll(_ => ZQuery.succeed(NullValue))).run + }.provideEnvironment(env) ) ) case ReducedStep.DeferStep(obj, nextSteps, path) =>