diff --git a/core/src/main/scala/caliban/execution/Executor.scala b/core/src/main/scala/caliban/execution/Executor.scala index 48f7abb0c1..e71880e676 100644 --- a/core/src/main/scala/caliban/execution/Executor.scala +++ b/core/src/main/scala/caliban/execution/Executor.scala @@ -107,12 +107,15 @@ object Executor { ) ) case ListStep(steps) => - reduceList( - steps.zipWithIndex.map { case (step, i) => - reduceStep(step, currentField, arguments, Right(i) :: path) - }, - Types.listOf(currentField.fieldType).fold(false)(_.isNullable) - ) + var i = 0 + val lb = List.newBuilder[ReducedStep[R]] + var remaining = steps + while (!remaining.isEmpty) { + lb += reduceStep(remaining.head, currentField, arguments, Right(i) :: path) + i += 1 + remaining = remaining.tail + } + reduceList(lb.result(), Types.listOf(currentField.fieldType).fold(false)(_.isNullable)) case StreamStep(stream) => if (request.operationType == OperationType.Subscription) { ReducedStep.StreamStep(