-
Notifications
You must be signed in to change notification settings - Fork 786
Refetch does not toggle loading #1529
Comments
I have the same issue. I thought I can find out about refetch in progress from networkStatus regarding to: https://www.apollographql.com/docs/react/basics/queries.html#graphql-query-data-networkStatus but networkStatus is not being updated to 4 at all. |
This is how I handle the reloading state: import { graphql } from "react-apollo";
import { withState, mapProps } from "recompose";
import { flowRight } from "lodash";
const withQuery = graphql(yourQuery, yourQueryOptions);
const withReloadingState = withState("reloading", "setReloading", false);
const withEnhancedRefetch = mapProps(
({
setReloading,
reloading,
data: { refetch, ...dataRest },
...remainingProps
}) => ({
data: {
reloading,
refetch: (...args) => {
if (reloading) {
return Promise.reject(new Error("Reload already in progress."));
}
setReloading(true);
return refetch(...args)
.then(result => {
setReloading(false);
return result;
})
.catch(err => {
setReloading(false);
return Promise.reject(err);
});
},
...dataRest
},
...remainingProps
})
);
const withReloadingProp = flowRight(withReloadingState, withEnhancedRefetch);
const MyEnhancedComponent = flowRight(withQuery, withReloadingProp)(
MyComponent
); |
I have the same issue but my biggest problem is that it seems it does not even trigger the props transformation if it was already made |
Can you check out 2.1.0-beta.3? AFAIK this should be fixed there. |
I tried to build it and couldn't . I'm using a node:9.3.0 image and ran: yarn install
yarn run compile Do I need to do anything fancier? |
You can install it via |
Is this supposed to be working again? I'm using
And the problem ist, the retry button is not hidden after you clicked it, so it looks as if nothing happens at all and you'd click the button again and again. The way I test this is I switch Chrome to offline in the dev tools, then load the page, then switch it to slow 3G. I tried downgrading to |
@bxt You could convert the example that I provided to the Render-Prop-API (https://reactjs.org/docs/render-props.html). I have no time to provide an example for you. But the Higher-Order-Component (https://reactjs.org/docs/higher-order-components.html) approach I provided in #1529 (comment) does still work on the newest apollo-client version. |
Hmmm okay. I tried the versions mentioned in apollographql/apollo-client#1622 (comment) and it seems like |
This should no longer be an issue with current day |
#321
I am still experiencing this issue and so are some others in the thread. If someone could take a look that would be great :)
It would be nice if there was perhaps a differentiation between loading (the initial fetch) and loading a refetch? - as sometimes - different display logic is used.
I guess you could add a prop - maybe 'loading context' for this quite easily that would not break BC.
The text was updated successfully, but these errors were encountered: