summaryrefslogtreecommitdiffstats
path: root/backend/src/resolvers
diff options
context:
space:
mode:
Diffstat (limited to 'backend/src/resolvers')
-rw-r--r--backend/src/resolvers/Mutation.js31
-rw-r--r--backend/src/resolvers/Query.js18
2 files changed, 42 insertions, 7 deletions
diff --git a/backend/src/resolvers/Mutation.js b/backend/src/resolvers/Mutation.js
index 2796cf8..fbae6fe 100644
--- a/backend/src/resolvers/Mutation.js
+++ b/backend/src/resolvers/Mutation.js
@@ -35,8 +35,35 @@ const mutations = {
},
// Creation of Post Mutations
- createItem: forwardTo('db'),
- deleteItem: forwardTo('db'),
+ async createItem(parent, args, ctx, info) {
+ return ctx.db.mutation.createItem({ data: { ...args } }, info);
+ },
+
+ async deleteItem(parent, args, ctx, info) {
+ console.log('gonna delete one');
+ console.log(args);
+ return ctx.db.mutation.deleteItem(
+ {
+ where: {
+ id: args.id,
+ },
+ },
+ info
+ );
+ },
+
+ async updateItem(parent, args, ctx, info) {
+ console.log('Updating an item');
+ const updates = { ...args };
+ delete updates.id;
+ return ctx.db.mutation.updateItem({
+ where: { id: args.id },
+ data: {
+ ...updates,
+ },
+ });
+ },
+
async createDraft(parent, { title, text }, ctx, info) {
// const userId = getUserId(ctx);
const userId = getUserId(ctx);
diff --git a/backend/src/resolvers/Query.js b/backend/src/resolvers/Query.js
index 9d9d142..a2eb749 100644
--- a/backend/src/resolvers/Query.js
+++ b/backend/src/resolvers/Query.js
@@ -1,18 +1,26 @@
const { getUserId, Context } = require('../utils');
+const { forwardTo } = require('prisma-binding');
const Query = {
+ items(parent, args, ctx, info) {
+ // check auth
+ return ctx.db.query.items({ ...args }, info);
+ },
+
+ itemsConnection: forwardTo('db'),
+
feed(parent, args, ctx, info) {
- return ctx.db.query.posts({ where: { isPublished: true } }, info);
+ return ctx.db.query.posts({}, info);
},
drafts(parent, args, ctx, info) {
- const id = getUserId(ctx);
+ // const id = getUserId(ctx);
const where = {
isPublished: false,
- author: {
- id,
- },
+ // author: {
+ // id,
+ // },
};
return ctx.db.query.posts({ where }, info);