2

I'm using Scala and Sangria. 1) Let's say there is a

case class Student {
  Int rollNo,
  Int busNo,
  Int phoneNo
}

2) I'm getting a request object within which

req 
 - School
 - Home
 - Student
     - rollNo
     - busNo
     - phoneNo

3) I have a converter function which converts graphQL style objects to pure Scala objects.

Now, I have to check if the busNo is present or not in the given input req, if not present set default busNo as 10.

Right now,

def someFunc(item: Option[UIRequestModel]): Future[UIResponseModel] = {
val req = CleanseRequest(
      <SomeTHing Related to School which works fine>,
      <Something related to Home which works fine>,
      item.flatMap(_.student.map(Utils.UIStudentToStudent)) //here _.student.map(_.busNo...
    //but after that I'm struck. I would like to check if the value is set or not for busNo, if //not set default value. 
    )
}

There is no way I can change the case class code or the hierarchy at this point.

sofs1
  • 3,834
  • 11
  • 51
  • 89
  • Are you using Sangria's `Schema`-class at all? Because I would find these type of answers while resolving the Schema. If you have a similar solution I can give you direction – SylarBenes Oct 24 '19 at 09:29

0 Answers0