Edit {item.id}
))}
)
}
}
// 1
// We export the graphQL HOC - this will fetch the data and inject it into the ItemList compeont via props
// Create some Enhancers
const itemsEnahncer = graphql(ALL_ITEMS_QUERY, { name: 'allLinksQuery' });
const deleteItemEnhancer = graphql(DELETE_ITEM_MUTATION, {
name: 'removeItemMutation',
options: {
update: (proxy, { data: { deleteItem } }) => {
// grab the data from our cache
const data = proxy.readQuery({ query: ALL_ITEMS_QUERY });
// filter out the delted item
data.allItems = data.allItems.filter(item => item.id !== deleteItem.id);
// and then "set state" (update cache), so it will update whereever we have used this data on the page
proxy.writeQuery({ query: ALL_ITEMS_QUERY, data });
},
}
});
export default compose(itemsEnahncer, deleteItemEnhancer)(ItemList)