From 94f5e152ad364e415ab59a3839efe2424cbb0e15 Mon Sep 17 00:00:00 2001 From: Pierre Ricadat Date: Sat, 1 Jun 2024 20:46:09 +0900 Subject: [PATCH] Optimize --- .../scala/caliban/execution/Executor.scala | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/core/src/main/scala/caliban/execution/Executor.scala b/core/src/main/scala/caliban/execution/Executor.scala index 953c17738..df096ea12 100644 --- a/core/src/main/scala/caliban/execution/Executor.scala +++ b/core/src/main/scala/caliban/execution/Executor.scala @@ -386,20 +386,20 @@ object Executor { case wrapper :: tail => val q = if (isPure && !wrapper.wrapPureValues) query - else - wrapper - .wrap(query, fieldInfo) - .mapErrorCause(e => - effectfulExecutionError( - PathValue.Key(fieldInfo.name) :: fieldInfo.path, - Some(fieldInfo.details.locationInfo), - e - ) - ) - + else wrapper.wrap(query, fieldInfo) loop(q, tail) } - loop(query, fieldWrappers) + + if ((isPure && !wrapPureValues) || (fieldWrappers eq Nil)) query + else { + loop(query, fieldWrappers).mapErrorCause(e => + effectfulExecutionError( + PathValue.Key(fieldInfo.name) :: fieldInfo.path, + Some(fieldInfo.details.locationInfo), + e + ) + ) + } } def objectFieldQuery(step: ReducedStep[R], info: FieldInfo, isPure: Boolean = false) = {