From 3c579f5bb95accea75c3779a84ac2602ae731b01 Mon Sep 17 00:00:00 2001 From: Jan Cajthaml Date: Thu, 25 Nov 2021 00:01:27 +0100 Subject: [PATCH] fix NaturalNumber user input parsing --- .../scala/com/openbank/dwh/service/GraphQLService.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/services/data-warehouse/src/main/scala/com/openbank/dwh/service/GraphQLService.scala b/services/data-warehouse/src/main/scala/com/openbank/dwh/service/GraphQLService.scala index d99147b..46e49cf 100644 --- a/services/data-warehouse/src/main/scala/com/openbank/dwh/service/GraphQLService.scala +++ b/services/data-warehouse/src/main/scala/com/openbank/dwh/service/GraphQLService.scala @@ -11,6 +11,7 @@ import com.openbank.dwh.persistence._ import sangria.execution.deferred._ import sangria.ast.{BigIntValue, IntValue, StringValue} import spray.json.{JsObject, JsValue} +import scala.math.BigInt sealed trait Types { @@ -18,9 +19,10 @@ sealed trait Types { "NaturalNumber", Some("Positive integer including zero"), coerceUserInput = { - case s: Int if s >= 0 => Right(s.toLong) - case s: Long if s >= 0 => Right(s) - case _ => Left(NaturalNumberCoerceViolation) + case s: Int if s >= 0 => Right(s.toLong) + case s: Long if s >= 0 => Right(s) + case s: BigInt if s.signum >= 0 && s.isValidLong => Right(s.longValue) + case _ => Left(NaturalNumberCoerceViolation) }, coerceOutput = (s, _) => s, coerceInput = {