While deriving an object type i want to add an field with the AddFields-methode of Sangria. I don't know how to fill the parameter "resolve = " Can anyone help me?
Given are the entities Delivery and System. I derived the object Type SystemD4S. Now I want to add a field "systemObject" with type SystemD4S in the derived object type for delivery. Don't know how to fill the parameter "resolve = "
case class Delivery (
docid: String,
override val docType: String = Doctype.DELIVERY,
system: String,
status: String,
items: List[DeliveryItem],
deleted: Boolean
) extends EntityItemCollection {
def getBusinessKey: String = s"$docid::$docType::$system"
}
case class System(id: String, company: String)
val SystemD4S = deriveObjectType[D4sEntityRepo, System](
ObjectTypeDescription("system"))
val DeliveryD4S = deriveObjectType[D4sEntityRepo, Delivery](
ObjectTypeDescription("delivery"),
AddFields(Field("systemObject", SystemD4S, resolve = c => enitiesD4S.deferRel()))
)
resolve is a function of type
Context[Ctx, Val] ⇒ Action[Ctx, Res].For
deriveObjectType[D4sEntityRepo, Delivery], yourCtxisD4sEntityRepo,ValisDeliveryandResisSystemD4SNow to get the
enitiesD4Sinstance in your resolve function, you can usec.ctx.Hope this helps.