I'm having a hard time figuring out how to update a list of items (in the cache). When a new item is created with react-apollo
.
The <CreateItemButton />
component is (in my case) not nested within <ListItems />
component. From what I can figure out, I need to update the cache via the update function in my createItemButton <Mutation />
component.
The problem is when I try to store.readQuery({query: GET_LIST_ITEMS, variables: ???})
to get the current list of items (to append my recently created item), this can have variables/filters (for pagination, sorting etc.).
How do I know what variable to pass to the store.readQuery
function, is there a sort of "last used variables" around this, or do you have any other suggestion on how to solve this issue?