val campaignsFetcher = Fetcher { (ctx: LabelsContext, ids: Seq[Long]) => ctx.fetchCampaignsByIds(ids.toSet) }(HasId(_.id))
implicit val labelType = deriveObjectType[Unit, GraphQLLabel]( ReplaceField(fieldName = "campaigns", field = Field( name = "campaigns", fieldType = listCampaignInfoType, description = Some("The campaign info for campaigns this label can be used within."), arguments = Argument("pageNumber", IntType) :: Argument("pageSize", IntType) :: Nil, resolve = (ctx) => { val pageSize = ctx.arg[Int]("pageSize") val pageNumber = ctx.arg[Int]("pageNumber") val campaignIds: List[Long] = ctx.value.campaigns.getOrElse(List.empty) val start = (pageNumber - 1) * pageSize campaignsFetcher.deferSeq(campaigns.slice(start, start + pageSize)) } )) )campaignsFetcher.deferSeq(campaigns.slice(start, start + pageSize)).map { deferredCampaigns => Page(data = deferredCampaigns, pageNumber = pageNumber, pageSize = pageSize, totalRecords = campaigns.size.toLong )}--
You received this message because you are subscribed to the Google Groups "sangria-graphql" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sangria-graphql+unsubscribe@googlegroups.com.
To post to this group, send email to sangria-graphql@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sangria-graphql/797be069-1c9f-4c3f-a92a-ef03cda08847%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.