Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sangria.macros.derive._
- import sangria.schema._
- // ... other entities
- implicit val MaterialType = ObjectType(
- "Material",
- "",
- fields[Unit, Material](
- Field("id", IntType,
- description = Some("Id of Material"),
- resolve = _.value.id)
- , Field("courseId", IntType,
- description = Some("Parent Id of course"),
- resolve = _.value.courseId)
- , Field("quantity", FloatType,
- description = Some("Cantidad"),
- resolve = _.value.quantity)
- , Field("item", ItemType,
- description = Some("Ítem (libro o material escolar)"),
- resolve = c ⇒ itemFetcher.defer(c.value.item)
- )
- )
- )
- implicit val CourseType = ObjectType(
- "Course",
- "",
- fields[Unit, Course](
- Field("id", IntType,
- description = Some("Id of Course"),
- resolve = _.value.id)
- , Field("teachingCenterId", IntType,
- description = Some("Parent Id of teachingCenter"),
- resolve = _.value.teachingCenterId)
- , Field("name", StringType,
- description = Some("Nombre del curso"),
- resolve = _.value.name)
- , Field("cycle", StringType,
- description = Some("Ciclo formativo"),
- resolve = _.value.cycle)
- , Field("materials", OptionType(ListType(MaterialType)),
- description = Some("Libros y material escolar"),
- arguments = Limit :: Offset :: Search :: Nil,
- resolve = c => MaterialDeferred(c.value.materials, c arg Limit, c arg Offset, c arg Search)
- )
- )
- )
- implicit val TeachingCenterType = ObjectType(
- "TeachingCenter",
- "",
- fields[Unit, TeachingCenter](
- Field("id", IntType,
- description = Some("Id of TeachingCenter"),
- resolve = _.value.id)
- , Field("name", StringType,
- description = Some("Nombre del centro"),
- resolve = _.value.name)
- , Field("email", OptionType(StringType),
- description = Some("Dirección de correo electrónico"),
- resolve = _.value.email)
- , Field("courses", OptionType(ListType(CourseType)),
- description = Some("Cursos"),
- arguments = Limit :: Offset :: Search :: Nil,
- resolve = c => CourseDeferred(c.value.courses, c arg Limit, c arg Offset, c arg Search)
- )
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement