Skip to content

Instantly share code, notes, and snippets.

@smolinari
Created April 5, 2020 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smolinari/9333b68202f0a3a9a4ef43c8e0c2d12c to your computer and use it in GitHub Desktop.
Save smolinari/9333b68202f0a3a9a4ef43c8e0c2d12c to your computer and use it in GitHub Desktop.
<template>
...
</template>
<script>
...
methods: {
updateCache (store, { data: { toggleTodo } }) {
const id = `TodoItem:${this.id}`
const fragment = queries.toggleTodoFragment
const todo = store.readFragment({ fragment, id })
const data = { ...todo, completed: !todo.completed }
store.writeData({ data, id })
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment