-
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
Data disappears between two queries of the same type. UI updates with empty props. #3928
Comments
Any workaround for this? Does anyone know a previous version that works? I'm just getting into using apollo/graphql and it doesn't work, so I don't know what previous versions were fine. |
This is a serious problem |
Are there any workarounds? 😞 |
The solution to this is to set the React Apollo |
Setting partialRefetch to true is not solution for all cases here, this only works if query B is a complete subset of query A or vice versa First query:
Later query (triggered after a user interaction):
partialRefetch will cause an infinite loop for queryA -> queryB -> partialRefetch queryA -> partialRefetch queryB -> partialRefetch queryA -> partialRefetch queryB-> partialRefetch queryA -> partialRefetch queryB -> partialRefetch queryA -> partialRefetch queryB..... |
I've run into a similar issue with queries like these: query A {
article {
image {
src
}
}
} query B {
article {
id
title
body
}
} Notice that query B requests an |
@KamalAman I'm a bit late to the party here, but are you sure the scenario you described would actually happen? Last I know, Apollo Client will merge objects in the cache, so the only case in which your loop would happen is if the In any case, I think there is no "perfect" solution here. In some cases, even merging object fields in the cache may be undesirable. However, in most cases I think |
@helfer In my mind |
I am using
react-apollo
and the<Query>
component.Intended outcome:
Execute two queries (
A
andB
) in series over the same root field (article
) and with a shared sub-query (image
). There are fewer fields on theimage
sub-selection in queryB
than on image in queryA
. The imageid
changes upstream between the execution of the two queries, so the data responses will be slightly different for the two queries.First query:
Later query (triggered after a user interaction):
The
<Query>
component that is subscribing to queryA
should either get updated with new data afterB
is completed, or ignore the data fromB
if it's inconsistent withA
.Actual outcome:
The query component that is subscribing to
A
is re-rendered without thedata
prop.How to reproduce the issue:
https://codesandbox.io/s/0xl9v5znnw
Versions
"apollo-cache-inmemory": "1.2.10"
"apollo-client": "2.4.2"
"react-apollo": "2.1.11"
Possibly related
#3267
apollographql/react-apollo#2003
The text was updated successfully, but these errors were encountered: