Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Refetched query not updating "loading" prop #1347

Closed
tnrich opened this issue Nov 20, 2017 · 8 comments
Closed

Refetched query not updating "loading" prop #1347

tnrich opened this issue Nov 20, 2017 · 8 comments

Comments

@tnrich
Copy link

tnrich commented Nov 20, 2017

Hey there,

I've got a component that is wrapped with an apollo query. I use react-apollo's "refetchQueries" to cause that query to update itself (after a mutation is run by a separate component). The new data is getting fetched, but unfortunately, the "loading" prop for that mutation does not appear to be getting changed. Thus I am not able to get a spinner to show over the component while it's updated data is getting loaded.

Is this how refetch queries is set up to work?

Is there a way to get the components interested in the query to be made aware that a fresh query is being made?

Hope that all makes sense.
Thanks!

@jbaxleyiii
Copy link
Contributor

@tnrich would you be able to create a small reproduction showing this?

@tnrich
Copy link
Author

tnrich commented Nov 21, 2017

@jbaxleyiii here ya go: https://codesandbox.io/s/ym1pwrjmzx

as you can see, the "Loading…" message appears on the initial load, but it does not show up on subsequent presses of the "Add Person Button" (even though the "people" query is getting run again by refetchQueries).

Please let me know if you have any questions about the implementation.

@t0x1c123
Copy link

t0x1c123 commented Nov 25, 2017

Yeah same issue here #1331

tonyjiang88215 pushed a commit to tonyjiang88215/react-apollo that referenced this issue Dec 21, 2017
       * redefine refetch function, if
option.notifyOnLoadingStatusChange is true, we forceUpdate
       * after calling original refetch to pass the new dataProps to
the wrappedComponent.
       * That can makes WrappedComponent be able to watch on loading
status;
@cannibal
Copy link

cannibal commented Jan 5, 2018

Im experiencing the same issue, get the loading container as per the recipe in apollo docs for initial load - this does not appear on pagination queries using fetchMore because 'loading' variable is not updated.

@djyde
Copy link

djyde commented May 29, 2018

how is it going?

@tknickman
Copy link

tknickman commented Sep 20, 2018

I just ran into this issue as well. I tried to proxy into the loading state with notifyOnNetworkStatusChange and networkStatus, but the networkStatus is 7 (indicating the data is ready) even when the <Query /> is being refetched from a <Mutation />.

I'm getting around this for now by passing refetch from the <Query /> I need to reload down and calling that in the <Mutation />'s onComplete method.

This is working fine, but refetchQueries would be a much more elegant solution (with a lot less prop drilling!)

@katiawheeler
Copy link

katiawheeler commented Dec 4, 2018

Any update on this? It seems like a huge limitation.

@hwillson
Copy link
Member

This should no longer be an issue with current day react-apollo, but if anyone is still encountering this, and can provide a small runnable (and current) reproduction, we'll take a look. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants