Skip to content

Instantly share code, notes, and snippets.

@david-mart
Created May 24, 2020 00:11
Show Gist options
  • Save david-mart/adab4a253044659278160ab482a4f0e9 to your computer and use it in GitHub Desktop.
Save david-mart/adab4a253044659278160ab482a4f0e9 to your computer and use it in GitHub Desktop.
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