Use `cache.identify` instead of manually creating a cache ID
This commit is contained in:
parent
2fbd878387
commit
9f8464ff7b
|
|
@ -55,13 +55,11 @@
|
|||
},
|
||||
update(store, {data: {updateSolutionVisibility: {success, solutionsEnabled}}}) {
|
||||
if (success) {
|
||||
// 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
|
||||
// https://www.apollographql.com/docs/react/caching/cache-interaction/#obtaining-an-objects-cache-id
|
||||
const id = store.identify({
|
||||
__typename: 'ModuleNode',
|
||||
slug
|
||||
});
|
||||
const fragment = MODULE_FRAGMENT;
|
||||
const module = store.readFragment({fragment, id});
|
||||
const data = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue