summaryrefslogtreecommitdiffstats
path: root/finished-application/backend/src
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-06-18 16:17:23 -0400
committerWes Bos <wesbos@gmail.com>2018-06-18 16:17:23 -0400
commit14caed5d15b3601bb91a5f4a688fbdfba38cf321 (patch)
treeeea3604dcda517832fc60120bb38c69430f8d17d /finished-application/backend/src
parente9682b7b418eaf77bc2137e81edf32786e2ca1d3 (diff)
updates
Diffstat (limited to 'finished-application/backend/src')
-rw-r--r--finished-application/backend/src/generated/prisma.graphql8
-rw-r--r--finished-application/backend/src/index.js7
-rw-r--r--finished-application/backend/src/resolvers/Mutation.js9
3 files changed, 17 insertions, 7 deletions
diff --git a/finished-application/backend/src/generated/prisma.graphql b/finished-application/backend/src/generated/prisma.graphql
index 953ddc2..b607520 100644
--- a/finished-application/backend/src/generated/prisma.graphql
+++ b/finished-application/backend/src/generated/prisma.graphql
@@ -1,5 +1,5 @@
# source: https://us1.prisma.sh/wesbos/sick-fits/dev
-# timestamp: Fri May 25 2018 10:46:45 GMT-0400 (EDT)
+# timestamp: Mon Jun 18 2018 16:08:08 GMT-0400 (EDT)
type AggregateCartItem {
count: Int!
@@ -819,6 +819,7 @@ type OrderItem implements Node {
createdAt: DateTime!
updatedAt: DateTime!
quantity: Int!
+ user(where: UserWhereInput): User
}
"""A connection to a list of items."""
@@ -838,6 +839,7 @@ input OrderItemCreateInput {
largeImage: String
price: Int!
quantity: Int
+ user: UserCreateOneInput
}
input OrderItemCreateManyInput {
@@ -933,6 +935,7 @@ input OrderItemUpdateDataInput {
largeImage: String
price: Int
quantity: Int
+ user: UserUpdateOneInput
}
input OrderItemUpdateInput {
@@ -942,6 +945,7 @@ input OrderItemUpdateInput {
largeImage: String
price: Int
quantity: Int
+ user: UserUpdateOneInput
}
input OrderItemUpdateManyInput {
@@ -1261,6 +1265,7 @@ input OrderItemWhereInput {
"""All values greater than or equal the given value."""
quantity_gte: Int
+ user: UserWhereInput
}
input OrderItemWhereUniqueInput {
@@ -1759,6 +1764,7 @@ input UserUpdateInput {
input UserUpdateOneInput {
create: UserCreateInput
connect: UserWhereUniqueInput
+ disconnect: Boolean
delete: Boolean
update: UserUpdateDataInput
upsert: UserUpsertNestedInput
diff --git a/finished-application/backend/src/index.js b/finished-application/backend/src/index.js
index 94911ec..2a1b433 100644
--- a/finished-application/backend/src/index.js
+++ b/finished-application/backend/src/index.js
@@ -22,7 +22,10 @@ server.express.use((req, res, next) => {
// 2. Get User from their ID
server.express.use(async (req, res, next) => {
if (!req.userId) return next();
- const user = await db.query.user({ where: { id: req.userId } }, `{ id, permissions, email, name }`);
+ const user = await db.query.user(
+ { where: { id: req.userId } },
+ `{ id, permissions, email, name }`
+ );
req.user = user;
next();
});
@@ -33,7 +36,7 @@ server.start(
credentials: true,
origin: process.env.FRONTEND_URL,
},
- port: 4444,
+ port: process.env.PORT,
},
deets => {
console.log(`Server is running on http://localhost:${deets.port}`);
diff --git a/finished-application/backend/src/resolvers/Mutation.js b/finished-application/backend/src/resolvers/Mutation.js
index 0f1d9ba..80ff3f2 100644
--- a/finished-application/backend/src/resolvers/Mutation.js
+++ b/finished-application/backend/src/resolvers/Mutation.js
@@ -276,14 +276,15 @@ const mutations = {
// 3. convert the items they want to OrderItems
const orderItems = user.cart.map(cartItem => {
+ console.log(cartItem);
const orderItem = {
quantity: cartItem.quantity,
// copy all the item details so it's there forever
...cartItem.item,
- item: {
- // relationship to the Item incase we need it
- connect: { id: cartItem.item.id },
- },
+ // item: {
+ // // relationship to the Item incase we need it
+ // connect: { id: cartItem.item.id },
+ // },
user: { connect: { id: user.id } },
};
// scrub the ID from it because the orderItem will have it's own ID