summaryrefslogtreecommitdiffstats
path: root/backend/src
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-02-13 17:04:00 -0500
committerWes Bos <wesbos@gmail.com>2018-02-13 17:04:00 -0500
commita09b01abf7c03e6b7e43f2175e5a34501808821b (patch)
tree21ae6feb1d9ac1a07f045dffc24db406e2a4183b /backend/src
parentfa3ec3299b3fa33e5a699683beb96cfa4e6dd51d (diff)
omg it works
Diffstat (limited to 'backend/src')
-rw-r--r--backend/src/generated/prisma.graphql100
-rw-r--r--backend/src/index.js3
-rw-r--r--backend/src/resolvers/Mutation.js8
-rw-r--r--backend/src/resolvers/Query.js13
4 files changed, 101 insertions, 23 deletions
diff --git a/backend/src/generated/prisma.graphql b/backend/src/generated/prisma.graphql
index 402e097..a0c3a3f 100644
--- a/backend/src/generated/prisma.graphql
+++ b/backend/src/generated/prisma.graphql
@@ -10,6 +10,8 @@ type CartItem implements Node {
quantity: Int!
item(where: ItemWhereInput): Item!
user(where: UserWhereInput): User!
+ createdAt: DateTime!
+ updatedAt: DateTime!
}
type Item implements Node {
@@ -18,6 +20,8 @@ type Item implements Node {
description: String!
image: String
price: Int!
+ createdAt: DateTime!
+ updatedAt: DateTime!
}
type Order implements Node {
@@ -25,6 +29,8 @@ type Order implements Node {
items(where: ItemWhereInput, orderBy: ItemOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [Item!]
total: Int!
user(where: UserWhereInput): User!
+ createdAt: DateTime!
+ updatedAt: DateTime!
charge: String!
}
@@ -50,6 +56,8 @@ type User implements Node {
resetToken: String
resetTokenExpiry: String
cart(where: CartItemWhereInput, orderBy: CartItemOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [CartItem!]
+ createdAt: DateTime!
+ updatedAt: DateTime!
}
@@ -113,15 +121,17 @@ enum CartItemOrderByInput {
id_DESC
quantity_ASC
quantity_DESC
- updatedAt_ASC
- updatedAt_DESC
createdAt_ASC
createdAt_DESC
+ updatedAt_ASC
+ updatedAt_DESC
}
type CartItemPreviousValues {
id: ID!
quantity: Int!
+ createdAt: DateTime!
+ updatedAt: DateTime!
}
type CartItemSubscriptionPayload {
@@ -197,6 +207,22 @@ input CartItemWhereInput {
quantity_lte: Int
quantity_gt: Int
quantity_gte: Int
+ createdAt: DateTime
+ createdAt_not: DateTime
+ createdAt_in: [DateTime!]
+ createdAt_not_in: [DateTime!]
+ createdAt_lt: DateTime
+ createdAt_lte: DateTime
+ createdAt_gt: DateTime
+ createdAt_gte: DateTime
+ updatedAt: DateTime
+ updatedAt_not: DateTime
+ updatedAt_in: [DateTime!]
+ updatedAt_not_in: [DateTime!]
+ updatedAt_lt: DateTime
+ updatedAt_lte: DateTime
+ updatedAt_gt: DateTime
+ updatedAt_gte: DateTime
item: ItemWhereInput
user: UserWhereInput
}
@@ -246,10 +272,10 @@ enum ItemOrderByInput {
image_DESC
price_ASC
price_DESC
- updatedAt_ASC
- updatedAt_DESC
createdAt_ASC
createdAt_DESC
+ updatedAt_ASC
+ updatedAt_DESC
}
type ItemPreviousValues {
@@ -258,6 +284,8 @@ type ItemPreviousValues {
description: String!
image: String
price: Int!
+ createdAt: DateTime!
+ updatedAt: DateTime!
}
type ItemSubscriptionPayload {
@@ -365,6 +393,22 @@ input ItemWhereInput {
price_lte: Int
price_gt: Int
price_gte: Int
+ createdAt: DateTime
+ createdAt_not: DateTime
+ createdAt_in: [DateTime!]
+ createdAt_not_in: [DateTime!]
+ createdAt_lt: DateTime
+ createdAt_lte: DateTime
+ createdAt_gt: DateTime
+ createdAt_gte: DateTime
+ updatedAt: DateTime
+ updatedAt_not: DateTime
+ updatedAt_in: [DateTime!]
+ updatedAt_not_in: [DateTime!]
+ updatedAt_lt: DateTime
+ updatedAt_lte: DateTime
+ updatedAt_gt: DateTime
+ updatedAt_gte: DateTime
}
input ItemWhereUniqueInput {
@@ -450,17 +494,19 @@ enum OrderOrderByInput {
id_DESC
total_ASC
total_DESC
- charge_ASC
- charge_DESC
- updatedAt_ASC
- updatedAt_DESC
createdAt_ASC
createdAt_DESC
+ updatedAt_ASC
+ updatedAt_DESC
+ charge_ASC
+ charge_DESC
}
type OrderPreviousValues {
id: ID!
total: Int!
+ createdAt: DateTime!
+ updatedAt: DateTime!
charge: String!
}
@@ -539,6 +585,22 @@ input OrderWhereInput {
total_lte: Int
total_gt: Int
total_gte: Int
+ createdAt: DateTime
+ createdAt_not: DateTime
+ createdAt_in: [DateTime!]
+ createdAt_not_in: [DateTime!]
+ createdAt_lt: DateTime
+ createdAt_lte: DateTime
+ createdAt_gt: DateTime
+ createdAt_gte: DateTime
+ updatedAt: DateTime
+ updatedAt_not: DateTime
+ updatedAt_in: [DateTime!]
+ updatedAt_not_in: [DateTime!]
+ updatedAt_lt: DateTime
+ updatedAt_lte: DateTime
+ updatedAt_gt: DateTime
+ updatedAt_gte: DateTime
charge: String
charge_not: String
charge_in: [String!]
@@ -862,10 +924,10 @@ enum UserOrderByInput {
resetToken_DESC
resetTokenExpiry_ASC
resetTokenExpiry_DESC
- updatedAt_ASC
- updatedAt_DESC
createdAt_ASC
createdAt_DESC
+ updatedAt_ASC
+ updatedAt_DESC
}
type UserPreviousValues {
@@ -877,6 +939,8 @@ type UserPreviousValues {
age: Int
resetToken: String
resetTokenExpiry: String
+ createdAt: DateTime!
+ updatedAt: DateTime!
}
type UserSubscriptionPayload {
@@ -1114,6 +1178,22 @@ input UserWhereInput {
resetTokenExpiry_not_starts_with: String
resetTokenExpiry_ends_with: String
resetTokenExpiry_not_ends_with: String
+ createdAt: DateTime
+ createdAt_not: DateTime
+ createdAt_in: [DateTime!]
+ createdAt_not_in: [DateTime!]
+ createdAt_lt: DateTime
+ createdAt_lte: DateTime
+ createdAt_gt: DateTime
+ createdAt_gte: DateTime
+ updatedAt: DateTime
+ updatedAt_not: DateTime
+ updatedAt_in: [DateTime!]
+ updatedAt_not_in: [DateTime!]
+ updatedAt_lt: DateTime
+ updatedAt_lte: DateTime
+ updatedAt_gt: DateTime
+ updatedAt_gte: DateTime
posts_every: PostWhereInput
posts_some: PostWhereInput
posts_none: PostWhereInput
diff --git a/backend/src/index.js b/backend/src/index.js
index 22cc9ef..3630b74 100644
--- a/backend/src/index.js
+++ b/backend/src/index.js
@@ -35,4 +35,5 @@ server.start(() => console.log('Server is running on http://localhost:4000'));
// overwrite console.log
const chalk = require('chalk');
-global.console.l = (...butta) => console.log(chalk.bold.yellow(...butta));
+// global.console.l = (...butta) => console.log(chalk.bold.yellow(...butta));
+global.console.l = console.log;
diff --git a/backend/src/resolvers/Mutation.js b/backend/src/resolvers/Mutation.js
index 1c071fe..6349109 100644
--- a/backend/src/resolvers/Mutation.js
+++ b/backend/src/resolvers/Mutation.js
@@ -251,14 +251,6 @@ const mutations = {
return ctx.db.mutation.deleteCartItem({
where: { id: args.id },
});
- // const userId = getUserId(ctx);
- // return ctx.db.query.user({ where: { id: userId } }, '{ id, cart { id, quantity }}');
- // const cartItem = await ctx.db.query.cartItem({
- // where: { id: args.id },
- // });
-
- // console.log(cartItem);
- // return cartItem;
},
async createOrder(parent, args, ctx, info) {
const userId = getUserId(ctx);
diff --git a/backend/src/resolvers/Query.js b/backend/src/resolvers/Query.js
index 8649e43..2aabdb7 100644
--- a/backend/src/resolvers/Query.js
+++ b/backend/src/resolvers/Query.js
@@ -41,10 +41,15 @@ const Query = {
return ctx.db.query.user({ where: { id } }, info);
},
async orders(parent, args, ctx, info) {
- console.l('--------------------FETCHING ORDERS---------------------');
- console.log(args);
- return ctx.db.query.orders({}, info);
- console.l('--------------------FETCHING ORDERS---------------------');
+ const userId = getUserId(ctx);
+ return ctx.db.query.orders(
+ {
+ where: {
+ user: { id: userId },
+ },
+ },
+ info
+ );
},
};