From a89c0d006b97a4534b661b13d98b1fb827df77da Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Tue, 20 Nov 2018 18:48:48 +0100 Subject: [PATCH] Save objective group via mutation --- .../NewObjectiveGroupWizard.vue | 54 +++++++++++-------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/client/src/components/objective-groups/NewObjectiveGroupWizard.vue b/client/src/components/objective-groups/NewObjectiveGroupWizard.vue index 92ac1f8a..84497951 100644 --- a/client/src/components/objective-groups/NewObjectiveGroupWizard.vue +++ b/client/src/components/objective-groups/NewObjectiveGroupWizard.vue @@ -3,7 +3,7 @@ - + { - try { - const query = ROOM_ENTRIES_QUERY; - const variables = {slug: this.room.slug}; - const data = store.readQuery({query, variables}); - if (data.room && data.room.roomEntries) { - data.room.roomEntries.edges.unshift({ - node: roomEntry, - __typename: 'RoomEntryNode' - }); - store.writeQuery({query, variables, data}); - } - } catch (e) { - // Query did not exist in the cache, and apollo throws a generic Error. Do nothing + // todo: make update work + // update: (store, {data: {addObjectiveGroup: {objectiveGroup}}}) => { + // const query = MODULE_DETAILS_QUERY; + // const variables = {slug: this.$route.params.slug}; + // const data = store.readQuery({query, variables}); + // debugger; + // if (data.module && data.module.objectiveGroups) { + // data.module.objectiveGroups.edges.push({ + // node: objectiveGroup, + // __typename: 'ObjectiveGroupNode' + // }); + // store.writeQuery({query, variables, data}); + // } + // + // } + refetchQueries: [{ + query: MODULE_DETAILS_QUERY, + variables: { + slug: this.$route.params.slug } - } + }] + }).then(() => { this.hideModal(); });