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.

Cannot set property 'networkStatus' of undefined error occurs when fetchMore gets called

See original GitHub issue

Intended outcome:

I’m trying to use fetchMore function that is described at your documentation. link : https://www.apollographql.com/docs/angular/recipes/pagination.html#fetch-more

below is the actual code :

this.fetchQuery = this.apollo.watchQuery<any>({
      query: gql`
          query FetchTrainingData ($projectId: String!, $label: String, $page: Int, $size:Int, $order: OrderType){
              trainingData(projectId: $projectId, label: $label, page: $page, size:$size, order: $order) {
                  sentence
                  labels
                  id
                  updateCount
              }
          }
      `,
      variables: {
        projectId: "",
        page: null,
        label: null,
        order: null,
        size: null
      }
    });

this.fetchQuery.fetchMore({
      variables: {
        projectId: this.projectId,
        label: null,
        page: page,
        size: size,
        order: null
      },
      updateQuery: (prev, { fetchMoreResult }) => {
        if (!fetchMoreResult) { return prev; }
        return Object.assign({}, prev, {
          feed: [...prev.feed, ...fetchMoreResult.feed],
        });
      },
    }).then(res => {
      console.log(res);
    })

but when fetchMore gets invoked, “Cannot set property ‘networkStatus’ of undefined” error occurs.

ps. After the 2.0.0 releases your documentations are very unstable .Inside the example code about usage of fetchMore(above link) there is no such “this.feedObs” property. Maybe you guys meant “this.feedQuery”. And also the “forceFetch” property inside watchquery options does not exist in type WatchQueryOptions & TypedVariables<V>.

Actual outcome:

2017-11-10 11 31 03 2017-11-10 11 31 27

How to reproduce the issue:

Version

"apollo-angular": "1.0.0-beta.2",
    "apollo-angular-link-http": "1.0.0-beta.5",
    "apollo-cache-inmemory": "1.1.0",
    "apollo-client": "^2.0.2",
    "apollo-link-context": "1.0.0"

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
alewiahmedcommented, Dec 12, 2017

@sondremare is right, it’s the same issue. When you first send a request & that request fails, a normal network error is thrown, but then when you send the fetchMore request the Cannot set property ‘networkStatus’ of undefined error occurs.

2reactions
alewiahmedcommented, Jan 27, 2018

hey guys, @seanyu4296 @DeviousM @pycraft114, this worked for me. you’ll need both steps.

  1. I upgraded react apollo to 2.1.0.beta.0 (the current react apollo pre release): this is because we need https://github.com/apollographql/react-apollo/pull/1531
  2. There is this pull request https://github.com/apollographql/apollo-client/pull/2906, if it got merged good, but if not it’s just a one liner, just edit the bundle.umd.js file of apollo-client to exactly like the pull request. I hope that helps.
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'fetchMore' of undefined in ...
I believe the issue is that you are using fetchMore within useEffect hook. Try to rethink your code to avoid this. Using fetchMore...
Read more >
Fetching data with queries | Full-Stack Quickstart
We need Apollo Client to instead merge the launches from our fetchMore query with the launches from our original query. Let's configure that...
Read more >
Query and store data - New Relic Developers
Set to undefined when data is loading or the fetch was successful. fetchMore : Callback function that can be called when the query...
Read more >
React TypeError: Cannot read property function of undefined
SET YOUR LIKE THERE ... Your browser can't play this video. ... Solved: React TypeError: Cannot read property function of undefined.
Read more >
Smart Query | Vue Apollo
to customize the value that is set in the vue property, ... options) is a hook called when there are errors. error is...
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