def cursorValue()

in src/main/scala/com/gu/contentapi/porter/graphql/Edge.scala [26:43]


  def cursorValue(forSort:Option[Seq[Any]]):Option[String] = {
    //Note - it's intentional that this will throw if we find a value we don't recognise
    for {
      json <- forSort.map(v => Json.arr(v.map({
        case strValue: String =>
          Json.fromString(strValue)
        case intValue: Integer =>
          Json.fromInt(intValue)
        case longValue: Long =>
          Json.fromLong(longValue)
        case floatValue: Float =>
          Json.fromFloat(floatValue).get
        case doubleValue: Double =>
          Json.fromDouble(doubleValue).get
      }): _*))
      encoded = encoder.encodeToString(json.noSpaces.getBytes(StandardCharsets.UTF_8))
    } yield encoded
  }