Skip to content

Commit 863dcc6

Browse files
Version Packages (alpha)
1 parent 49ace0e commit 863dcc6

File tree

4 files changed

+111
-3
lines changed

4 files changed

+111
-3
lines changed

.changeset/pre.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"clean-sheep-hide",
1616
"clever-zebras-mate",
1717
"cool-bikes-shake",
18+
"cool-kiwis-hunt",
1819
"cuddly-spiders-tie",
1920
"curvy-pianos-count",
2021
"dirty-eagles-poke",
@@ -27,18 +28,24 @@
2728
"forty-hairs-occur",
2829
"forty-shrimps-fry",
2930
"forty-tomatoes-punch",
31+
"four-countries-clean",
3032
"four-ghosts-watch",
3133
"fresh-moose-hope",
3234
"funny-jeans-invent",
35+
"funny-terms-deny",
3336
"fuzzy-tips-sit",
37+
"gentle-badgers-train",
3438
"giant-apes-thank",
3539
"giant-bags-share",
3640
"good-dolphins-peel",
3741
"gorgeous-chefs-tap",
42+
"great-roses-jog",
3843
"grumpy-vans-type",
3944
"healthy-apes-sneeze",
4045
"hip-vans-act",
4146
"hot-cycles-notice",
47+
"hungry-bikes-cough",
48+
"itchy-chefs-run",
4249
"itchy-drinks-refuse",
4350
"itchy-roses-accept",
4451
"khaki-keys-deliver",
@@ -78,6 +85,7 @@
7885
"rich-eagles-cross",
7986
"rich-kids-carry",
8087
"rude-fans-study",
88+
"seven-dragons-repair",
8189
"seven-foxes-melt",
8290
"shaggy-pugs-add",
8391
"shiny-carrots-invent",
@@ -104,6 +112,7 @@
104112
"tender-swans-flash",
105113
"thick-books-grin",
106114
"thin-peas-hear",
115+
"tidy-pandas-punch",
107116
"tidy-squids-poke",
108117
"tough-rockets-allow",
109118
"tough-taxis-smoke",

CHANGELOG.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,104 @@
11
# @apollo/client
22

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+
### Minor Changes
35+
36+
- [#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.
37+
38+
```ts
39+
CombinedGraphQLErrors.formatMessage = (
40+
errors,
41+
{ result, defaultFormatMessage }
42+
) => {
43+
return "Some formatted message";
44+
};
45+
46+
CombinedProtocolErrors.formatMessage = (errors, { defaultFormatMessage }) => {
47+
return "Some formatted message";
48+
};
49+
```
50+
51+
- [#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.
52+
53+
This change applies to the following error types:
54+
55+
- `CombinedGraphQLErrors`
56+
- `CombinedProtocolErrors`
57+
- `ServerError`
58+
- `ServerParseError`
59+
- `UnconventionalError`
60+
61+
**Example**
62+
63+
```ts
64+
import { CombinedGraphQLErrors } from "@apollo/client";
65+
66+
if (CombinedGraphQLErrors.is(error)) {
67+
console.log(error.message);
68+
error.errors.forEach((graphQLError) => console.log(graphQLError.message));
69+
}
70+
```
71+
72+
### Patch Changes
73+
74+
- [#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.
75+
76+
This change affects the following APIs:
77+
78+
- `client.query`
79+
- `client.mutate`
80+
- `client.subscribe`
81+
- `client.watchQuery`
82+
- `useBackgroundQuery`
83+
- `useQuery`
84+
- `useSubscription`
85+
- `useSuspenseQuery`
86+
87+
- [#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`.
88+
89+
- [#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.
90+
91+
```diff
92+
console.log(error.message);
93+
- `The GraphQL server returned with errors:
94+
- - Email not found
95+
- - Username already in use`
96+
+ `Email not found
97+
+ Username already in use`
98+
```
99+
100+
- [#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.
101+
3102
## 4.0.0-alpha.9
4103

5104
### Major Changes

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@apollo/client",
3-
"version": "4.0.0-alpha.9",
3+
"version": "4.0.0-alpha.10",
44
"description": "A fully-featured caching GraphQL client.",
55
"private": true,
66
"keywords": [

0 commit comments

Comments
 (0)