diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-02-02 15:23:20 -0500 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-02-02 15:23:20 -0500 |
| commit | eabff7cd396d1f37ceb929e666f082ce57f07919 (patch) | |
| tree | 6fbd487688ee9e53bada734288994c35b732150e /backend/src/resolvers/Mutation.js | |
| parent | cd0b07b3adb36fb5ec098f9e511ab45d774fee7b (diff) | |
updateS
Diffstat (limited to 'backend/src/resolvers/Mutation.js')
| -rw-r--r-- | backend/src/resolvers/Mutation.js | 31 |
1 files changed, 29 insertions, 2 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); |
