-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client implementation errror "Cannot deduce decoder" #10
Comments
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.
The case class should be
In the same exact order as you querying. At least i had this issue using drunk with auto decoder from circe. |
@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?
The text was updated successfully, but these errors were encountered: