|
1 | 1 | # Change log |
2 | 2 |
|
| 3 | +## 14.0.0 |
| 4 | + |
| 5 | +### Major Changes |
| 6 | + |
| 7 | +- [#2395](https://github.com/the-guild-org/apollo-angular/pull/2395) |
| 8 | + [`4e9f107`](https://github.com/the-guild-org/apollo-angular/commit/4e9f107aa556c10cbe6c552e876cc9e96aac0618) |
| 9 | + Thanks [@JesseZomer](https://github.com/JesseZomer)! - **BREAKING CHANGE**: HTTP errors now return |
| 10 | + Apollo Client's `ServerError` instead of Angular's `HttpErrorResponse` |
| 11 | + |
| 12 | + When Apollo Server returns non-2xx HTTP status codes (status >= 300), apollo-angular's HTTP links |
| 13 | + now return `ServerError` from `@apollo/client/errors` instead of Angular's `HttpErrorResponse`. |
| 14 | + This enables proper error detection in errorLinks using `ServerError.is(error)` and provides |
| 15 | + consistent error handling with Apollo Client's ecosystem. |
| 16 | + |
| 17 | + **Migration Guide:** |
| 18 | + |
| 19 | + Before: |
| 20 | + |
| 21 | + ```typescript |
| 22 | + import { HttpErrorResponse } from '@angular/common/http'; |
| 23 | + |
| 24 | + link.request(operation).subscribe({ |
| 25 | + error: err => { |
| 26 | + if (err instanceof HttpErrorResponse) { |
| 27 | + console.log(err.status); |
| 28 | + console.log(err.error); |
| 29 | + } |
| 30 | + }, |
| 31 | + }); |
| 32 | + ``` |
| 33 | + |
| 34 | + After: |
| 35 | + |
| 36 | + ```typescript |
| 37 | + import { ServerError } from '@apollo/client/errors'; |
| 38 | + |
| 39 | + link.request(operation).subscribe({ |
| 40 | + error: err => { |
| 41 | + if (ServerError.is(err)) { |
| 42 | + console.log(err.statusCode); |
| 43 | + console.log(err.bodyText); |
| 44 | + console.log(err.response.headers); |
| 45 | + } |
| 46 | + }, |
| 47 | + }); |
| 48 | + ``` |
| 49 | + |
| 50 | + **Properties Changed:** |
| 51 | + - `err.status` → `err.statusCode` |
| 52 | + - `err.error` → `err.bodyText` (always string, JSON stringified for objects) |
| 53 | + - `err.headers` (Angular HttpHeaders) → `err.response.headers` (native Headers) |
| 54 | + - Access response via `err.response` which includes: `status`, `statusText`, `ok`, `url`, `type`, |
| 55 | + `redirected` |
| 56 | + |
| 57 | + **Note:** This only affects HTTP-level errors (status >= 300). Network errors and other error |
| 58 | + types remain unchanged. GraphQL errors in the response body are still processed normally through |
| 59 | + Apollo Client's error handling. |
| 60 | + |
| 61 | + Fixes #2394 |
| 62 | + |
| 63 | +### Patch Changes |
| 64 | + |
| 65 | +- [#2392](https://github.com/the-guild-org/apollo-angular/pull/2392) |
| 66 | + [`8d2be64`](https://github.com/the-guild-org/apollo-angular/commit/8d2be646a73e74654f5e0ff1c3fdf71a64d1648a) |
| 67 | + Thanks [@vz-tl](https://github.com/vz-tl)! - Allow headers type in DefaultContext to be Record or |
| 68 | + HttpHeaders |
| 69 | + |
3 | 70 | ## 13.0.0 |
4 | 71 |
|
5 | 72 | ### Major Changes |
|
0 commit comments