nexneo
June 1, 2020, 2:06pm
#1
Hello,
I’m new to Apollo, mostly I have used Redux so far.
I have Entity form in cell A and Entity list in cell B. Once I update Entity, how I can force cell B to re-fetch data so list can be updated.
I have found Reading and writing data to the cache - Apollo GraphQL Docs but kind of lost.
Thanks for any help!
1 Like
This thread might be helpful: How to trigger a cell refresh
1 Like
nexneo
June 1, 2020, 7:24pm
#3
Thanks, I had tried that first before asking. It kind of works but it keeps refreshing always. I only want to fetch fresh data only when update is made. i.e after mutation
nexneo
June 1, 2020, 7:52pm
#4
I think, I was looking for something like this. I will try this out,
status
}
}
`
const AddTodo = () => {
const [createTodo] = useMutation(CREATE_TODO, {
// An example of updating Apollo's cache. This will trigger a re-rended of any
// affected components, so we don't need to do anything but update the cache.
update: (cache, { data: { createTodo } }) => {
const { todos } = cache.readQuery({ query: TODOS })
cache.writeQuery({
query: TODOS,
data: { todos: todos.concat([createTodo]) },
})
},
})
const submitTodo = (body) => {
// An example of providing an optimistic response to a GraphQL mutation. Note
// that `__typename` is required for each object in order to make this work.
createTodo({
3 Likes