Skip to content

Instantly share code, notes, and snippets.

Created August 3, 2017 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/129474ea7f4f150dd08e8d0e27265146 to your computer and use it in GitHub Desktop.
Save anonymous/129474ea7f4f150dd08e8d0e27265146 to your computer and use it in GitHub Desktop.
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