Skip to content

Commit

Permalink
Release v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegIlyenko committed Feb 28, 2016
1 parent 644cd9b commit c1ee5b5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v0.2.0 (2016-02-28)

* Added support for input parsing by providing an instance of `InputParser` type class
* Updated to latest version of marshalling API

## v0.1.0 (2016-01-23)

* Initial release
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
SBT Configuration:

```scala
libraryDependencies += "org.sangria-graphql" %% "sangria-play-json" % "0.1.0"
libraryDependencies += "org.sangria-graphql" %% "sangria-play-json" % "0.2.0"
```

## License
Expand Down
8 changes: 4 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "sangria-play-json"
organization := "org.sangria-graphql"
version := "0.2.0-SNAPSHOT"
version := "0.2.0"

description := "Sangria play-json marshalling"
homepage := Some(url("http://sangria-graphql.org"))
Expand All @@ -10,11 +10,11 @@ scalaVersion := "2.11.7"
scalacOptions ++= Seq("-deprecation", "-feature")

libraryDependencies ++= Seq(
"org.sangria-graphql" %% "sangria-marshalling-api" % "0.1.0",
"org.sangria-graphql" %% "sangria-marshalling-api" % "0.1.1",
"com.typesafe.play" %% "play-json" % "2.4.6",

"org.sangria-graphql" %% "sangria-marshalling-testkit" % "0.1.0" % "test",
"org.scalatest" %% "scalatest" % "2.2.4" % "test"
"org.sangria-graphql" %% "sangria-marshalling-testkit" % "0.1.2" % "test",
"org.scalatest" %% "scalatest" % "2.2.6" % "test"
)

git.remoteRepo := "[email protected]:sangria-graphql/sangria-play-json.git"
Expand Down
6 changes: 6 additions & 0 deletions src/main/scala/sangria/marshalling/playJson.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package sangria.marshalling

import play.api.libs.json._

import scala.util.Try

object playJson extends PlayJsonSupportLowPrioImplicits {
implicit object PlayJsonResultMarshaller extends ResultMarshaller {
type Node = JsValue
Expand Down Expand Up @@ -101,6 +103,10 @@ object playJson extends PlayJsonSupportLowPrioImplicits {
throw InputParsingError(formattedErrors)
}
}

implicit object PlayJsonInputParser extends InputParser[JsValue] {
def parse(str: String) = Try(Json.parse(str))
}
}

trait PlayJsonSupportLowPrioImplicits {
Expand Down
13 changes: 11 additions & 2 deletions src/test/scala/sangria/marshalling/PlayJsonSupportSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package sangria.marshalling
import org.scalatest.{Matchers, WordSpec}
import play.api.libs.json._

import sangria.marshalling.testkit.{InputHandlingBehaviour, MarshallingBehaviour, Comment, Article}
import sangria.marshalling.testkit._
import sangria.marshalling.playJson._


class PlayJsonSupportSpec extends WordSpec with Matchers with MarshallingBehaviour with InputHandlingBehaviour {
class PlayJsonSupportSpec extends WordSpec with Matchers with MarshallingBehaviour with InputHandlingBehaviour with ParsingBehaviour {
implicit val commentFormat = Json.format[Comment]
implicit val articleFormat = Json.format[Article]

Expand All @@ -19,6 +19,15 @@ class PlayJsonSupportSpec extends WordSpec with Matchers with MarshallingBehavio

behave like `case class input unmarshaller`
behave like `case class input marshaller` (PlayJsonResultMarshaller)

behave like `input parser` (ParseTestSubjects(
complex = """{"a": [null, 123, [{"foo": "bar"}]], "b": {"c": true, "d": null}}""",
simpleString = "\"bar\"",
simpleInt = "12345",
simpleNull = "null",
list = "[\"bar\", 1, null, true, [1, 2, 3]]",
syntaxError = List("[123, \"FOO\" \"BAR\"")
))
}

val toRender = Json.obj(
Expand Down

0 comments on commit c1ee5b5

Please sign in to comment.