the-guild-org / the-guild-org/apollo-angular

When `notifyOnNetworkStatusChange` is set to true and call refetch, then the network states sticks and always shows NetworkStatus.loading

Open
#1,890 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.5k
Forks
309
Avg merge
1h 45m
Merged PRs (30d)
3

Description

Describe the bug

When notifyOnNetworkStatusChange is set to true and call refetch, then the network states sticks and always shows loading spinner

To Reproduce
Steps to reproduce the behavior:

  1. Create queryRef:
this.queryRef = this.readQuery.watch(variables, {
      fetchPolicy: 'cache-and-network',
      // BUG if uncomment next line, then there will be an infinite load when calling refetch
      // notifyOnNetworkStatusChange: true,
      ...readQuery?.options
    })
  1. Call refetch
this.queryRef.refetch(variables);
  1. Observe loading status
this.querying$ = this.queryRef?.valueChanges.pipe(
      map((x) => x.loading),
      distinctUntilChanged(),
      shareReplay(1)
);

Expected behavior

Then refetch complete network request loading indicator should be false

Environment:

- @angular/cli@14.2.6
- @angular/core@14.2.7
- @apollo/client@3.7.0
- apollo-angular@4.1.0
- graphql@16.6.0
- typescript@4.8.4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the shown watch configuration, fetchPolicy, notifyOnNetworkStatusChange, refetch, and valueChanges pipeline. Trace the network status emitted after refetch completes; done means the loading value becomes false instead of remaining true indefinitely.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, graphql, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.