How to update cache of graphql queries without an error?
const [ createBook ] = useMutation(CREATE_BOOK, {
onError: (error) => {
props.notify(error.message)
}
,
update: (store, response) => {
console.log('-->', response.data.addBook)
const dataInStore = store.readQuery({ query: ALL_BOOKS })
console.log(dataInStore)
dataInStore.allBooks.push(response.data.addBook)
store.writeQuery({
query: ALL_BOOKS,
data: dataInStore
})
}
})
console.log(dataInStore)
shows object with property Allbooks which is array to which I try to push