Skip to content

Instantly share code, notes, and snippets.

/post.scala
Created Aug 3, 2017

Embed
What would you like to do?
the description for this gist
val QueryType = ObjectType(
"Query",
fields[ShopRepository, Unit](
Field("allProducts", ListType(ProductType),
description = Some("Returns a list of all available products."),
complexity = constantComplexity(200),
resolve = _.ctx.allProducts
),
Field("product", OptionType(ProductType),
description = Some("Returns a product with specific `id`."),
arguments = Argument("id", IntType) :: Nil,
resolve = c => productsFetcher.defer(c.arg[ProductId]("id"))),
Field("products", ListType(ProductType),
description = Some("Returns a list of products for provided IDs."),
arguments = Argument("ids", ListInputType(IntType)) :: Nil,
resolve = c => productsFetcher.deferSeqOpt(c.arg[List[ProductId]]("ids"))
),
Field("category", OptionType(CategoryType),
description = Some("Returns a category with specific `id`."),
arguments = Argument("id", IntType) :: Nil,
resolve = c => categoriesFetcher.deferOpt(c.arg[CategoryId]("id"))),
Field("categories", ListType(CategoryType),
description = Some("Returns categories by provided ids"),
arguments = Argument("ids", ListInputType(IntType)) :: Nil,
complexity = constantComplexity(30),
resolve = c => categoriesFetcher.deferSeqOpt(c.arg[List[CategoryId]]("ids"))
),
Field("allCategories", ListType(CategoryType),
description = Some("Returns a list of all available categories."),
complexity = constantComplexity(250),
resolve = _.ctx.allCategories
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.