Conversation
There was a problem hiding this comment.
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/clientto^4.2.7andapollo-angularto^14.1.0, updating affected services/tests for new APIs and typings. - Add a new Natural
createErrorLink()/createErrorHandler()implementation plus a sharedErrorService. - Introduce an
ignoreErrors()RxJS operator and adoptonlyCompleteData()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"}`
079c8bb to
cd32c06
Compare
There was a problem hiding this comment.
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
apolloDefaultOptionsfrom the workspace app (src/app/...). That couples the library’s unit tests to the demo app layout and makesprojects/naturalharder 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';
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.
There was a problem hiding this comment.
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
apolloDefaultOptionsfrom 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 movingapolloDefaultOptions(and the associated type augmentation) intoprojects/natural/src/lib/...and importing it from there.
import {apolloDefaultOptions} from '../../../../../src/app/shared/config/apollo-options.provider';
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-completeErrorServicenow also lives in Natural, instead of in each projects with very minor differences.