Cache-first always returns NetworkStatus 7
See original GitHub issueIntended outcome: Show a spinner(loading: true) until data is loaded when I load the page for the first time and subsequent times load from cache.
Actual outcome:
According to the console log statements (called twice).
Also if i set the fetchPolicy
to network-only
or cache-and-network
it works as intended
data: {...}
loading: false
networkStatus: 7
code snippet
<Query query={CURRENT_USER_QUERY}>
{({ data, loading }) => {
return (
<div>
{!loading &&
<Query
query={CALENDAR_QUERY}
variables={{ id: data.user.business.id }}
fetchPolicy='cache-first'
>
{data => {
console.log(data)
// return (
// <div>
// {!loading &&
// !error &&
// <NoSSR>
// <Calendar {...props} business={data.business} />
// </NoSSR>}
// {loading &&
// !error &&
// <SpinnerStyles>
// <Spin size='large' tip='Loading events' />
// </SpinnerStyles>}
// </div>
// )
return null
}}
</Query>}
{loading && !error && <Spin size='large' tip='Loading events' />}
</div>
)
}}
</Query>
Versions
System:
OS: macOS High Sierra 10.13.6
Binaries:
Node: 10.12.0 - /usr/local/bin/node
Yarn: 1.10.1 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Browsers:
Chrome: 70.0.3538.102
Safari: 11.1.2
Issue Analytics
- State:
- Created 5 years ago
- Reactions:16
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Queries - Apollo GraphQL Docs
If all data is available locally, useQuery returns that data and doesn't query your GraphQL server. This cache-first policy is Apollo Client's default...
Read more >API: graphql container with queries | Apollo React Docs
cache-first : This is the default value where we always try reading data from your cache first. If all the data needed to...
Read more >apollo-client/bundle.esm.js.map - UNPKG
n */\nexport function isNetworkRequestInFlight(\n networkStatus: NetworkStatus,\n): boolean {\n return networkStatus < 7;\n}\n","// This simplified polyfill ...
Read more >Solved: Empty customer graphql query networkStatus 7
Solved: Hi, I'm making a query using useQuery from @shopify/react-graphql. No errors are returned other than networkStatus 7 and a blank ...
Read more >Queries - Vue Apollo
This query would return a data object with an array of users with their id ... const options = ref({ fetchPolicy: 'cache-first', })...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Also seeing this on
@apollo/client
version3.0.2
I am also seeing this after upgrading to apollo-client 2.6.4 (from 2.3.8 where I didn’t have this problem)