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
+66-6Lines changed: 66 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -366,6 +366,12 @@ End: Inserted by Apollo Client 3->4 migration codemod.
366
366
367
367
### Running the codemod
368
368
369
+
<Note>
370
+
371
+
The codemod requires a Node.js version that supports loading ECMAScript modules with `require`. See the table in the [Node.js documentation](https://nodejs.org/api/modules.html#loading-ecmascript-modules-using-require) for the versions that support this feature (you might need to expand the "History" section to see the table.)
372
+
373
+
</Note>
374
+
369
375
To run the codemod, use the following command:
370
376
371
377
```shshowLineNumbers=false
@@ -378,6 +384,12 @@ This command behaves similarly to [`jscodeshift`](https://github.com/facebook/js
378
384
379
385
</Note>
380
386
387
+
<Note>
388
+
389
+
This example targets the `src` directory with the codemod. Replace `src` with the file pattern applicable to your file structure if it differs.
390
+
391
+
</Note>
392
+
381
393
For more details on the available options, run the command using the `--help` option.
This example targets the `src` directory with the codemod. Replace `src` with the file pattern applicable to your file structure if it differs.
399
-
400
-
</Note>
401
-
402
408
### Running specific modifications
403
409
404
410
If you prefer to migrate your application more selectively instead of all at once, you can specify specific modifications using the `--codemod` option. For example, to run only the `imports` and `links` modifications, run the following command:
@@ -1032,6 +1038,60 @@ If you rely on the initial value to read data from the subscription, we recommen
1032
1038
1033
1039
</Caution>
1034
1040
1041
+
### `ObservableQuery` no longer inherits from `Observable`
1042
+
1043
+
`ObservableQuery` instances returned from `client.watchQuery` no longer inherit from `Observable`. This might cause TypeScript errors when using `ObservableQuery` with some RxJS utilities that expect `Observable` instances, such as [`firstValueFrom`](https://rxjs.dev/api/index/function/firstValueFrom).
1044
+
1045
+
Convert `ObservableQuery` to an `Observable` using the [`from`](https://rxjs.dev/api/index/function/from) function.
`ObservableQuery` implements the [`Subscribable`](https://rxjs.dev/api/index/interface/Subscribable) interface, so you can call `subscribe` directly without converting to an `Observable`. It also implements the `pipe` function, so you can chain operators.<br/><br/>
1057
+
1058
+
Use `from` only for functions that require an `Observable` instance.
1059
+
1060
+
</Note>
1061
+
1062
+
### Removal of `Observable` utilities
1063
+
1064
+
Apollo Client 3 included several utilities for working with `Observable` instances from the `zen-observable` library. Apollo Client 4 removes these utilities in favor of RxJS's operators.
1065
+
1066
+
#### `fromError`
1067
+
1068
+
Use the [`throwError`](https://rxjs.dev/api/index/function/throwError) function instead.
0 commit comments