React-apollo: Container stuck in loading state when fetchPolicy is not default

Created on 2 May 2017  路  7Comments  路  Source: apollographql/react-apollo

Steps to Reproduce

I have recreated the basic setup with a fork of the error template repo: https://github.com/rtymchyk/react-apollo-error-template

  1. Add react-router and series of routes.
  2. Add a AuthenticatedRoute component that checks if there is a result of some query. In a real API this would check the viewer for example (Relay style), or just user (non-Relay). For this type of guard to have any value, this query needs to have a policy that's either network-only or cache-and-network. There are other routes that perform a similar/identical query, but they can utilize the cache (hopefully from the result of AuthenticatedRoute's query).
  3. Press Home.

Buggy Behavior

This AuthenticatedRoute component is stuck in loading state, even though the request completes.

Expected Behavior

The AuthenticatedRoute component resolves to ready state with data from the query.

Version

Notes

  • this works when the rendering/querying is done on the server (although not demonstrated in that example)
  • I had to hook in a mock API that has a limit on the # of requests, so please be gentle with it :)

Most helpful comment

Thanks for the info @gustavlrsn. I can confirm that things are fine in 1.0.0, and the issue is introduced since in 1.0.1. This branch is the culprit https://github.com/apollographql/react-apollo/pull/531.

Have you had a chance to look into this @helfer ?

All 7 comments

Experiencing the same issue.

@rtymchyk @Peterabsolon can you guys check this with the latest version? If it still occurs, a minimal repro that we can run locally would be really really great. Thanks! 馃檪

@helfer verified that this is still failing with the latest 1.3.0. The minimal repro provided in original post is still applicable. Specifically this commit https://github.com/rtymchyk/react-apollo-error-template/commit/108e2076c8f566ba2fa18c321afe340146114e7f is enough to reproduce.

Also having this issue. Downgrading react-apollo to 1.0.0 solved it for me.

Having the same issue with react-apollo 1.3. 馃槩

Thanks for the info @gustavlrsn. I can confirm that things are fine in 1.0.0, and the issue is introduced since in 1.0.1. This branch is the culprit https://github.com/apollographql/react-apollo/pull/531.

Have you had a chance to look into this @helfer ?

Fixed with >1.4.0 - thank you.

Was this page helpful?
0 / 5 - 0 ratings