summaryrefslogtreecommitdiffstats
path: root/frontend/components/DeleteItem.js
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-05-24 09:03:04 -0400
committerGitHub <noreply@github.com>2018-05-24 09:03:04 -0400
commitb294a6fa500b165aae86afbad5fce49a02314b0d (patch)
treef538c8b01f1ee41ea0c7cd0f58fcf7746b8accb8 /frontend/components/DeleteItem.js
parentee068a81a5a8e71663c78135e5e865621dba53cb (diff)
parente040b70da6a48b1eb2f2b32132fa9b2244e92780 (diff)
Merge pull request #8 from peggyrayzis/apollo-feedback
Apollo feedback
Diffstat (limited to 'frontend/components/DeleteItem.js')
-rw-r--r--frontend/components/DeleteItem.js13
1 files changed, 8 insertions, 5 deletions
diff --git a/frontend/components/DeleteItem.js b/frontend/components/DeleteItem.js
index 4ef227d..53fc04d 100644
--- a/frontend/components/DeleteItem.js
+++ b/frontend/components/DeleteItem.js
@@ -1,20 +1,23 @@
import React from 'react';
import { Mutation } from 'react-apollo';
import PropTypes from 'prop-types';
-import { REMOVE_ITEM_MUTATION, ALL_ITEMS_QUERY } from '../queries/queries.graphql';
+import {
+ REMOVE_ITEM_MUTATION,
+ ALL_ITEMS_QUERY,
+} from '../queries/queries.graphql';
class DeleteItem extends React.Component {
static propTypes = {
id: PropTypes.string.isRequired,
};
- update = (proxy, payload) => {
+ update = (cache, payload) => {
const deletedItem = payload.data.deleteItem;
- const data = proxy.readQuery({ query: ALL_ITEMS_QUERY });
+ const data = cache.readQuery({ query: ALL_ITEMS_QUERY });
// filter this one out
data.items = data.items.filter(item => item.id !== deletedItem.id);
- // write the data back to the proxy
- proxy.writeQuery({ query: ALL_ITEMS_QUERY, data });
+ // write the data back to the cache
+ cache.writeQuery({ query: ALL_ITEMS_QUERY, data });
};
render() {