question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cache-first always returns NetworkStatus 7

See original GitHub issue

Intended 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:closed
  • Created 5 years ago
  • Reactions:16
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
eugene-kimcommented, Jul 24, 2020

Also seeing this on @apollo/client version 3.0.2

2reactions
kedarguycommented, Sep 9, 2019

I am also seeing this after upgrading to apollo-client 2.6.4 (from 2.3.8 where I didn’t have this problem)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found