diff options
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/prisma/datamodel.graphql | 4 | ||||
| -rw-r--r-- | backend/src/generated/prisma.graphql | 15 | ||||
| -rw-r--r-- | backend/src/resolvers/Mutation.js | 11 |
3 files changed, 12 insertions, 18 deletions
diff --git a/backend/prisma/datamodel.graphql b/backend/prisma/datamodel.graphql index 9465524..cb8afcb 100644 --- a/backend/prisma/datamodel.graphql +++ b/backend/prisma/datamodel.graphql @@ -52,8 +52,6 @@ type OrderItem { createdAt: DateTime! updatedAt: DateTime! quantity: Int! @default(value: 1) - item: Item! # Relationship to an Item - user: User! # Relationship to a user } type Order { @@ -64,4 +62,4 @@ type Order { createdAt: DateTime! updatedAt: DateTime! charge: String! -}
\ No newline at end of file +} diff --git a/backend/src/generated/prisma.graphql b/backend/src/generated/prisma.graphql index aeacf68..953ddc2 100644 --- a/backend/src/generated/prisma.graphql +++ b/backend/src/generated/prisma.graphql @@ -1,5 +1,5 @@ -# source: https://us1.prisma.sh/johannes-schickling/wesbos/dev -# timestamp: Mon May 21 2018 18:02:25 GMT-0700 (PDT) +# source: https://us1.prisma.sh/wesbos/sick-fits/dev +# timestamp: Fri May 25 2018 10:46:45 GMT-0400 (EDT) type AggregateCartItem { count: Int! @@ -418,6 +418,7 @@ input ItemUpdateInput { input ItemUpdateOneInput { create: ItemCreateInput connect: ItemWhereUniqueInput + disconnect: Boolean delete: Boolean update: ItemUpdateDataInput upsert: ItemUpsertNestedInput @@ -818,8 +819,6 @@ type OrderItem implements Node { createdAt: DateTime! updatedAt: DateTime! quantity: Int! - item(where: ItemWhereInput): Item! - user(where: UserWhereInput): User! } """A connection to a list of items.""" @@ -839,8 +838,6 @@ input OrderItemCreateInput { largeImage: String price: Int! quantity: Int - item: ItemCreateOneInput! - user: UserCreateOneInput! } input OrderItemCreateManyInput { @@ -936,8 +933,6 @@ input OrderItemUpdateDataInput { largeImage: String price: Int quantity: Int - item: ItemUpdateOneInput - user: UserUpdateOneInput } input OrderItemUpdateInput { @@ -947,8 +942,6 @@ input OrderItemUpdateInput { largeImage: String price: Int quantity: Int - item: ItemUpdateOneInput - user: UserUpdateOneInput } input OrderItemUpdateManyInput { @@ -1268,8 +1261,6 @@ input OrderItemWhereInput { """All values greater than or equal the given value.""" quantity_gte: Int - item: ItemWhereInput - user: UserWhereInput } input OrderItemWhereUniqueInput { 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); }, |
