I’ve tried it on the same screen and on a different screen (react native), it works ok on the same screen but doesn’t work if I trigger a mutation on a different screen and then goBack() to the original screen. Any tips?
Can you use the update function and manually update the cache?
onSubmit = async values => {
try {
this.setState({ loading: true });
let variables = {
params: {
...values
}
};
await this.props.saveHome({
variables,
update: (proxy, { data }) => {
let localData = proxy.readQuery({
query: homesQuery
});
console.log({
localData,
data
});
proxy.writeQuery({
query: homesQuery,
data: {
...localData,
homes: {
...localData.homes,
homes: [...localData.homes.homes, data.saveHome]
}
}
});
}
});
this.props.onSubmitComplete();
message.success('Home successfully added');
} catch (err) {
console.log(err);
}
};
Also, the local cache, I think, is specific to the variables used with the queries. So if you don’t call refetch queries using the same exact variables as being used on the other page, it won’t think it’s the same query. Does that make sense?