From 2db0626d1745e1e3757b0b028560503566e8c186 Mon Sep 17 00:00:00 2001 From: Kyri Petrou Date: Wed, 20 Dec 2023 19:07:00 +1100 Subject: [PATCH 1/2] Avoid wrapping `Step[R]` in Option in ObjectFieldResolver --- .../scala/caliban/schema/ObjectFieldResolver.scala | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/core/src/main/scala/caliban/schema/ObjectFieldResolver.scala b/core/src/main/scala/caliban/schema/ObjectFieldResolver.scala index fdc4864b70..6d24b16d86 100644 --- a/core/src/main/scala/caliban/schema/ObjectFieldResolver.scala +++ b/core/src/main/scala/caliban/schema/ObjectFieldResolver.scala @@ -9,13 +9,12 @@ final private class ObjectFieldResolver[R, A] private ( name: String, fields: mutable.HashMap[String, A => Step[R]] ) { - def resolve(value: A): Step[R] = ObjectStep( - name, - fields.get(_) match { - case Some(f) => f(value) - case None => NullStep - } - ) + private val nullStepFunction: A => Step[R] = _ => NullStep + + private def getFieldStep(value: A): String => Step[R] = + fields.getOrElse(_, nullStepFunction)(value) + + def resolve(value: A): Step[R] = ObjectStep(name, getFieldStep(value)) } private object ObjectFieldResolver { From 666dcc981fa1fd1568f6fd1195f1ae3765ae0bb7 Mon Sep 17 00:00:00 2001 From: Kyri Petrou Date: Wed, 20 Dec 2023 19:37:35 +1100 Subject: [PATCH 2/2] trigger CI