Skip to content

Commit

Permalink
Avoid wrapping of Step[R] into Option in ObjectFieldResolver (#2053)
Browse files Browse the repository at this point in the history
* Avoid wrapping `Step[R]` in Option in ObjectFieldResolver

* trigger CI
  • Loading branch information
kyri-petrou authored Dec 20, 2023
1 parent 2febf6d commit 8f33f07
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions core/src/main/scala/caliban/schema/ObjectFieldResolver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8f33f07

Please sign in to comment.