Slide 13
Slide 13 text
งғؾ
case class MyObject(id: Long, name: String)
val myObjectType: ObjectType[Unit, MyObject] = derive.deriveObjectType()
val myQuery: ObjectType[MyObjectRepository, Unit] = {
ObjectType.apply(
"MyQuery",
fields[MyObjectRepository, Unit](
{ val idArg = Argument("id", LongType)
Field(
"findById",
OptionType(myObjectType),
arguments = idArg :: Nil,
resolve = ctx => ctx.ctx.findById(ctx.arg(idArg)))
},
Field("all", ListType(myObjectType),
resolve = ctx => Future { ctx.ctx.findAll })
)
)
}
13