-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
networkStatus doesn't change for refetchQueries #1263
Comments
I have the same problem with the fetchMore() function, the networkStatus is always set at 7. I have passed the I'm using apollo-client 0.6.0 and react-apollo 0.8.3 |
@srosset81 For |
@RAFREX can we see your mutation’s code for this? There are some cases where we don’t currently expect network status to change. |
@calebmer, there are two mutations where it happens: mutation createPortoflio($input: CreatePortfolioInput!) {
createPortfolio(input: $input) {
changedPortfolio {
id
...
coverImage {
id
...
}
}
}
} and mutation updatePortfolio($input: UpdatePortfolioInput!) {
updatePortfolio(input: $input) {
changedPortfolio {
id
...
}
}
} |
@calebmer, for |
@RAFREX It depends on how you are using If you want to show a loading indicator then I recommend setting some I really wanted to see when I asked for your mutation code is what you had for |
@calebmer I'm passing in the query document and variables to retchQueries: [{
query: portfolioQuery,
variables: portfolioQueryVariables(input.urlTitle),
}] |
Yep, then we wouldn’t expect Is this something that you really need from Apollo Client? It might be easy enough to implement yourself for the UI that needs it. |
@RAFREX if your other component is active at that moment (which it seems to be since you expect it to update), you could just refer to the query by the name you gave it for now. That's the quick solution, but I think for longer term it's better to follow @calebmer's advice and implement it yourself in the UI. |
Thanks @calebmer and @helfer Where it is needed, is when the mutation causes a different route to match, which loads a different set of components that has the query that is being refetched from the mutation. So it's not possible to track the loading state locally or pass it down through props, I could track loading globally, but it would be great if Apollo would take care of that. Basically, this is what I'm dealing with:
|
Intended outcome:
networkStatus
should change to4
when a query is refetched after a mutation.Actual outcome:
networkStatus
remains at7
and the query returns cached data (the query then returns the updated data from the refetch also with anetworkStatus
of7
),How to reproduce the issue:
Mount
CompAWithData
which causesqueryA
to load and prime the cache. UnmountCompAWithData
. Run some mutation that does 3 things: 1) changes the data thatqueryA
will return, 2) on success it will causeCompAWithData
to mount, and 3) also hasrefetchQueriers
option to refetchqueryA
.When
CompAWithData
mounts as a result of the mutation the initial data it gets fromqueryA
is the cached version but thenetworkStatus
is still7
, it then receives the updated data from the refetch also with anetworkStatus
of7
.Note
I think this also happens without the mount and unmount, i.e. a single component with a mutation and a query where the mutation refetches the query. I added
notifyOnNetworkStatusChange: true
to the query options, which I think should cause the query to pass in the newnetworkStatus
to the component as soon as the refetch is called after the mutation, but nothing is passed into the component until the refetch returns the new data. I'm not sure if that is the intended behavior ofnotifyOnNetworkStatusChange: true
, so I typed it up the mount and unmount way. Is that the intended behavior ofnotifyOnNetworkStatusChange: true
? (docs are a bit light on the topic)Using
apollo-client
0.8.1 andreact-apollo
0.9.0The text was updated successfully, but these errors were encountered: