You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/migrating/apollo-client-4-migration.mdx
+24-14Lines changed: 24 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,24 +14,28 @@ Apollo Client 3.14 introduces many deprecations and warnings that will help you
14
14
## What’s new in 4.0
15
15
16
16
- Bundling changes
17
-
- Apollo Client 4.0 now has an `exports` field in its `package.json` for better ESM support
18
-
-`@apollo/client/core` and `@apollo/client` are now identical and framework-agnostic. React-related exports are now only available in `@apollo/client/react`.
17
+
- Apollo Client 4.0 now includes an `exports` field in its `package.json` for better ESM support
18
+
-`@apollo/client` is now framework-agnostic. React-related exports have been removed and are now only available in `@apollo/client/react`
19
+
- As a result `@apollo/client/core` and `@apollo/client` are now identical
19
20
- Enhanced Error Handling
20
-
- network errors are now handled the same way as GraphQL errors and populate the `error` field of a query result
21
-
- the throwing behaviour between network errors and GraphQL errors has been unified
22
-
-`ApolloError` has been removed. A number of new error classes have been introduced, and external errors are now passed through as-is without wrapping them, which enables easier debugging.
21
+
- Network errors and GraphQL errors have been unified into a single `error` property of a query result
22
+
- Network errors now adhere to the `errorPolicy` in the same way as GraphQL errors
23
+
-`ApolloError` has been removed in favor of more granular error classes
24
+
- Network errors are now passed through as-is without wrapping them in a separate error class, making them easier to debug
23
25
- TypeScript improvements
24
-
- APIs like`client.query` or `useQuery` that accept variables in options will now require the variables to be passed in if any option is non-optional.
26
+
-The `variables` option used throughout various client APIs (e.g.`client.query` or `useQuery`) now requires that the `variables` option is provided if any variable is non-optional.
25
27
- return types are more precise, taking options into account - if you pass in the `returnPartialData` option, `data` on the return object will be `DeepPartial<TData>`
26
-
-added a new `dataState` property that contains information about the state of the `data` property of a return value. This property can be used to narrow down the type of `data`.
27
-
-most types are now colocated within the API that they relate to, so it is much easier to find the right type for the right situation.
28
-
-some core types like types for `DataMasking` or types representing the that `dataState` narrows down to can now be overwritten.
28
+
-A new `dataState` property has been added that contains information about the state of the `data` property which can be used to accurately narrow down the type of `data`.
29
+
-Types are now generally colocated in a namespace with the API that owns them, making them more discoverable with clear ownership boundaries
30
+
-Selective core types, such as those used for data masking, can now be overridden to provide your own type implementations
29
31
- Local State changes
30
-
-The local resolver implementation is now a pluggable `LocalState` class to save on bundle size for everyone who doesn't use it.
32
+
-Local state management (e.g. the `@client` directive) is now an opt-in feature to reduce the bundle size of client when local state is not used
31
33
- Many improvements and bug fixes in the new `LocalState` implementation
32
-
- The `Observable` implementation has been changed to `rxjs`.
33
-
- The incremental delivery implementation has been made pluggable, so in the future we can support multiple different versions of the incremental delivery protocol.
34
-
- For a full list of changes, see the [changelog](https://github.com/apollographql/apollo-client/blob/main/CHANGELOG.md).
34
+
- The `Observable` implementation now uses `rxjs` instead of `zen-observable`.
35
+
- The incremental delivery implementation is now pluggable. This makes it possible to support multiple versions of the incremental delivery protocol thoughout.
@@ -43,10 +47,16 @@ Apollo Client 4.0 is a major-version release that includes breaking changes. If
43
47
44
48
Install Apollo Client 4 along with its peer dependencies with the following command:
45
49
46
-
```
50
+
```sh
47
51
npm install @apollo/client graphql rxjs
48
52
```
49
53
54
+
<Note>
55
+
56
+
`rxjs` is a new peer dependency with Apollo Client 4.0.
57
+
58
+
</Note>
59
+
50
60
## Codemod
51
61
52
62
To ease the migration process, we have created a codemod that will automatically update your codebase to use the new imports and APIs in Apollo Client 4.
0 commit comments