I have the following case class:
case class QueryResult[T: Decoder](data: T)
It works with auto derivation.
But I could not solve it to have a semiautomatic derivation.
Here is my Test case:
//import io.circe.generic.auto._ // with this it works
import io.circe.derivation._
case class Name(name: String)
case class QueryResult[T: Decoder](data: T)
implicit val nameDer = deriveDecoder[Name]
implicit def result[T: Decoder] = deriveDecoder[QueryResult[T]] // this does not work
This gives me:
Error:(16, 50) No method evidence$1 in pme123.graphql.client.QueryResult[T] (this is probably because a constructor parameter isn't a val)
implicit def result[T: Decoder] = deriveDecoder[QueryResult[T]]
Which version of circe are you using? In 0.12.3 I have to use import io.circe.generic.semiauto._
and the following works for me:
case class Name(name: String)
case class QueryResult[T: Decoder](data: T)
implicit val nameDer = deriveDecoder[Name]
implicit def result[T: Decoder] = deriveDecoder[QueryResult[T]]
val json = """{"data": {"name": "foo"}}"""
decode[QueryResult[Name]](json) // Right(QueryResult(Name(foo)))