Rizwan Anwar
05/20/2020, 8:16 PMChazzz
05/20/2020, 9:51 PMRizwan Anwar
05/21/2020, 7:39 AMMike SOK
05/21/2020, 1:35 PMasync minusFromCart(parent, args, ctx, info) {
// 1. Make sure they are signed in
const { userId } = ctx.request;
if (!userId) {
throw new Error('You must be signed in soooon');
}
// 2. Query the users current cart
const [existingCartItem] = await ctx.db.query.cartItems({
where: {
user: { id: userId },
item: { id: args.id },
},
});
// 3. Check if that item is already in their cart and increment by 1 if it is
if (existingCartItem) {
console.log('This item is already in their cart');
return ctx.db.mutation.updateCartItem(
{
where: { id: existingCartItem.id },
data: { quantity: existingCartItem.quantity - 1 },
},
info
);
}
//1. Find the cart item
const cartItem = await ctx.db.query.cartItem(
{
where: {
id: args.id,
},
},
`{ id, user { id }}`
);
if (existingCartItem < 1) {
//3. Delete that cart Item
return ctx.db.mutation.deleteCartItem ({
where: { id: args.id },
}, info);
}
},
@HarshitAbhischek
05/21/2020, 1:40 PMIndexOptionsConflict
when trying to deploy? I have multiple documents referencing the field it's complaining about using a @relation(link: INLINE)
Specifying a named @relation()
didn't really help so wondering if anyone faced a similar issuePhilipp Rajah Moura Srivastava
05/21/2020, 11:25 PMMohamed Nabawy
05/22/2020, 4:01 PMMohamed Nabawy
05/22/2020, 4:02 PMMohamed Nabawy
05/22/2020, 4:30 PMAaron Fulkerson
05/22/2020, 10:14 PMIppo
05/23/2020, 3:00 AMGlen
05/23/2020, 7:39 AMGlenn Dwiyatcita
05/23/2020, 9:36 AMPavlo Strunkin
05/23/2020, 10:27 AMPhilipp Rajah Moura Srivastava
05/23/2020, 7:04 PMPhilipp Rajah Moura Srivastava
05/23/2020, 7:05 PMPhilipp Rajah Moura Srivastava
05/23/2020, 7:10 PMPhilipp Rajah Moura Srivastava
05/23/2020, 7:21 PMPhilipp Rajah Moura Srivastava
05/23/2020, 10:45 PMPhilipp Rajah Moura Srivastava
05/23/2020, 10:45 PMPhilipp Rajah Moura Srivastava
05/23/2020, 10:45 PMPhilipp Rajah Moura Srivastava
05/23/2020, 10:46 PMPhilipp Rajah Moura Srivastava
05/23/2020, 10:47 PMPhilipp Rajah Moura Srivastava
05/23/2020, 10:47 PMPhilipp Rajah Moura Srivastava
05/23/2020, 10:47 PMPhilipp Rajah Moura Srivastava
05/23/2020, 10:47 PMPhilipp Rajah Moura Srivastava
05/24/2020, 12:34 AMAhmed Ghanem
05/24/2020, 12:40 AMtype Meta {
id: ID! @id @unique
firstName: String
user: User @relation(name: "UserToMeta")
}
type User {
id: ID! @id @unique
username: String!
meta: Meta @relation(link: INLINE,name: "UserToMeta", onDelete: CASCADE)
}
Ahmed Ghanem
05/24/2020, 12:41 AMAhmed Ghanem
05/24/2020, 12:41 AM