Update cache code

This commit is contained in:
Ramon Wenger 2022-01-28 23:22:28 +01:00
parent a3c616d10e
commit 656b2be364
2 changed files with 18 additions and 17 deletions

View File

@ -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
});
}
}
},
}
},
};

View File

@ -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}`);