Uploading the Repo

This commit is contained in:
Andrean
2022-03-09 22:16:51 +02:00
parent 53a8d56f1e
commit 2726127708
9 changed files with 2269 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
const { v4 } = require("uuid");
const { animals } = require("../db");
const Mutation = {
addAnimal: (
parent,
{ image, title, rating, price, description, slug, stock, onSale, category },
{ animals }
) => {
let newAnimal = {
id: v4(),
image,
title,
rating,
price,
description,
slug,
stock,
onSale,
category,
};
animals.push(newAnimal);
return newAnimal;
},
removeAnimal: (parent, { id }, { animals }) => {
let index = animals.findIndex((animal) => {
return animal.id === id;
});
animals.splice(index, 1);
return true;
},
};
module.exports = { Mutation };