I have a list of todo items and I would like to receive notifications when items are added or deleted from the list.
So far I have implemented item addition notification:
<Connect
query={graphqlOperation(listTodos)}
subscription={graphqlOperation(onCreateTodo)}
onSubscriptionMsg={(prev, { onCreateTodo }) => {
return addItem(prev, onCreateTodo)
}}
>
{({ data: { listTodos }, loading, error }) => {
if (loading) return "Loading"
if (error) return "Error"
return listTodos.items
.map(({ id, name }) => <div key={id}>{name}</div>)
}}
</Connect>
Now I am wondering, how can I add item deletion notification to this component? Does subscription attribute accept an array of graphql operations?
Thanks!