Expand variants
This commit is contained in:
@@ -4,16 +4,19 @@ export default async (req, res) => {
|
|||||||
const productService = req.scope.resolve("productService")
|
const productService = req.scope.resolve("productService")
|
||||||
let product = await productService.retrieve(id)
|
let product = await productService.retrieve(id)
|
||||||
|
|
||||||
product = await productService.decorate(product, [
|
product = await productService.decorate(
|
||||||
"title",
|
product,
|
||||||
"description",
|
[
|
||||||
"tags",
|
"title",
|
||||||
"handle",
|
"description",
|
||||||
"images",
|
"tags",
|
||||||
"options",
|
"handle",
|
||||||
"variants",
|
"images",
|
||||||
"published",
|
"options",
|
||||||
])
|
"published",
|
||||||
|
],
|
||||||
|
["variants"]
|
||||||
|
)
|
||||||
|
|
||||||
res.json({ product })
|
res.json({ product })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,16 +5,19 @@ export default async (req, res) => {
|
|||||||
products = await Promise.all(
|
products = await Promise.all(
|
||||||
products.map(
|
products.map(
|
||||||
async product =>
|
async product =>
|
||||||
await productService.decorate(product, [
|
await productService.decorate(
|
||||||
"title",
|
product,
|
||||||
"description",
|
[
|
||||||
"tags",
|
"title",
|
||||||
"handle",
|
"description",
|
||||||
"images",
|
"tags",
|
||||||
"options",
|
"handle",
|
||||||
"variants",
|
"images",
|
||||||
"published",
|
"options",
|
||||||
])
|
"published",
|
||||||
|
],
|
||||||
|
["variants"]
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
res.json({ products })
|
res.json({ products })
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ export default async (req, res) => {
|
|||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|
||||||
const schema = Validator.object().keys({
|
const schema = Validator.object().keys({
|
||||||
title: Validator.string().required(),
|
title: Validator.string(),
|
||||||
description: Validator.string().optional(),
|
description: Validator.string().optional(),
|
||||||
tags: Validator.string().optional(),
|
tags: Validator.string().optional(),
|
||||||
handle: Validator.string().required(),
|
handle: Validator.string(),
|
||||||
images: Validator.array()
|
images: Validator.array()
|
||||||
.items(Validator.string())
|
.items(Validator.string())
|
||||||
.optional(),
|
.optional(),
|
||||||
@@ -34,9 +34,8 @@ export default async (req, res) => {
|
|||||||
"handle",
|
"handle",
|
||||||
"images",
|
"images",
|
||||||
"options",
|
"options",
|
||||||
"variants",
|
|
||||||
"published",
|
"published",
|
||||||
])
|
], ["variants"])
|
||||||
res.json({ product: newProduct })
|
res.json({ product: newProduct })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw err
|
throw err
|
||||||
|
|||||||
Reference in New Issue
Block a user