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
docs: update migration guide with section renumbering and API changes
- Renumber `useAsyncQuery` subsections for clarity.
- Document changes to `useApolloClient`, including removal of `resolveClient`.
- Update `useMutation onDone` callback with new `TData` handling.
- Revise summary table with newly added API differences and notes.
> This simplifies typing and aligns with Apollo `QueryOptions`.
81
81
82
-
### 2) `useLazyAsyncQuery` removed
82
+
### 3.2) `useLazyAsyncQuery` removed
83
83
Use `useAsyncQuery` with Nuxt `AsyncData` options instead of the dedicated "lazy" variant.
84
84
85
85
**Before:**
@@ -102,7 +102,7 @@ useAsyncQuery(
102
102
)
103
103
```
104
104
105
-
### 3) `cache` option removed
105
+
### 3.3) `cache` option removed
106
106
The old `cache?:boolean` flag is replaced by **Apollo fetch policies**.
107
107
108
108
**Before:**
@@ -122,15 +122,81 @@ useAsyncQuery({
122
122
})
123
123
```
124
124
125
+
### 3.4) `useApolloClient` changes
126
+
127
+
The old helper returned an object with `resolveClient` and `client`. The new helper is a **function** that returns the Apollo client instance directly.
- No `resolveClient` function, no `.client` property.
158
+
- If **no clients are registered**, an error is thrown.
159
+
- If the **requested id is missing**, an error is thrown with the list of available clients.
160
+
- Register clients via `apolloPlugin` and include a `default` client.
161
+
162
+
### 3.5) `useMutationonDone` changes
163
+
164
+
In the old API, `onDone` received a `MutateResult` object wrapping the mutation data, whereas in the new API it directly provides the **typed mutation data (TData)**.
165
+
166
+
**Before:**
167
+
```ts
168
+
onDone((result, { client }) => {
169
+
// result.data contains mutation result
170
+
console.log(result.data?.createUser.id)
171
+
// access Apollo client through context
172
+
client.cache.modify({ ... })
173
+
})
174
+
```
175
+
176
+
**After:**
177
+
```ts
178
+
onDone((data, context) => {
179
+
// data is the mutation result directly
180
+
console.log(data.createUser.id)
181
+
// access Apollo client through context
182
+
context.client.cache.modify({ ... })
183
+
})
184
+
```
185
+
186
+
**Key Differences:**
187
+
- Old: `result` was of type `MutateResult<TData>` → contained `{ data, error, extensions }`.
188
+
- New: first argument is `TData`, not wrapped inside `data`.
189
+
- Second argument `context` still includes `{ client }`.
190
+
125
191
## 4. Summary
126
-
| Feature | Old | New | Notes |
127
-
|----------|-----|-----|-------|
128
-
| Async Query (SSR) | `useAsyncQuery` from old package | `useAsyncQuery` (object options) | Unified API for Nuxt 4 |
0 commit comments