From 656b2be3647cf111b0b1bdbedecb39361317e46d Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Fri, 28 Jan 2022 23:22:28 +0100 Subject: [PATCH] Update cache code --- client/src/graphql/cache.js | 32 +++++++++---------- .../src/mixins/update-project-share-state.js | 3 +- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/client/src/graphql/cache.js b/client/src/graphql/cache.js index b854e31d..96886e98 100644 --- a/client/src/graphql/cache.js +++ b/client/src/graphql/cache.js @@ -58,22 +58,22 @@ const typePolicies = { objectiveGroup: {read: idToRefFactory('ObjectiveGroupNode')}, projectEntry: {read: idToRefFactory('ProjectEntryNode')}, // project: {read: idToRefFactory('ProjectNode')}, - // project: { - // read(_, {args: {slug, id}, toReference}) { - // console.log(`Trying to reference project with slug ${slug}, id ${id}`); - // if (slug) { - // return toReference({ - // __typename: 'ProjectNode', - // slug - // }); - // } else { - // return toReference({ - // __typename: 'ProjectNode', - // id - // }); - // } - // } - // }, + project: { + read(_, {args: {slug, id}, toReference}) { + console.log(`Trying to reference project with slug ${slug}, id ${id}`); + if (slug) { + return toReference({ + __typename: 'ProjectNode', + id: slug + }); + } else { + return toReference({ + __typename: 'ProjectNode', + id + }); + } + } + }, } }, }; diff --git a/client/src/mixins/update-project-share-state.js b/client/src/mixins/update-project-share-state.js index 8479332f..a1c86d1c 100644 --- a/client/src/mixins/update-project-share-state.js +++ b/client/src/mixins/update-project-share-state.js @@ -14,12 +14,13 @@ export default { variables: { input, }, - update(store, {data: {updateProjectSharedState: {shared: final, errors}}}) { + update: (store, {data: {updateProjectSharedState: {shared: final, errors}}}) => { if (!errors) { const query = PROJECT_QUERY; const variables = { id: id, }; + const {project} = store.readQuery({query, variables}); this.$log.debug(`updating project ${project.id} ${project.title}`);