added cleanup mutation (#157)
* added cleanup mutation * default to empty array
This commit is contained in:
@@ -232,6 +232,28 @@ export const productMutationTypeDefs = {
|
||||
return (<ProductAPI>dataSources.productApi).getProduct(id);
|
||||
},
|
||||
|
||||
/**
|
||||
* @function cleanupInteriors
|
||||
* @description Will remove all unused interior images for s3
|
||||
*/
|
||||
async cleanupInteriors(_, { productId }, { dataSources }) {
|
||||
const product = await (<ProductAPI>dataSources.productApi).getProduct(
|
||||
productId,
|
||||
);
|
||||
const interiors = [];
|
||||
for (const printProduct of product.printProducts) {
|
||||
const i = await (<InteriorAPI>(
|
||||
dataSources.interiorApi
|
||||
)).getPrintProductInteriors(printProduct.id);
|
||||
interiors.push(...i);
|
||||
}
|
||||
const response = await (<ProductAPI>(
|
||||
dataSources.productApi
|
||||
)).cleanupInteriors(productId, interiors);
|
||||
|
||||
return response;
|
||||
},
|
||||
|
||||
/**
|
||||
* @function productInfo
|
||||
* @description Mutate base information about a product
|
||||
|
||||
Reference in New Issue
Block a user