Created
May 24, 2020 00:11
-
-
Save david-mart/adab4a253044659278160ab482a4f0e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const onUpdate = (key) => (value) => { | |
const task = { [key]: value }; | |
updateTask({ | |
variables: { task, id }, | |
update: (proxy, { data = {} }) => { | |
// update cache with local values | |
proxy.writeData({ id: `Task:${id}`, data: task }); | |
// or update cache with the values coming from the server, | |
// for example if you need to reflect the updated timestamp | |
const { updateTask } = data; | |
proxy.writeData({ id: `Task:${id}`, data: updateTask }); | |
}, | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment