Skip to content

Commit a79d3f2

Browse files
committed
Address accuracy issues
1 parent abb5612 commit a79d3f2

1 file changed

Lines changed: 36 additions & 9 deletions

File tree

release-notes.md

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ Apollo Client v4 completely reimagines error handling with a new, more granular
1111
**Key Changes:**
1212
- **Specialized Error Classes**: Errors are now categorized into distinct types:
1313
- `CombinedGraphQLErrors` for GraphQL errors (replacing `graphqlErrors`)
14-
- Network errors are passed through directly without wrapping
14+
- Network errors are passed through directly as-is (no wrapper class)
1515
- `CombinedProtocolErrors` for transport-level errors
1616
- **Type-Safe Error Handling**: Use `instanceof` checks to handle specific error types
17-
- **Improved Error Wrapping**: String errors are automatically wrapped in `Error` instances, and non-error objects are wrapped in `UnknownError` with a `cause` property
17+
- **Improved Error Wrapping**: String errors are automatically wrapped in `Error` instances, and non-error objects are wrapped in `UnconventionalError` with a `cause` property
1818
- **GraphQL over HTTP Spec Compliance**: Full support for `application/graphql-response+json` media type with stricter adherence to the GraphQL over HTTP specification
1919

2020
**Migration Example:**
@@ -28,7 +28,10 @@ if (error instanceof ApolloError) {
2828
// Apollo Client v4
2929
if (error instanceof CombinedGraphQLErrors) {
3030
console.log(error.graphQLErrors);
31-
} else if (error instanceof NetworkError) {
31+
} else if (error instanceof CombinedProtocolErrors) {
32+
console.log(error.protocolErrors);
33+
} else {
34+
// Network errors and other errors are passed through as-is
3235
console.log(error.message);
3336
}
3437
```
@@ -94,7 +97,7 @@ Apollo Client v4 introduces a pluggable incremental delivery system for the `@de
9497
- Available handlers:
9598
- `NotImplementedHandler` (default)
9699
- `Defer20220824Handler` (Apollo Router format)
97-
- `GraphQL17Alpha2Handler` (GraphQL 17.0.0-alpha.2 format)
100+
- `GraphQL17Alpha2Handler` (alias for Defer20220824Handler, for GraphQL 17.0.0-alpha.2 compatibility)
98101

99102
**HTTP Multipart Improvements:**
100103
- Stricter error handling for connection issues
@@ -106,11 +109,33 @@ Apollo Client v4 introduces a pluggable incremental delivery system for the `@de
106109
Local state management in Apollo Client v4 has been completely revamped for better reliability and type safety.
107110

108111
**Resolver System Overhaul:**
112+
- Resolvers have been moved from `ApolloClient` to a new `LocalState` class
113+
- The `resolvers` option on `ApolloClient` has been replaced with a `localState` option
109114
- Errors thrown in resolvers now set the field to `null` and add to the `errors` array
110115
- Remote results are dealiased before being passed to resolvers
111116
- New `context` function for customizing `requestContext`
112117
- `Resolvers` generic provides autocompletion and type checking
113118

119+
**Breaking Change - Resolver Migration:**
120+
Resolvers must now be configured through the `LocalState` class:
121+
```typescript
122+
// Apollo Client v3
123+
const client = new ApolloClient({
124+
cache,
125+
resolvers: { /* ... */ }
126+
});
127+
128+
// Apollo Client v4
129+
import { LocalState } from '@apollo/client/local-state';
130+
131+
const client = new ApolloClient({
132+
cache,
133+
localState: new LocalState({
134+
resolvers: { /* ... */ }
135+
})
136+
});
137+
```
138+
114139
**Breaking Change - Resolver Context:**
115140
The resolver `context` argument (3rd argument) has been restructured:
116141
```typescript
@@ -139,6 +164,7 @@ const resolver = (parent, args, context, info) => {
139164
All React-related exports have moved to dedicated entrypoints:
140165
- Main exports: `@apollo/client/react`
141166
- Testing utilities: `@apollo/client/testing/react`
167+
- Note: `gql` should be imported from `@apollo/client`, not from `@apollo/client/react`
142168

143169
This change allows core client usage without requiring React as a dependency.
144170

@@ -209,13 +235,14 @@ const link = new HttpLink({ uri: '/graphql' });
209235

210236
Apollo Client v4 includes breaking changes that require migration. The most significant include:
211237

212-
1. **Error System**: Replace `ApolloError` checks with specific error class checks
213-
2. **React Exports**: Update imports from `@apollo/client` to `@apollo/client/react`
238+
1. **Error System**: Replace `ApolloError` checks with specific error class checks (`CombinedGraphQLErrors`, `CombinedProtocolErrors`, etc.)
239+
2. **React Exports**: Update imports from `@apollo/client` to `@apollo/client/react` (except `gql` which stays in `@apollo/client`)
214240
3. **Link Classes**: Replace creator functions with class constructors
215241
4. **ApolloClient Constructor**: `link` option is now required
216-
5. **Resolver Context**: Update resolver signatures to use new context structure
217-
6. **RxJS Migration**: Update observable transformations to use `.pipe()`
218-
7. **Type System**: Update type signatures for `dataState` changes
242+
5. **Local State**: Move `resolvers` from `ApolloClient` to new `LocalState` class
243+
6. **Resolver Context**: Update resolver signatures to use new context structure
244+
7. **RxJS Migration**: Update observable transformations to use `.pipe()`
245+
8. **Type System**: Update type signatures for `dataState` changes
219246

220247
## Migration Resources
221248

0 commit comments

Comments
 (0)