diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-03-12 14:06:25 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-03-12 14:06:25 -0400 |
| commit | 46a0ba30ef54a7e36206481a4f5b2bf1f9702fca (patch) | |
| tree | a95fd534fc27761d8b26d0dffcdb5f300f7a61c7 /backend | |
| parent | f7bea2d1b7be2b70dceb25c9837f608b538e9cec (diff) | |
wip
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/README.md | 3 | ||||
| -rw-r--r-- | backend/database/datamodel.graphql | 2 | ||||
| -rw-r--r-- | backend/src/generated/prisma.graphql | 40 | ||||
| -rw-r--r-- | backend/src/resolvers/Mutation.js | 11 | ||||
| -rw-r--r-- | backend/src/schema.graphql | 7 |
5 files changed, 60 insertions, 3 deletions
diff --git a/backend/README.md b/backend/README.md index b6d93b6..2aab87c 100644 --- a/backend/README.md +++ b/backend/README.md @@ -34,4 +34,5 @@ if in trouble, run `prisma local nuke` ## TODO: 1. When an item is deleted, the cartItems need to be deleted as well -1. When an order goes through, delete cartItems
\ No newline at end of file +1. When an order goes through, delete cartItems + diff --git a/backend/database/datamodel.graphql b/backend/database/datamodel.graphql index c4ac4f6..b35f423 100644 --- a/backend/database/datamodel.graphql +++ b/backend/database/datamodel.graphql @@ -38,6 +38,7 @@ type Item { title: String! description: String! image: String + largeImage: String price: Int! createdAt: DateTime! updatedAt: DateTime! @@ -48,6 +49,7 @@ type OrderItem { title: String! description: String! image: String + largeImage: String price: Int! createdAt: DateTime! updatedAt: DateTime! diff --git a/backend/src/generated/prisma.graphql b/backend/src/generated/prisma.graphql index f65ba96..d910a39 100644 --- a/backend/src/generated/prisma.graphql +++ b/backend/src/generated/prisma.graphql @@ -19,6 +19,7 @@ type Item implements Node { title: String! description: String! image: String + largeImage: String price: Int! createdAt: DateTime! updatedAt: DateTime! @@ -39,6 +40,7 @@ type OrderItem implements Node { title: String! description: String! image: String + largeImage: String price: Int! createdAt: DateTime! updatedAt: DateTime! @@ -260,6 +262,7 @@ input ItemCreateInput { title: String! description: String! image: String + largeImage: String price: Int! } @@ -282,6 +285,8 @@ enum ItemOrderByInput { description_DESC image_ASC image_DESC + largeImage_ASC + largeImage_DESC price_ASC price_DESC createdAt_ASC @@ -295,6 +300,7 @@ type ItemPreviousValues { title: String! description: String! image: String + largeImage: String price: Int! createdAt: DateTime! updatedAt: DateTime! @@ -321,6 +327,7 @@ input ItemUpdateInput { title: String description: String image: String + largeImage: String price: Int } @@ -390,6 +397,20 @@ input ItemWhereInput { image_not_starts_with: String image_ends_with: String image_not_ends_with: String + largeImage: String + largeImage_not: String + largeImage_in: [String!] + largeImage_not_in: [String!] + largeImage_lt: String + largeImage_lte: String + largeImage_gt: String + largeImage_gte: String + largeImage_contains: String + largeImage_not_contains: String + largeImage_starts_with: String + largeImage_not_starts_with: String + largeImage_ends_with: String + largeImage_not_ends_with: String price: Int price_not: Int price_in: [Int!] @@ -510,6 +531,7 @@ input OrderItemCreateInput { title: String! description: String! image: String + largeImage: String price: Int! quantity: Int item: ItemCreateOneInput! @@ -535,6 +557,8 @@ enum OrderItemOrderByInput { description_DESC image_ASC image_DESC + largeImage_ASC + largeImage_DESC price_ASC price_DESC createdAt_ASC @@ -550,6 +574,7 @@ type OrderItemPreviousValues { title: String! description: String! image: String + largeImage: String price: Int! createdAt: DateTime! updatedAt: DateTime! @@ -577,6 +602,7 @@ input OrderItemUpdateInput { title: String description: String image: String + largeImage: String price: Int quantity: Int item: ItemUpdateOneInput @@ -649,6 +675,20 @@ input OrderItemWhereInput { image_not_starts_with: String image_ends_with: String image_not_ends_with: String + largeImage: String + largeImage_not: String + largeImage_in: [String!] + largeImage_not_in: [String!] + largeImage_lt: String + largeImage_lte: String + largeImage_gt: String + largeImage_gte: String + largeImage_contains: String + largeImage_not_contains: String + largeImage_starts_with: String + largeImage_not_starts_with: String + largeImage_ends_with: String + largeImage_not_ends_with: String price: Int price_not: Int price_in: [Int!] diff --git a/backend/src/resolvers/Mutation.js b/backend/src/resolvers/Mutation.js index b0afc6d..cd25599 100644 --- a/backend/src/resolvers/Mutation.js +++ b/backend/src/resolvers/Mutation.js @@ -31,7 +31,6 @@ const mutations = { if (!valid) { throw new Error('Invalid password'); } - return { token: jwt.sign({ userId: user.id }, process.env.APP_SECRET), user, @@ -322,6 +321,16 @@ const mutations = { // 4. Send an email with their order // 5. Send the order back }, + async updateUser(parent, args, ctx, info) { + const userId = getUserId(ctx); + console.log(userId); + const updatedUser = await ctx.db.mutation.updateUser({ + data: args, + where: { id: userId }, + }); + console.log(updatedUser); + return updatedUser; + }, }; module.exports = mutations; diff --git a/backend/src/schema.graphql b/backend/src/schema.graphql index 8d8218a..dc7caba 100644 --- a/backend/src/schema.graphql +++ b/backend/src/schema.graphql @@ -26,12 +26,17 @@ type Mutation { signin(email: String!, password: String!): AuthPayload! requestReset(email: String!): User resetPassword(resetToken: String!, password: String!, confirmPassword: String!): AuthPayload! - createItem(title: String, description: String, price: Int, image: String): Item! + createItem(title: String, description: String, price: Int, image: String, largeImage: String): Item! deleteItem(id: ID!): Item! updateItem(id: ID!, title: String, description: String, price: Int): Item! addToCart(id: ID!): CartItem removeFromCart(id: ID!): CartItem createOrder(token: String!): Order! + updateUser(name: String): User +} + +input UserInput { + name: String } type AuthPayload { |
