-
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
Loading query overwrites proxy.writeQuery #1759
Comments
I created a failing example using the error template and Scaphold as a backend:
Login with As a workaround, uncomment line 19 to line 25 to load the |
@RAFREX Thanks for re-opening the issue and providing a reproduction. I will try to find out why |
Great, thanks! |
Might also be somewhat related to #1821. |
This issue has been automatically marked as stale becuase it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions to Apollo Client! |
@helfer this is still a valid issue. |
This issue has been automatically marked as stale becuase it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions to Apollo Client! |
This issue has been automatically closed because it has not had recent activity after being marked as stale. If you belive this issue is still a problem or should be reopened, please reopen it! Thank you for your contributions to Apollo Client! |
@helfer Was this issue resolved. I've come across many issues here that have been closed due to inactivity, but not resolved. It helps keep the issue count down, but many issues are getting lost into the ether it seems. |
This is a re-issue of #1223 (updated using
apollo-client
v1.4.0,react-apollo
v1.4.2 andproxy.writeQuery
)I have a
login
mutation with anupdate
option that updates my current user query:This works fine in isolation, the
currentUser
query is updated with the userid
andusername
and myUser
React component gets the new current user data exactly as is should. However, when I have a current user, myUser
component renders aUserInfo
component which has acurrentUserInfo
query:When this query runs it first has
data.loading: true
, as it should, but it also updates the result of thecurrentUser
query so theuser
isnull
(note that loading for thecurrentUser
query isfalse
, so it's saying it's finished loading and has anull
user
), which gets passed into myUser
component and causes problems.Note that this is all happening synchronously:
login
mutation result updatescurrentUser
query with logged in user >User
component gets new current user data and renders theUserInfo
component >UserInfo
component runscurrentUserInfo
query >currentUser
query is updated withuser
asnull
>User
component gets new current user data withnull
user
>User
component un-mountsUserInfo
component.If I change it so the
UseInfo
component is rendered asynchronously (with asetTimeout
of 0), everything works as it should andcurrentUser
is not updated withuser
asnull
.Also, if the
currentUser
query is first run because theUser
component is rendered (and there is a current user, say on a page reload), then the synchronous process works fine. It's only when it starts withupdate
proxy.writeQuery(...)
from thelogin
mutation that the issue arises.The text was updated successfully, but these errors were encountered: