diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-05-25 14:06:53 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-05-25 14:06:53 -0400 |
| commit | 22635ea05dab85a71fa93dbb98f93da7670ef899 (patch) | |
| tree | b9e974dee484634d0401a9149c9a68f5537553db /backend/src/resolvers | |
| parent | 549cfa77c9fec0936c3a8d87a49b69401cbfbd7a (diff) | |
Delete and Add refetch refinements
Diffstat (limited to 'backend/src/resolvers')
| -rw-r--r-- | backend/src/resolvers/Mutation.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/backend/src/resolvers/Mutation.js b/backend/src/resolvers/Mutation.js index 9510cd6..2a67da5 100644 --- a/backend/src/resolvers/Mutation.js +++ b/backend/src/resolvers/Mutation.js @@ -81,12 +81,17 @@ const mutations = { }; // 1. find the item const item = await ctx.db.query.item({ where }, `{ user {id}, title, id, description }`); - // 2. Make sure they own it, or are an admin - if (item.user.id !== ctx.request.user.id || !ctx.request.user.permissions.includes('ADMIN')) { + console.log(item.user); + console.log('-----------------'); + console.log(ctx.request.user); + // 2. if they 1. Don't own it AND 2. aren't an admin + if (item.user.id !== ctx.request.user.id && !ctx.request.user.permissions.includes('ADMIN')) { throw new Error("You aren't allowed to delete that item!"); } - // You Should Either Own this item, or have ITEMDELETE in roles + // 3. remove any orderItems this item is in + + return ctx.db.mutation.deleteItem({ where }, info); }, |
