sangria-graphql/sangria

Add deriveInterfaceType

Open

#263 opened on Jul 8, 2017

View on GitHub
 (2 comments) (0 reactions) (0 assignees)Scala (1,961 stars) (219 forks)batch import
derive-macrosfeaturehelp wanted

Description

Would be cool to have this for traits

trait MyInterface {
  def id: Int
  name: String
}
val MyInterfaceType = deriveInterfaceType[Unit, MyInterface]()

I think that another solution that is closer to deriveObjectType could be

case class MyInterfaceImpl(id: Int, name: String) extends MyInterface
val MyInterfaceType = deriveInterfaceType[Unit, MyInterfaceImpl](InterfaceTypeName("MyInterface"))

This would help because you don't have to copy & paste the field names into another definition

Contributor guide