Skip to content

Commit

Permalink
checkpoint 9 - more polish
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpdaniels committed Aug 19, 2023
1 parent ff9026e commit f960102
Show file tree
Hide file tree
Showing 5 changed files with 311 additions and 218 deletions.
16 changes: 8 additions & 8 deletions core/src/main/scala/caliban/Value.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ import caliban.interop.circe._
import caliban.interop.tapir.IsTapirSchema
import caliban.interop.jsoniter.IsJsoniterCodec
import caliban.interop.zio.{ IsZIOJsonDecoder, IsZIOJsonEncoder }
import caliban.rendering.ValueRenderer
import zio.stream.Stream

sealed trait InputValue {
def toInputString: String = toString
sealed trait InputValue { self =>
def toInputString: String = ValueRenderer.inputValueRenderer.renderCompact(self)
}
object InputValue extends ValueJsonCompat {
case class ListValue(values: List[InputValue]) extends InputValue {
override def toString: String = values.mkString("[", ",", "]")
override def toInputString: String = values.map(_.toInputString).mkString("[", ", ", "]")
override def toInputString: String = ValueRenderer.inputListValueRenderer.render(this)
}
case class ObjectValue(fields: Map[String, InputValue]) extends InputValue {
override def toString: String =
fields.map { case (name, value) => s""""$name:${value.toString}"""" }.mkString("{", ",", "}")

override def toInputString: String =
fields.map { case (name, value) => s"""$name: ${value.toInputString}""" }.mkString("{", ", ", "}")
override def toInputString: String = ValueRenderer.inputObjectValueRenderer.render(this)
}
case class VariableValue(name: String) extends InputValue {
override def toString: String = s"$$$name"
Expand Down Expand Up @@ -60,11 +60,11 @@ sealed trait ResponseValue { self =>
}
object ResponseValue extends ValueJsonCompat {
case class ListValue(values: List[ResponseValue]) extends ResponseValue {
override def toString: String = values.mkString("[", ",", "]")
override def toString: String = ValueRenderer.responseListValueRenderer.renderCompact(this)
}
case class ObjectValue(fields: List[(String, ResponseValue)]) extends ResponseValue {
override def toString: String =
fields.map { case (name, value) => s""""$name":${value.toString}""" }.mkString("{", ",", "}")
ValueRenderer.responseObjectValueRenderer.renderCompact(this)

override def hashCode: Int = fields.toSet.hashCode()
override def equals(other: Any): Boolean =
Expand Down Expand Up @@ -114,7 +114,7 @@ object Value {
}
case class EnumValue(value: String) extends Value {
override def toString: String = s""""${value.replace("\"", "\\\"")}""""
override def toInputString: String = s"""${value.replace("\"", "\\\"")}"""
override def toInputString: String = ValueRenderer.enumInputValueRenderer.render(this)
}

object IntValue {
Expand Down
Loading

0 comments on commit f960102

Please sign in to comment.