diff --git a/CHANGELOG.md b/CHANGELOG.md index b85c680..b77ccb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.4.4 (2016-05-01) + +* Updated to sangria-marshalling-api v0.2.1 + ## v0.4.3 (2016-04-11) * Updated `circe` to version 0.4.1 diff --git a/README.md b/README.md index 59bccd3..9e1ed59 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ SBT Configuration: ```scala -libraryDependencies += "org.sangria-graphql" %% "sangria-circe" % "0.4.3" +libraryDependencies += "org.sangria-graphql" %% "sangria-circe" % "0.4.4" ``` ## License diff --git a/build.sbt b/build.sbt index 171f2e8..03086ff 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ name := "sangria-circe" organization := "org.sangria-graphql" -version := "0.4.4-SNAPSHOT" +version := "0.4.4" description := "Sangria circe marshalling" homepage := Some(url("http://sangria-graphql.org")) @@ -12,12 +12,12 @@ scalacOptions ++= Seq("-deprecation", "-feature") val circeVersion = "0.4.1" libraryDependencies ++= Seq( - "org.sangria-graphql" %% "sangria-marshalling-api" % "0.2.0", + "org.sangria-graphql" %% "sangria-marshalling-api" % "0.2.1", "io.circe" %% "circe-core" % circeVersion, "io.circe" %% "circe-generic" % circeVersion, - "org.sangria-graphql" %% "sangria-marshalling-testkit" % "0.2.0" % "test", + "org.sangria-graphql" %% "sangria-marshalling-testkit" % "0.2.1" % "test", "org.scalatest" %% "scalatest" % "2.2.6" % "test" ) diff --git a/src/main/scala/sangria/marshalling/circe.scala b/src/main/scala/sangria/marshalling/circe.scala index e208e31..aa02373 100644 --- a/src/main/scala/sangria/marshalling/circe.scala +++ b/src/main/scala/sangria/marshalling/circe.scala @@ -20,6 +20,20 @@ object circe { case None ⇒ nullNode } + def scalarNode(value: Any, typeName: String, info: Set[ScalarValueInfo]) = value match { + case v: String ⇒ Json.fromString(v) + case v: Boolean ⇒ Json.fromBoolean(v) + case v: Int ⇒ Json.fromInt(v) + case v: Long ⇒ Json.fromLong(v) + case v: Float ⇒ Json.fromDouble(v).get + case v: Double ⇒ Json.fromDouble(v).get + case v: BigInt ⇒ Json.fromBigInt(v) + case v: BigDecimal ⇒ Json.fromBigDecimal(v) + case v ⇒ throw new IllegalArgumentException("Unsupported scalar value: " + v) + } + + def enumNode(value: String, typeName: String) = Json.fromString(value) + def booleanNode(value: Boolean) = Json.fromBoolean(value) def floatNode(value: Double) = Json.fromDouble(value).get def stringNode(value: String) = Json.fromString(value)