parent
e05edc0867
commit
ddf5360c51
|
|
@ -16,20 +16,20 @@
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
Checkbox
|
Checkbox,
|
||||||
},
|
},
|
||||||
|
|
||||||
apollo: {
|
apollo: {
|
||||||
me: meQuery,
|
me: meQuery,
|
||||||
module: moduleQuery
|
module: moduleQuery,
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
me: {
|
me: {
|
||||||
permissions: []
|
permissions: [],
|
||||||
},
|
},
|
||||||
module: {}
|
module: {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
},
|
},
|
||||||
slug() {
|
slug() {
|
||||||
return this.$route.params.slug;
|
return this.$route.params.slug;
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -50,20 +50,29 @@
|
||||||
variables: {
|
variables: {
|
||||||
input: {
|
input: {
|
||||||
slug,
|
slug,
|
||||||
enabled
|
enabled,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
update(store, {data: {updateSolutionVisibility: {success, solutionsEnabled}}}) {
|
update(store, {data: {updateSolutionVisibility: {success, solutionsEnabled}}}) {
|
||||||
if (success) {
|
if (success) {
|
||||||
const id = `ModuleNode:${slug}`;
|
// according to the documentation, this should be
|
||||||
|
// const id = `ModuleNode:${slug}`;
|
||||||
|
// see: https://www.apollographql.com/docs/react/caching/cache-interaction/#readfragment
|
||||||
|
// but in the actual cache, it's found like this
|
||||||
|
const id = `ModuleNode:{"slug":"${slug}"}`;
|
||||||
|
// there's an open issue on Stackoverflow here
|
||||||
|
// https://stackoverflow.com/questions/70264586/apollo-client-readfragment-with-custom-id-keyfields
|
||||||
const fragment = MODULE_FRAGMENT;
|
const fragment = MODULE_FRAGMENT;
|
||||||
const data = store.readFragment({fragment, id});
|
const module = store.readFragment({fragment, id});
|
||||||
data.solutionsEnabled = solutionsEnabled;
|
const data = {
|
||||||
|
solutionsEnabled,
|
||||||
|
...module,
|
||||||
|
};
|
||||||
store.writeFragment({fragment, data, id});
|
store.writeFragment({fragment, data, id});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue