apollo-client: Refetch is not refetching
Hello!
I have a pretty simple use case here where I have a query which fetches all contacts for a particular account. In another area of the app, I have an import feature which allows the user to import a csv of contacts. Upon returning to the contacts page, I call refetch on the query, however, the new data is never actually fetched, only the old data is returned without the added contacts. Upon refreshing the app, the new data is properly fetched. Am I missing something?
function isLoading(props) {
const { accounts, contacts } = props;
return accounts.loading || contacts.loading;
}
module.exports = class extends React.Component {
componentDidMount() {
this.props.contacts.refetch();
}
render() {
console.log(isLoading(this.props));
const Footer = () => (
<div className="box-footer text-right">
<Button
label="Create Contact"
size="sm"
onClick={ () => showContact() }
/>
</div>
);
return !isLoading(this.props) ? (
<WidgetBox boxTitle="Contacts" Footer={ Footer }>
{ renderContacts(this.props) }
</WidgetBox>
) : null;
}
};
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 2
- Comments: 17 (12 by maintainers)
That’s odd -
refetch
is definitely intended to always fetch from the server regardless of other options.@helfer I can do that. I did confirm that refetch was being called, but the returned result was the cached result, and not the new result from the server.
Is refetch working for you as expected?