I'd like to refetch data from the server every time the componentDidMount 馃槈
...
componentDidMount () {
this.props.data.refetch()
}
...
The first time the component mounts everything is working as expected, on consecutive
mounts however the refetch request gets sent to the server and returns with the correct results, but the store never gets updated.
When I call refetch in the render method the store gets updated as expected!
After the refetch request returns from the server, the store should get updated with the new data
I'm also seeing this issue. To be clear, refetch sends a request to the server and the response is correct. But the Apollo store doesn't get updated.
This problem should be fixed in [email protected] by this PR: https://github.com/apollographql/apollo-client/pull/1264
Let me know if you still have this problem after 0.8.6 馃槉
I switched to the new version, but the issue remains. The Apollo store only get's updated when I use your forceFetch: true workaround from the other issue.
Hmm, then I鈥檓 not entirely sure what is causing your issue @Chris-R3. Could you fork react-apollo-error-template and put together a small case which reproduces your error? This would go a long way in helping us debug the issue.
Sure I'll look into it next week. Vacation starts tomorrow 馃槈 .
I'm having same problem - data is fetched but the store is not updated. Relevant code snippet is here:
class AccountsPage extends React.Component {
constructor(props) {
super(props);
this.state = initialState;
}
componentDidMount() {
this.props.data.refetch();
}
render() {
/* this.props.data.allAccounts.map render */
}
}
const FeedQuery = gql`query allAccounts {
allAccounts {
id
name
pin
}
}`;
const AccountsPageWithData = graphql(FeedQuery)(AccountsPage);
export default AccountsPageWithData;
I'm using "apollo-client": "^0.8.6"
@pajasevi if you update to the latest versions, does this still exist?
I updated all necessary dependencies and it's ok now. I had to use componentDidUpdate in one instance, but it works properly. Thanks @jbaxleyiii
This issue has been automatically labled because it has not had recent activity. If you have not received a response from anyone, please mention the repository maintainer (most likely @jbaxleyiii). It will be closed if no further activity occurs. Thank you for your contributions to React Apollo!
Im using react-apollo 1.4.11 and I have noticed this issue as well, specifically referring to arrays as a property of one of my objects. In my case I can see the graphQL query result in the network tab shows that my object has an empty array for a property, however the UI and react show the props data as containing a previous value, I would have expected the refetch to have set the property to an empty array in react as returned from the server.
This issue has been automatically labled because it has not had recent activity. If you have not received a response from anyone, please mention the repository maintainer (most likely @jbaxleyiii). It will be closed if no further activity occurs. Thank you for your contributions to React Apollo!
This issue has been automatically closed because it has not had recent activity after being marked as no recent activyt. If you belive this issue is still a problem or should be reopened, please reopen it! Thank you for your contributions to React Apollo!
Most helpful comment
Im using react-apollo 1.4.11 and I have noticed this issue as well, specifically referring to arrays as a property of one of my objects. In my case I can see the graphQL query result in the network tab shows that my object has an empty array for a property, however the UI and react show the props data as containing a previous value, I would have expected the refetch to have set the property to an empty array in react as returned from the server.