Expand variants

This commit is contained in:
Sebastian Rindom
2020-07-01 20:28:01 +02:00
parent 3e033bf646
commit 602cd2f914
3 changed files with 29 additions and 24 deletions

View File

@@ -4,16 +4,19 @@ export default async (req, res) => {
const productService = req.scope.resolve("productService")
let product = await productService.retrieve(id)
product = await productService.decorate(product, [
"title",
"description",
"tags",
"handle",
"images",
"options",
"variants",
"published",
])
product = await productService.decorate(
product,
[
"title",
"description",
"tags",
"handle",
"images",
"options",
"published",
],
["variants"]
)
res.json({ product })
}

View File

@@ -5,16 +5,19 @@ export default async (req, res) => {
products = await Promise.all(
products.map(
async product =>
await productService.decorate(product, [
"title",
"description",
"tags",
"handle",
"images",
"options",
"variants",
"published",
])
await productService.decorate(
product,
[
"title",
"description",
"tags",
"handle",
"images",
"options",
"published",
],
["variants"]
)
)
)
res.json({ products })

View File

@@ -4,10 +4,10 @@ export default async (req, res) => {
const { id } = req.params
const schema = Validator.object().keys({
title: Validator.string().required(),
title: Validator.string(),
description: Validator.string().optional(),
tags: Validator.string().optional(),
handle: Validator.string().required(),
handle: Validator.string(),
images: Validator.array()
.items(Validator.string())
.optional(),
@@ -34,9 +34,8 @@ export default async (req, res) => {
"handle",
"images",
"options",
"variants",
"published",
])
], ["variants"])
res.json({ product: newProduct })
} catch (err) {
throw err