148 - Product category mutations

This commit is contained in:
Anders Gustafsson
2021-09-16 11:04:23 +02:00
parent c4915cb15f
commit 2a2281ab5d
3 changed files with 51 additions and 0 deletions
+20
View File
@@ -180,4 +180,24 @@ export const productMutationTypeDefs = {
);
return (<ProductAPI>dataSources.productApi).getProduct(productId);
},
async addCategoriesToProduct(_, { productId, categoryIds }, { dataSources }) {
await (<ProductAPI>dataSources.productApi).addCategoriesToProduct(
productId,
categoryIds,
);
return (<ProductAPI>dataSources.productApi).getProduct(productId);
},
async removeCategoriesFromProduct(
_,
{ productId, categoryIds },
{ dataSources },
) {
await (<ProductAPI>dataSources.productApi).removeCategoriesFromProduct(
productId,
categoryIds,
);
return (<ProductAPI>dataSources.productApi).getProduct(productId);
},
};