kamilkisiela / apollo-angular

A fully-featured, production ready caching GraphQL client for Angular and every GraphQL server 🎁
https://apollo-angular.com
MIT License
1.5k stars 309 forks source link

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

Open dkhrunov opened 1 year ago

dkhrunov commented 1 year ago

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);
  2. 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