-
Notifications
You must be signed in to change notification settings - Fork 786
[Bug] loading
doesn't change back to false if updateQuery doesn't mutate the store
#228
Comments
Thanks @migueloller. I may end up doing this myself, I'll let you know if so. |
@migueloller @tmeasday Is there any known workaround? |
@davidyaha, the way I got to work around it was by checking if the query variable existed and used that as a proxy for loading. For example, if your top level query is named I would also recommend to assume that loading is of type |
We do class Foo extends Component {
constructor() {
super();
this.state = {
hasRefetched: false,
refetching: false,
};
}
setRefetchingToFalse() {
this.setState({ refetching: false });
}
fetchMore() {
this.setState({ refetching: true, hasRefetched: true });
this.props.data.fetchMore({
// ...
}).then(this.setRefetchingToFalse).catch(this.setRefetchingToFalse);
}
render() {
const loading = this.state.hasRefetched ? this.state.refetching : this.props.data.loading;
// ...
}
} It's not perfect by any means, and could have some nasty bugs with regards to loading state in other components, but it works for our use case. |
@migueloller can you try version 0.5.8? |
@jbaxleyiii From what I see now, it is not changing into true when I use fetchMore. There is a new |
I'm also seeing this bug since updating to 0.5.8 - any work arounds? |
Ok, I foolishly created a failing test and then realised it doesn't make sense any more: https://github.com/apollostack/react-apollo/tree/228-failing-test |
@davidyaha you are correct on both counts. See apollographql/apollo-client#707 |
@webular by "bug" do you mean the fact that it never goes loading when you If so a "workaround"[1] is to use your own internal state, just as you would for mutations: @graphql(...)
class Foo extends React {
onFetchMore() {
this.setState({ fetching: true });
this.data.fetchMore(...)
.then(() => this.setState({ fetching: false });
}
} We should document this better but I'm going to close this because this isn't really a bug any more. [1] Arguably this behaviour is more correct than before, but we did take away a feature I guess ;) |
I am still having this issue. I see in the docs that What am I doing wrong here? (assume my code is the same as the docs because that is what I used as a model) |
👍 also still having this issue |
This is a continuation of apollographql/apollo-client#698.
@tmeasday,
I'm very low on time at the moment but I'll try to get a PR done in the next couple of days with the failing test case.
The text was updated successfully, but these errors were encountered: