I can't seem to get my cache to update after a mutation, although I passed the typename and id to reference the object to modify. What am I doing wrong? I reproduced a simple example here.
I first initialized my cache with the data -
const writeInitialData = () => {
cache.writeQuery({
query: gql`
query {
test
}
`,
data: {
test: {
__typename: 'test',
id: 'id1',
string: 'initial string',
}
},
});
};
I then executed the mutation on my client.
updateTest: (_, __, { cache }) => {
cache.modify({
id: cache.identify({
__typename: 'test',
id: 'id1',
}),
fields: {
string: 'changed string',
},
});
}
however, the value in the cache did not change, and furthermore if I console.log() the returned value of cache.modify, it gives me false, implying that there is no update to the cache.