sangria
sangria copied to clipboard
Fix enum derivation
Fix enum derivation when the enum composed of case objects but they are not within another class
@wordrak thanks a lot for the PR. To help me reviewing this, could you explain more what the actual issue is?
Hi, issue is that the deriveEnumType macro fails when the Enum is a "case object hierarchy" and it is not contained in another object.
e.g.:
sealed trait Fruit
case object RedApple extends Fruit
case object SuperBanana extends Fruit
case object MegaOrange extends Fruit
object Fruit {
implicit val enumType = deriveEnumType[Fruit]()
}
If you revert the changes in the TestCase then you see the problem.
instead of creating the term derive.SuperBanana that is failing:
[error] /Users/yannsimon/projects/sangria-graphql/sangria/modules/derivation/src/test/scala/sangria/macros/derive/DeriveEnumTypeMacroSpec.scala:55:48: not found: value derive
[error] val singletonEnum = deriveEnumType[Fruit]()
[error] ^
we now create the term SuperBanana.
Thanks a lot!