diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-03-20 21:52:36 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-03-20 21:52:36 -0400 |
| commit | 93495ce146c4e81ecfab3a0bca99460e75a759da (patch) | |
| tree | 12b2de283a017ff6cc53c1175371f9add84238d2 /backend/src/resolvers | |
| parent | 92f612a995c54f7423bd2b760fb1a324044693a6 (diff) | |
tests
Diffstat (limited to 'backend/src/resolvers')
| -rw-r--r-- | backend/src/resolvers/Mutation.js | 71 | ||||
| -rw-r--r-- | backend/src/resolvers/Query.js | 25 |
2 files changed, 6 insertions, 90 deletions
diff --git a/backend/src/resolvers/Mutation.js b/backend/src/resolvers/Mutation.js index 6eeab7c..3d9ebb8 100644 --- a/backend/src/resolvers/Mutation.js +++ b/backend/src/resolvers/Mutation.js @@ -66,68 +66,6 @@ const mutations = { }); }, - // async createDraft(parent, { title, text }, ctx, info) { - // // const userId = getUserId(ctx); - // const userId = getUserId(ctx); - // return ctx.db.mutation.createPost( - // { - // data: { - // title, - // text, - // isPublished: false, - // author: { - // connect: { id: userId }, - // }, - // }, - // }, - // info - // ); - // }, - - // async publish(parent, { id }, ctx, info) { - // const userId = getUserId(ctx); - // const postExists = await ctx.db.exists.Post({ - // id, - // author: { id: userId }, - // }); - // if (!postExists) { - // throw new Error(`Post not found or you're not the author`); - // } - - // return ctx.db.mutation.updatePost( - // { - // where: { id }, - // data: { isPublished: true }, - // }, - // info - // ); - // }, - - // async deletePost(parent, { id }, ctx, info) { - // const userId = getUserId(ctx); - // const postExists = await ctx.db.exists.Post({ - // id, - // author: { id: userId }, - // }); - // if (!postExists) { - // throw new Error(`Post not found or you're not the author`); - // } - - // return ctx.db.mutation.deletePost({ where: { id } }); - // }, - - // // Wes Added this brand new one! - // async updatePost(parent, args, ctx, info) { - // const updatedPost = await ctx.db.mutation.updatePost({ - // where: { id: args.id }, - // data: { - // title: args.title, - // text: args.text, - // }, - // }); - // return updatedPost; - // }, - // Send password request async requestReset(parent, args, ctx, info) { // 1. find if there is a user with that email @@ -307,18 +245,15 @@ const mutations = { // 6. Clean up, clear the users cart adn send back { user, order } // Delete the users current cart items const cartItemIds = user.cart.map(cartItem => cartItem.id); - const deletedCartItems = await ctx.db.mutation.deleteManyCartItems({ + await ctx.db.mutation.deleteManyCartItems({ where: { id_in: cartItemIds, }, }); - console.l('--------ORDER-------------'); - console.log(order); - console.l('--------ORDER-------------'); + // 5. Send the order back to the client return order; - // 4. Send an email with their order - // 5. Send the order back + // 4. TODO: Send an email with their order }, async updateUser(parent, args, ctx, info) { const userId = getUserId(ctx); diff --git a/backend/src/resolvers/Query.js b/backend/src/resolvers/Query.js index 262517a..2aa4f5c 100644 --- a/backend/src/resolvers/Query.js +++ b/backend/src/resolvers/Query.js @@ -8,31 +8,11 @@ const Query = { }, itemsConnection: forwardTo('db'), - order: forwardTo('db'), - - // feed(parent, args, ctx, info) { - // return ctx.db.query.posts({}, info); - // }, - - // drafts(parent, args, ctx, info) { - // // const id = getUserId(ctx); - - // const where = { - // isPublished: false, - // // author: { - // // id, - // // }, - // }; - // return ctx.db.query.posts({ where }, info); - // }, - - // post(parent, { id }, ctx, info) { - // return ctx.db.query.post({ where: { id } }, info); - // }, + // TODO: Make sure they own this order before looking it up + order: forwardTo('db'), me(parent, args, ctx, info) { - console.l('me!'); const Authorization = ctx.request.get('Authorization'); if (!Authorization || Authorization === 'null') { console.log('Authorization is null'); @@ -41,6 +21,7 @@ const Query = { const id = getUserId(ctx); return ctx.db.query.user({ where: { id } }, info); }, + async orders(parent, args, ctx, info) { const userId = getUserId(ctx); return ctx.db.query.orders( |
