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.

fetchMore networkStatus and notifyOnNetworkChange not working in 3.3.7

See original GitHub issue

In the latest version (3.3.7) the networkStatus for fetchingMore is not working:

export declare enum NetworkStatus {
    loading = 1,
    setVariables = 2,
    fetchMore = 3,
    refetch = 4,
    poll = 6,
    ready = 7,
    error = 8
}

But when calling fetchMore, the networkStatus is never changed to 3 when notifyOnNetworkChange = true…

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:9
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ramiAbdoucommented, Apr 27, 2021

I’m seeing the same issue. I’m using local-only fields in my query and when my local-only fields change, it refetches from the network, but does not update the loading and networkStatus variables.

1reaction
sflahavecommented, Feb 14, 2021

I’m seeing the same … I’m expecting that if a call to fetchMore triggers a network call, then either loading or networkStatus should be updated so I can let the user know that data is loading.

I have a query setup like this:

const { loading, error, data, fetchMore, networkStatus } = useQuery(ALL_JOBS, {
    variables: {
      filter,
      first: rowsPerPage,
      sortBy,
      sortDir,
    },
    notifyOnNetworkStatusChange: true,
    context: {
      debounceKey: "ALL_JOBS",
      debounceTimeout: 50,
    },
  })

Then I have a sort function that gets called when a user wants to change the sorting:

function sort(propertyName) {
    const newSortBy = propertyName
    const newSortDir = propertyName !== sortBy ? "ASC" : sortDir === "ASC" ? "DESC" : "ASC"
    setSortBy(newSortBy)
    setSortDir(newSortDir)
    setPage(0)
    fetchMore({
      variables: {
        filter,
        first: rowsPerPage,
        sortBy: newSortBy,
        sortDir: newSortDir,
      },
    })
  }

I can see that this triggers a network call, but the loading always remains false and networkStatus always stays at 7.

This query is configured to use the relayStylePagination from @apollo/client/utilities, btw

Read more comments on GitHub >

github_iconTop Results From Across the Web

react apollo - Why would data.loading not become true during ...
I was having the same problem. Turns out you have to opt in by setting notifyOnNetworkStatusChange to true in your options:.
Read more >
FetchMore not updating data with queryroot : r/graphql - Reddit
FetchMore not updating data with queryroot. Hi! I'm trying to get some products in a specific collection and show them on the screen....
Read more >
Issues · apollographql/apollo-client · GitHub - amd-drivers.org
[Unhandled promise rejection: Error: undefined is not an object (evaluating ... fetchMore networkStatus and notifyOnNetworkChange not working in 3.3.7 ...
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