|
1 | 1 | # @apollo/client |
2 | 2 |
|
| 3 | +## 4.0.0-alpha.10 |
| 4 | + |
| 5 | +### Major Changes |
| 6 | + |
| 7 | +- [#12559](https://github.com/apollographql/apollo-client/pull/12559) [`49ace0e`](https://github.com/apollographql/apollo-client/commit/49ace0e2119b7fd5997dcf051002ebd4ba2e0bc4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `ObservableQuery.variables` can now be reset back to empty when calling `reobserve` with `variables: undefined`. Previously the `variables` key would be ignored so `variables` would remain unchanged. |
| 8 | + |
| 9 | +- [#12559](https://github.com/apollographql/apollo-client/pull/12559) [`49ace0e`](https://github.com/apollographql/apollo-client/commit/49ace0e2119b7fd5997dcf051002ebd4ba2e0bc4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `never` is no longer supported as a valid `TVariables` generic argument for APIs that require `variables` as part of its type. Use `Record<string, never>` instead. |
| 10 | + |
| 11 | +- [#12559](https://github.com/apollographql/apollo-client/pull/12559) [`49ace0e`](https://github.com/apollographql/apollo-client/commit/49ace0e2119b7fd5997dcf051002ebd4ba2e0bc4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - When passing a `variables` key with the value `undefined`, the value will be replaced by the default value in the query, if it is provided, rather than leave it as `undefined`. |
| 12 | + |
| 13 | + ```ts |
| 14 | + // given this query |
| 15 | + const query = gql` |
| 16 | + query PaginatedQuery($limit: Int! = 10, $offset: Int) { |
| 17 | + list(limit: $limit, offset: $offset) { |
| 18 | + id |
| 19 | + } |
| 20 | + } |
| 21 | + `; |
| 22 | + |
| 23 | + const observable = client.query({ |
| 24 | + query, |
| 25 | + variables: { limit: 5, offset: 0 }, |
| 26 | + }); |
| 27 | + console.log(observable.variables); // => { limit: 5, offset: 0 } |
| 28 | + |
| 29 | + observable.reobserve({ variables: { limit: undefined, offset: 10 } }); |
| 30 | + // limit is now `10`. This would previously be `undefined` |
| 31 | + console.log(observable.variables); // => { limit: 10, offset: 10 } |
| 32 | + ``` |
| 33 | + |
| 34 | +- [#12562](https://github.com/apollographql/apollo-client/pull/12562) [`90bf0e6`](https://github.com/apollographql/apollo-client/commit/90bf0e61516a382182f212ac8ab891099e2eb009) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `client.query` no longer supports a `fetchPolicy` of `standby`. `standby` does not fetch and did not return `data`. `standby` is meant for watched queries where fetching should be on hold. |
| 35 | + |
| 36 | +### Minor Changes |
| 37 | + |
| 38 | +- [#12557](https://github.com/apollographql/apollo-client/pull/12557) [`51d26ae`](https://github.com/apollographql/apollo-client/commit/51d26ae631c6631a189c98ea9357b18e77a9a876) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add ability to specify message formatter for `CombinedGraphQLErrors` and `CombinedProtocolErrors`. To provide your own message formatter, override the static `formatMessage` property on these classes. |
| 39 | + |
| 40 | + ```ts |
| 41 | + CombinedGraphQLErrors.formatMessage = ( |
| 42 | + errors, |
| 43 | + { result, defaultFormatMessage } |
| 44 | + ) => { |
| 45 | + return "Some formatted message"; |
| 46 | + }; |
| 47 | + |
| 48 | + CombinedProtocolErrors.formatMessage = (errors, { defaultFormatMessage }) => { |
| 49 | + return "Some formatted message"; |
| 50 | + }; |
| 51 | + ``` |
| 52 | + |
| 53 | +- [#12546](https://github.com/apollographql/apollo-client/pull/12546) [`5dffbbe`](https://github.com/apollographql/apollo-client/commit/5dffbbe407eb1d9adbcb0fff89f2d3a75dc1ad2b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add a static `is` method to error types defined by Apollo Client. `is` makes it simpler to determine whether an error is a specific type, which can be helpful in cases where you'd like to narrow the error type in order to use specific properties from that error. |
| 54 | + |
| 55 | + This change applies to the following error types: |
| 56 | + |
| 57 | + - `CombinedGraphQLErrors` |
| 58 | + - `CombinedProtocolErrors` |
| 59 | + - `ServerError` |
| 60 | + - `ServerParseError` |
| 61 | + - `UnconventionalError` |
| 62 | + |
| 63 | + **Example** |
| 64 | + |
| 65 | + ```ts |
| 66 | + import { CombinedGraphQLErrors } from "@apollo/client"; |
| 67 | + |
| 68 | + if (CombinedGraphQLErrors.is(error)) { |
| 69 | + console.log(error.message); |
| 70 | + error.errors.forEach((graphQLError) => console.log(graphQLError.message)); |
| 71 | + } |
| 72 | + ``` |
| 73 | + |
| 74 | +### Patch Changes |
| 75 | + |
| 76 | +- [#12559](https://github.com/apollographql/apollo-client/pull/12559) [`49ace0e`](https://github.com/apollographql/apollo-client/commit/49ace0e2119b7fd5997dcf051002ebd4ba2e0bc4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `variables` option used with various APIs are now enforced more consistently across the client when `TVariables` contains required variables. If required `variables` are not provided, TypeScript will now complain that it requires a `variables` option. |
| 77 | + |
| 78 | + This change affects the following APIs: |
| 79 | + |
| 80 | + - `client.query` |
| 81 | + - `client.mutate` |
| 82 | + - `client.subscribe` |
| 83 | + - `client.watchQuery` |
| 84 | + - `useBackgroundQuery` |
| 85 | + - `useQuery` |
| 86 | + - `useSubscription` |
| 87 | + - `useSuspenseQuery` |
| 88 | + |
| 89 | +- [#12559](https://github.com/apollographql/apollo-client/pull/12559) [`49ace0e`](https://github.com/apollographql/apollo-client/commit/49ace0e2119b7fd5997dcf051002ebd4ba2e0bc4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix type of `variables` returned from `useLazyQuery`. When `called` is `false`, `variables` is now `Partial<TVariables>` instead of `TVariables`. |
| 90 | + |
| 91 | +- [#12562](https://github.com/apollographql/apollo-client/pull/12562) [`90bf0e6`](https://github.com/apollographql/apollo-client/commit/90bf0e61516a382182f212ac8ab891099e2eb009) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `client.query` no longer supports `notifyOnNetworkStatusChange` in options. An error will be thrown if this option is set. The effects of this option were not observable by `client.query` since `client.query` emits a single result. |
| 92 | + |
| 93 | +- [#12557](https://github.com/apollographql/apollo-client/pull/12557) [`51d26ae`](https://github.com/apollographql/apollo-client/commit/51d26ae631c6631a189c98ea9357b18e77a9a876) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Update format of the error message for `CombinedGraphQLErrors` and `CombinedProtocolErrors` to be more like v3.x. |
| 94 | + |
| 95 | + ```diff |
| 96 | + console.log(error.message); |
| 97 | + - `The GraphQL server returned with errors: |
| 98 | + - - Email not found |
| 99 | + - - Username already in use` |
| 100 | + + `Email not found |
| 101 | + + Username already in use` |
| 102 | + ``` |
| 103 | + |
| 104 | +- [#12559](https://github.com/apollographql/apollo-client/pull/12559) [`49ace0e`](https://github.com/apollographql/apollo-client/commit/49ace0e2119b7fd5997dcf051002ebd4ba2e0bc4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `ObservableQuery.variables` has been updated to return `TVariables` rather than `TVariables | undefined`. This is more consistent with the runtime value where an empty object (`{}`) will be returned when the `variables` option is not provided. |
| 105 | + |
3 | 106 | ## 4.0.0-alpha.9 |
4 | 107 |
|
5 | 108 | ### Major Changes |
|
0 commit comments