Skip to content

Commit 4110e3d

Browse files
felixbrmuuki88
authored andcommitted
Update circe to 0.11.1 while replacing jawn with jackson (#72)
* Update circe to 0.11.1 while replacing jawn with jackson * Remove unnecessary dependency declaration
1 parent 3c62796 commit 4110e3d

File tree

5 files changed

+53
-11
lines changed

5 files changed

+53
-11
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ In your `build.sbt` enable the plugins and add sangria. I'm using circe as a par
3636
enablePlugins(GraphQLSchemaPlugin, GraphQLQueryPlugin)
3737

3838
libraryDependencies ++= Seq(
39-
"org.sangria-graphql" %% "sangria" % "1.4.2",
40-
"org.sangria-graphql" %% "sangria-circe" % "1.2.1"
39+
"org.sangria-graphql" %% "sangria" % "1.4.2"
4140
)
4241
```
4342

build.sbt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ organization := "rocks.muki"
33
sbtPlugin := true
44
enablePlugins(SbtPlugin)
55

6-
val circeVersion = "0.9.3"
7-
val catsVersion = "1.4.0"
6+
val circeVersion = "0.11.1"
7+
val catsVersion = "1.5.0"
88
libraryDependencies ++= Seq(
99
"org.sangria-graphql" %% "sangria" % "1.4.2",
10-
"org.sangria-graphql" %% "sangria-circe" % "1.2.1",
1110
"io.circe" %% "circe-core" % circeVersion,
12-
"io.circe" %% "circe-parser" % circeVersion,
11+
"io.circe" %% "circe-jackson28" % circeVersion,
1312
"org.typelevel" %% "cats-core" % catsVersion,
1413
"org.typelevel" %% "cats-testkit" % catsVersion % Test,
1514
"org.scalaj" %% "scalaj-http" % "2.3.0",

project/plugins.sbt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@ addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0")
77
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.9.3")
88
addSbtPlugin("com.dwijnand" % "sbt-travisci" % "1.1.1")
99

10-
// plugin project
11-
libraryDependencies += "org.typelevel" %% "cats-core" % "1.4.0"
12-
1310
// testing
1411
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value

src/main/scala/rocks/muki/graphql/instances/instances.scala

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package rocks.muki.graphql
22

33
import cats.Monoid
4+
import io.circe.Json
45
import sangria.ast.Document
6+
import sangria.marshalling.InputUnmarshaller
57

68
package object instances {
79

@@ -14,4 +16,49 @@ package object instances {
1416
override def empty: Document = Document(Vector.empty)
1517
override def combine(x: Document, y: Document): Document = x merge y
1618
}
19+
20+
/**
21+
* Inlined from sangria-circe 1.2.1, as it is not yet available for circe 0.11.x and it is unclear when it would be.
22+
*
23+
* We only need this part so no need to inline everything else from `sangria.marshalling.circe._`.
24+
*/
25+
implicit object CirceInputUnmarshaller extends InputUnmarshaller[Json] {
26+
def getRootMapValue(node: Json, key: String) = node.asObject.get(key)
27+
28+
def isMapNode(node: Json) = node.isObject
29+
def getMapValue(node: Json, key: String) = node.asObject.get(key)
30+
def getMapKeys(node: Json) = node.asObject.get.keys
31+
32+
def isListNode(node: Json) = node.isArray
33+
def getListValue(node: Json) = node.asArray.get
34+
35+
def isDefined(node: Json) = !node.isNull
36+
def getScalarValue(node: Json) = {
37+
def invalidScalar =
38+
throw new IllegalStateException(s"$node is not a scalar value")
39+
40+
node.fold(
41+
jsonNull = invalidScalar,
42+
jsonBoolean = identity,
43+
jsonNumber =
44+
num num.toBigInt orElse num.toBigDecimal getOrElse invalidScalar,
45+
jsonString = identity,
46+
jsonArray = _ invalidScalar,
47+
jsonObject = _ invalidScalar
48+
)
49+
}
50+
51+
def getScalaScalarValue(node: Json) = getScalarValue(node)
52+
53+
def isEnumNode(node: Json) = node.isString
54+
55+
def isScalarNode(node: Json) =
56+
node.isBoolean || node.isNumber || node.isString
57+
58+
def isVariableNode(node: Json) = false
59+
def getVariableName(node: Json) =
60+
throw new IllegalArgumentException("variables are not supported")
61+
62+
def render(node: Json) = node.noSpaces
63+
}
1764
}

src/main/scala/rocks/muki/graphql/schema/SchemaLoader.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package rocks.muki.graphql.schema
33
import java.io.File
44

55
import io.circe.Json
6-
import io.circe.parser.parse
6+
import io.circe.jackson.parse
77
import sangria.introspection.introspectionQuery
88
import sangria.macros._
9-
import sangria.marshalling.circe._
9+
import rocks.muki.graphql.instances._
1010
import sangria.parser.QueryParser
1111
import sangria.schema.Schema
1212
import sbt.io.IO

0 commit comments

Comments
 (0)