summaryrefslogtreecommitdiffstats
path: root/sick-fits/backend/src/resolvers/Query.js
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-06-22 16:22:13 -0400
committerWes Bos <wesbos@gmail.com>2018-06-22 16:22:13 -0400
commit4e52a98a0f78d2bedfdd31a1955639143cd26fc6 (patch)
treeadee99154b9274c0c4df27ef67d63704694f5e39 /sick-fits/backend/src/resolvers/Query.js
parent5f2d4ba39a19e2900192a69a58ee211f4eda9a98 (diff)
update starter files
Diffstat (limited to 'sick-fits/backend/src/resolvers/Query.js')
-rw-r--r--sick-fits/backend/src/resolvers/Query.js61
1 files changed, 1 insertions, 60 deletions
diff --git a/sick-fits/backend/src/resolvers/Query.js b/sick-fits/backend/src/resolvers/Query.js
index 51c2c42..eebe788 100644
--- a/sick-fits/backend/src/resolvers/Query.js
+++ b/sick-fits/backend/src/resolvers/Query.js
@@ -1,62 +1,3 @@
-const { hasPermission } = require('../utils');
-
-const { forwardTo } = require('prisma-binding');
-
-const Query = {
- items: forwardTo('db'),
- itemsConnection: forwardTo('db'),
-
- async order(parent, args, ctx, info) {
- // 1. make sure they are signed in
- if (!ctx.request.userId) {
- throw new Error('You Must be signed in to view an order');
- }
-
- // 2. Create the query
- const where = {
- id: args.id,
- user: {
- id: ctx.request.userId,
- },
- };
- // 3. Fire off the query
- const [order] = await ctx.db.query.orders({ where }, info);
-
- // 4. Check that they are allowed to view the order
- if (order.user.id !== ctx.request.userId || hasPermission(ctx.request.user, ['ADMIN'])) {
- throw new Error("You don't have permission");
- }
- // 5. If everything checks out, return the order
- return order;
- },
-
- me(parent, args, ctx, info) {
- if (!ctx.request.userId) {
- return null; // don't error out, just return nothing
- }
-
- return ctx.db.query.user(
- {
- where: { id: ctx.request.userId },
- },
- info
- );
- },
-
- async orders(parent, args, ctx, info) {
- const { userId } = ctx.request;
- if (!userId) {
- throw new Error('You must be signed in to see your orders');
- }
- return ctx.db.query.orders(
- {
- where: {
- user: { id: userId },
- },
- },
- info
- );
- },
-};
+const Query = {};
module.exports = Query;