|
1 | 1 | # @apollo/client
|
2 | 2 |
|
| 3 | +## 4.0.0-rc.7 |
| 4 | + |
| 5 | +### Major Changes |
| 6 | + |
| 7 | +- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `operation.getContext` now returns a `Readonly<OperationContext>` type. |
| 8 | + |
| 9 | +- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `ApolloLink.Request` (i.e. `GraphQLRequest`) passed to `ApolloLink.execute` no longer accepts `operationName` and `operationType` options. These properties are derived from the `query` and set on the returned `ApolloLink.Operation` type. |
| 10 | + |
| 11 | +- [#12808](https://github.com/apollographql/apollo-client/pull/12808) [`8e31a23`](https://github.com/apollographql/apollo-client/commit/8e31a2303b18f6fc4d8ec1cf4c01bf26b90f3f0b) Thanks [@phryneas](https://github.com/phryneas)! - HTTP Multipart handling will now throw an error if the connection closed before the final boundary has been received. |
| 12 | + Data after the final boundary will be ignored. |
| 13 | + |
| 14 | +- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `operation.operationType` is now a non-null `OperationTypeNode`. It is now safe to compare this value without having to check for `undefined`. |
| 15 | + |
| 16 | +- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `operation.operationName` is now set as `string | undefined` where `undefined` represents an anonymous query. Previously `operationName` would return an empty string as the `operationName` for anonymous queries. |
| 17 | + |
| 18 | +- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `concat`, `from`, and `split` functions on `ApollLink` no longer support a plain request handler function. Please wrap the request handler with `new ApolloLink`. |
| 19 | + |
| 20 | + ```diff |
| 21 | + const link = new ApolloLink(/* ... */); |
| 22 | + |
| 23 | + link.concat( |
| 24 | + - (operation, forward) => forward(operation), |
| 25 | + + new ApolloLink((operation, forward) => forward(operation)), |
| 26 | + ); |
| 27 | + ``` |
| 28 | + |
| 29 | +- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `transformOperation` and `validateOperation` have been removed and are no longer exported from `@apollo/client/link/utils`. These utilities have been merged into the implementation of `createOperation`. As a result, `createOperation` now returns a well-formed `Operation` object. Previously `createOperation` relied on an external call to `transformOperation` to provide a well-formed `Operation` type. If you use `createOperation` directly, remove the calls to `transformOperation` and `validateOperation` and pass the request directly. |
| 30 | + |
| 31 | +- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The request handler provided to `ApolloLink` must now return an `Observable`. `null` is no longer supported as a valid return value. If you rely on `null` so that `ApolloLink` provides an empty observable, use the `EMPTY` observable from RxJS instead: |
| 32 | + |
| 33 | + ```diff |
| 34 | + import { ApolloLink } from "@apollo/client"; |
| 35 | + + import { EMPTY } from "rxjs"; |
| 36 | + |
| 37 | + const link = new ApolloLink((operation, forward) => { |
| 38 | + - return null; |
| 39 | + + return EMPTY; |
| 40 | + }); |
| 41 | + ``` |
| 42 | + |
| 43 | + If you have a custom link that overrides the `request` method, remove `null` from the return signature: |
| 44 | + |
| 45 | + ```diff |
| 46 | + class MyCustomLink extends ApolloLink { |
| 47 | + request( |
| 48 | + operation: ApolloLink.Operation, |
| 49 | + forward: ApolloLink.ForwardFunction, |
| 50 | + - ): Observable<ApolloLink.Result> | null { |
| 51 | + + ): Observable<ApolloLink.Result> { |
| 52 | + // implementation |
| 53 | + } |
| 54 | + } |
| 55 | + ``` |
| 56 | + |
| 57 | +- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `createOperation` no longer accepts `context` as the first argument. Instead make sure `context` is set as the `context` property on the request passed to `createOperation`. |
| 58 | + |
| 59 | + ```diff |
| 60 | + createOperation( |
| 61 | + - startingContext, |
| 62 | + - { query }, |
| 63 | + + { query, context: startingContext }, |
| 64 | + { client } |
| 65 | + ); |
| 66 | + ``` |
| 67 | + |
| 68 | +- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `TVariables` generic argument on the `GraphQLRequest` type. |
| 69 | + |
| 70 | +- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The context object returned from `operation.getContext()` is now frozen to prevent mutable changes to the object which could result in subtle bugs. This applies to the `previousContext` object passed to the `operation.setContext()` callback as well. |
| 71 | + |
| 72 | +- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `forward` function passed to the request handler is now always provided to `request` and no longer optional. If you create custom links by subclassing `ApolloLink`, the `forward` function no longer needs to be optional: |
| 73 | + |
| 74 | + ```ts |
| 75 | + class CustomLink extends ApolloLink { |
| 76 | + request( |
| 77 | + operation: ApolloLink.Operation, |
| 78 | + // This no longer needs to be typed as optional |
| 79 | + forward: ApolloLink.ForwardFunction |
| 80 | + ) { |
| 81 | + // ... |
| 82 | + } |
| 83 | + } |
| 84 | + ``` |
| 85 | + |
| 86 | + As a result of this change, `ApolloLink` no longer detects terminating links by checking function arity on the request handler. This means using methods such as `concat` on a terminating link no longer emit a warning. On the flip side, if the terminating link calls the `forward` function, a warning is emitted and an observable that immediately completes is returned which will result in an error from Apollo Client. |
| 87 | + |
| 88 | +### Minor Changes |
| 89 | + |
| 90 | +- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `ApolloLink`'s `concat` method now accepts multiple links to concatenate together. |
| 91 | + |
| 92 | + ```ts |
| 93 | + const first = new ApolloLink(); |
| 94 | + |
| 95 | + const link = first.concat(second, third, fouth); |
| 96 | + ``` |
| 97 | + |
| 98 | +- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Many of the types exported from `@apollo/client/link` now live on the `ApolloLink` namespace. The old types are now deprecated in favor of the namespaced types. |
| 99 | + |
| 100 | + - `FetchResult` -> `ApolloLink.Result` |
| 101 | + - `GraphQLRequest` -> `ApolloLink.Request` |
| 102 | + - `NextLink` -> `ApolloLink.ForwardFunction` |
| 103 | + - `Operation` -> `ApolloLink.Operation` |
| 104 | + - `RequestHandler` -> `ApolloLink.RequestHandler` |
| 105 | + |
| 106 | +- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The static `ApolloLink.concat` method is now deprecated in favor of `ApolloLink.from`. `ApolloLink.concat` is now an alias for `ApolloLink.from` so prefer `ApolloLink.from` instead. |
| 107 | + |
| 108 | +### Patch Changes |
| 109 | + |
| 110 | +- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The individual `empty`, `concat`, `from` and `split` functions exported from `@apollo/client/link` are now deprecated in favor of using the static functions instead. |
| 111 | + |
| 112 | + ```diff |
| 113 | + import { |
| 114 | + ApolloLink, |
| 115 | + - concat, |
| 116 | + - empty, |
| 117 | + - from, |
| 118 | + - split, |
| 119 | + } from "@apollo/client/link"; |
| 120 | + |
| 121 | + - concat(first, second); |
| 122 | + + ApolloLink.concat(first, second); |
| 123 | + |
| 124 | + - empty(); |
| 125 | + + ApolloLink.empty(); |
| 126 | + |
| 127 | + - from([first, second]); |
| 128 | + + ApolloLink.from([first, second]); |
| 129 | + |
| 130 | + - split( |
| 131 | + + ApolloLink.split( |
| 132 | + (operation) => /* */, |
| 133 | + first, |
| 134 | + second |
| 135 | + ); |
| 136 | + ``` |
| 137 | + |
3 | 138 | ## 4.0.0-rc.6
|
4 | 139 |
|
5 | 140 | ### Major Changes
|
|
0 commit comments