Apollo-client: QueryObservable `currentResult` behavior seems to be buggy

Created on 9 Mar 2017  路  17Comments  路  Source: apollographql/apollo-client

QueryObservable returned from client.subscribe seems to assign the immediate query result (from APOLLO_QUERY_RESULT to lastResult and returns an empty object from currentResult immediately following.

This seems to break react-apollo here.

This bug appears to express itself only in areas of our app where we are rendering a list server-side and then clicking a link on that list to navigate to a "more details" view for the list item.

  • If I set ssr to false for the list view, the bug does not occur.
  • If the user navigates to the list and the data is fetched from the client, this bug doesn't present itself.
  • If I click the back button from the details view and select the same, or a different, list item the bug doesn't present itself a second time without a browser refresh.

It seems to be some sort of bug with state somewhere in either apollo-client or react-apollo. The bug causes the details view to remain in "loading state" forever because the query result is never passed into the view via @graphql#props callback even when loading becomes false and the query result has been digested into redux.

Screenshots

Query result during breakpoints
screen shot 2017-03-09 at 10 01 00 am

QueryObservable#lastResult contains the query result and QueryResult#currentResult() returns an empty object
screen shot 2017-03-09 at 10 14 32 am

props callback in @graphql does not contain user
screen shot 2017-03-09 at 10 18 14 am
screen shot 2017-03-09 at 10 16 41 am

needs-reproduction 馃悶 bug

All 17 comments

Will try to create a test case for this.

If you could create a reproduction using react-apollo-error-template it would go a long way in helping us debug this issue! Thank you so much for reporting 馃槉

@calebmer I plan to implement an integration test in react-apollo, which is where this should be moved once we have verified it to be the problem. I just haven't had time yet. Already paired with @helfer on it for a bit last friday. Sorry!

I've been trying to debug this as well. Any updates on a solution or ways we can help out?

ways we can help out

I think we still don't have a reliable reproduction, which would make it much easier to work on a fix.

FWIW, we discovered today that running the graphql HoC twice on a single component with two different queries caused this to happen. By merging both queries together, the bug went away. I've been planning on implementing a test case to reproduce, and will hopefully have time to do so pater this week

Some more debugging... FWIW when a refetchQueries: myQuery is called for an unmounted graphql(myQuery), this bug seems to occur when it is mounted again. Trying to repo in the error template repo...

@derek-duncan @alfonsoperez could either of you find time to try to reproduce this with an integration test in react-apollo? I was planning on doing this like a week ago but I've been so slammed at work that I haven't had time. We should try to get this ironed out before 1.0.

A reliable reproduction with https://github.com/apollographql/react-apollo-error-template would be great! Once we have that, it shouldn't be too hard to pinpoint the issue.

@helfer could I just add you as read-only to our app? I have 3 or 4 examples :D

@helfer I've been working on reproducing in react-apollo-error-template for a bit and having a difficult time pinpointing. I can continue to debug, but @thebigredgeek's repo might be the clearest way for you to see the issue right now.

@thebigredgeek is it easy to run? The main reason we have an error template is because it's relatively easy to run and thus reproduce the error without a lot of unrelated code getting in the way.

@helfer Yeah it's easy to run. You just need docker and direnv. With those, you can pull down prod data spin up then entire project with 3 or 4 commands. PM me on slack?

Or I can just come over again haha

I can try to do it this weekend, but I suspect my issue was related to what @derek-duncan said. Been pretty tough on deadlines too myself :D

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!

Was this page helpful?
0 / 5 - 0 ratings