Open MichaelHornung opened 5 years ago
Any ideas? Would be happy to get this solved.
Hello đź‘‹
I know that i had this issue when my query order did not match my case class definition order. For example :
query{delivery( id: "4727"){
docid
docType
system
status
}
The case class should be
case class Delivery(
docid: String,
docType: String,
system: String,
status: String
)
In the same exact order as you querying. At least i had this issue using drunk with auto decoder from circe. Don't know if it can solve your problem
@MichaelHornung I'm assuming you have either found your answer or moved on but the issue is likely that you don't have anything declared for the discriminators. The implementation looks like this:
/**
* This a special [[io.circe.Decoder]] for decode a polymorphic JSON response using the __typename field.
*/
def deriveByTypenameDecoder[T](discriminators: (String, Decoder[_ <: T])*) = new Decoder[T] {
val discriminatorsMap = discriminators.toMap
override def apply(c: HCursor) = c.downField(ast.TypenameFieldName).as[String] match {
case Right(tpe) if discriminatorsMap.contains(tpe) =>
discriminatorsMap(tpe)(c)
case Right(tpe) =>
Left(DecodingFailure(s"Cannot deduce decoder $tpe for ${ast.TypenameFieldName}", c.history))
case _ =>
Left(DecodingFailure(s"Cannot deduce decoder. Missing ${ast.TypenameFieldName}", c.history))
}
}
Meaning you need to supply the list of discriminators in order for it to be able to resolve which subtype you want
Hi,
i implemented this client:
Running i get this error:
Can anyone help me to fix it?