AddProduct mutation (#59)

This commit is contained in:
Niklas Fondberg
2021-10-05 10:03:13 +02:00
committed by GitHub
parent 4e55166828
commit 491ac6e64e
5 changed files with 38 additions and 0 deletions
+7
View File
@@ -84,6 +84,13 @@ export const productQueryTypeDefs = {
///////////////////
// Mutations below
export const productMutationTypeDefs = {
async addProduct(_, { name, batch }, { dataSources }) {
const id = await (<ProductAPI>dataSources.productApi).addProduct(
name,
batch,
);
return (<ProductAPI>dataSources.productApi).getProduct(id);
},
async productInfo(_, { productId, info }, { dataSources }) {
await (<ProductAPI>dataSources.productApi).updateProductInfo(
productId,