the description for this gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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