Skip to content

Apollo Client v4 #11733#290

Merged
PowerKiKi merged 1 commit into
masterfrom
apollo-v4
Jul 24, 2026
Merged

Apollo Client v4 #11733#290
PowerKiKi merged 1 commit into
masterfrom
apollo-v4

Conversation

@PowerKiKi

Copy link
Copy Markdown
Member

Going forward the main differences in usage are:

 apollo
     .query({query: myQuery})
     .pipe(
+        ignoreErrors(),
         map(result => result.data.myQuery),
     );
 apollo
     .watchQuery({
         query: myQuery,
+        notifyOnNetworkStatusChange: false,
     })
     .valueChanges
     .pipe(
+        onlyCompleteData(),
         map(result => result.data.myQuery),
     );

Alos, Natural has a new createErrorLink(), with related tests moved from Epicerio. To make it reasonnable a feature-complete ErrorService now also lives in Natural, instead of in each projects with very minor differences.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR upgrades the repo to Apollo Client v4 / apollo-angular v14 and updates the Natural library + demo app integration accordingly, including updated result typing and new convenience operators/links to handle v4’s data/error semantics.

Changes:

  • Upgrade @apollo/client to ^4.2.7 and apollo-angular to ^14.1.0, updating affected services/tests for new APIs and typings.
  • Add a new Natural createErrorLink()/createErrorHandler() implementation plus a shared ErrorService.
  • Introduce an ignoreErrors() RxJS operator and adopt onlyCompleteData() in model-service flows.

Reviewed changes

Copilot reviewed 17 out of 19 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/main.ts Switches Apollo provider wiring to an apolloOptionsFactory.
src/app/shared/services/any-link-mutation.service.ts Updates mock link-mutation result typing for Apollo v4.
src/app/shared/config/apollo.d.ts Adds module augmentation to constrain default options typing.
projects/natural/tsconfig.spec.json Expands test TS include set to pick up shared Apollo typings.
projects/natural/src/public-api.ts Exports new createErrorLink, ignoreErrors, and ErrorService.
projects/natural/src/lib/testing/mock-apollo.provider.ts Updates mock client creation for Apollo v4 and sets defaultOptions.
projects/natural/src/lib/services/link-mutation.service.ts Updates mutation result typing and refetch API call name.
projects/natural/src/lib/services/error.service.ts Adds shared error capture + redirect helper service.
projects/natural/src/lib/services/error.service.spec.ts Adds initial unit test coverage for ErrorService.
projects/natural/src/lib/services/enum.service.ts Adjusts enum handling for potentially-undefined data shape.
projects/natural/src/lib/services/abstract-model.service.ts Migrates watch/query flows to onlyCompleteData() and updates result typings/refetch API call name.
projects/natural/src/lib/services/abstract-model.service.spec.ts Updates tests for new Apollo refetch API and onlyCompleteData() behavior.
projects/natural/src/lib/classes/rxjs.ts Adds ignoreErrors() operator for filtering query results to complete data only.
projects/natural/src/lib/classes/create-error-handler.ts Adds new Apollo error link + server-error-to-snackbar transformation.
projects/natural/src/lib/classes/create-error-handler.spec.ts Adds unit tests for error handler behavior and server-error mapping.
projects/natural/src/lib/classes/apollo-utils.ts Updates Apollo link + apollo-angular HTTP option typing imports.
projects/natural/package.json Bumps apollo-angular dependency for the Natural package.
package.json Bumps root deps to Apollo Client v4 and apollo-angular v14.
pnpm-lock.yaml Locks upgraded Apollo Client / apollo-angular dependency graph.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (1)

projects/natural/src/lib/classes/create-error-handler.ts:64

  • Typo in comment: “JSON” should be capitalized consistently.
    // If we are sure it's a jSON error in our custom format of `{message: "my error message"}`

Comment thread src/main.ts
Comment thread projects/natural/src/lib/testing/mock-apollo.provider.ts
Comment thread projects/natural/src/lib/classes/create-error-handler.spec.ts
Comment thread projects/natural/src/lib/classes/create-error-handler.ts Outdated
Comment thread projects/natural/src/lib/classes/create-error-handler.spec.ts Outdated
Comment thread projects/natural/src/lib/classes/create-error-handler.ts Outdated
Comment thread projects/natural/src/lib/classes/create-error-handler.ts
Comment thread projects/natural/src/lib/classes/rxjs.ts Outdated
Comment thread projects/natural/src/lib/services/error.service.ts
Comment thread projects/natural/src/lib/services/error.service.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 21 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (1)

projects/natural/src/lib/testing/mock-apollo.provider.ts:7

  • This library test helper now imports apolloDefaultOptions from the workspace app (src/app/...). That couples the library’s unit tests to the demo app layout and makes projects/natural harder to test/build in isolation. Prefer keeping test-only defaults local to the test helper (or exporting them from the library) so the library tests don’t depend on app sources.
import {SchemaLink} from '@apollo/client/link/schema';
import {inject, Injectable, NgZone, Provider} from '@angular/core';
import {buildSchema} from 'graphql';
import {addMocksToSchema, IMocks} from '@graphql-tools/mock';
import {apolloDefaultOptions} from '../../../../../src/app/shared/config/apollo-options.provider';

Comment thread projects/natural/src/lib/classes/rxjs.ts Outdated
Going forward the main differences in usage are:

```diff
 apollo
     .query({query: myQuery})
     .pipe(
+        ignoreErrors(),
         map(result => result.data.myQuery),
     );
```

```diff
 apollo
     .watchQuery({
         query: myQuery,
+        notifyOnNetworkStatusChange: false,
     })
     .valueChanges
     .pipe(
+        onlyCompleteData(),
         map(result => result.data.myQuery),
     );
```

Alos, Natural has a new `createErrorLink()`, with related
tests moved from Epicerio. To make it reasonnable a feature-complete
`ErrorService` now also lives in Natural, instead of in each projects
with very minor differences.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 21 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (1)

projects/natural/src/lib/testing/mock-apollo.provider.ts:7

  • This imports apolloDefaultOptions from the workspace app source (src/app/...) into the Natural library test utilities. That creates a brittle cross-project coupling and will break when the library is consumed/published without the app sources. Consider moving apolloDefaultOptions (and the associated type augmentation) into projects/natural/src/lib/... and importing it from there.
import {apolloDefaultOptions} from '../../../../../src/app/shared/config/apollo-options.provider';

Comment thread projects/natural/src/lib/services/error.service.ts
Comment thread projects/natural/tsconfig.spec.json
@PowerKiKi
PowerKiKi merged commit dc0897f into master Jul 24, 2026
14 checks passed
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.

2 participants