Hi Oleg,
First of all great project. I'm wondering if it's possible to use an already defined serializer/deserializer for JSON ?
Let's take for example this class:
case class Person(_id: ObjectId, name: String)
We need to define GraphQL output type for
ObjectId which can be achieved with something like this:
case object ObjectIdCoercion extends ValueCoercionViolation("ObjectId value expected")
implicit val ObjectIdType = ScalarType[ObjectId]("ObjectId",
coerceOutput = (objId, _) => objId.toString,
coerceUserInput = {
case s: String => Right(new ObjectId(s))
case _ => Left(ObjectIdCoercion)
},
coerceInput = {
case StringValue(s, _, _) => Right(new ObjectId(s))
case _ => Left(ObjectIdCoercion)
})
val PersonType = deriveObjectType[Unit, Person](
ObjectTypeDescription("Person description")
)
We need to do it for every custom type we have however we already did this for Json4s in our case, can they be reused ?