Skip to content

New onlyComplete() helper to filter only complete results#2379

Merged
PowerKiKi merged 1 commit intomasterfrom
powerkiki2
Oct 13, 2025
Merged

New onlyComplete() helper to filter only complete results#2379
PowerKiKi merged 1 commit intomasterfrom
powerkiki2

Conversation

@PowerKiKi
Copy link
Copy Markdown
Collaborator

If you use this, you should probably combine it with notifyOnNetworkStatusChange. This tells @apollo/client to not emit the first partial result, so apollo-angular does not need to filter it out. The overall behavior is identical, but it saves some CPU cycles.

So something like this:

apollo
  .watchQuery({
    query: myQuery,
    notifyOnNetworkStatusChange: false, // Adding this will save CPU cycles
  })
  .valueChanges
  .pipe(onlyComplete())
  .subscribe(result => {
    // Do something with complete result
  });

If you use this, you should probably combine it with [`notifyOnNetworkStatusChange`](https://www.apollographql.com/docs/react/data/queries#queryhookoptions-interface-notifyonnetworkstatuschange).
This tells `@apollo/client` to not emit the first `partial` result, so
`apollo-angular` does not need to filter it out. The overall behavior is
identical, but it saves some CPU cycles.

So something like this:

```ts
apollo
  .watchQuery({
    query: myQuery,
    notifyOnNetworkStatusChange: false, // Adding this will save CPU cycles
  })
  .valueChanges
  .pipe(onlyComplete())
  .subscribe(result => {
    // Do something with complete result
  });
```
@github-actions
Copy link
Copy Markdown
Contributor

💻 Website Preview

The latest changes are available as preview in: https://pr-2379.apollo-angular.pages.dev

@PowerKiKi PowerKiKi merged commit 69794b4 into master Oct 13, 2025
24 checks passed
@PowerKiKi PowerKiKi deleted the powerkiki2 branch October 13, 2025 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant