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
[_Can be specified using `QueryClient`_](https://js2me.github.io/mobx-tanstack-query/api/QueryClient.html#mutationfeatures)
158
+
159
+
Chooses how MobX observes the mutation **`result`** property (the `MutationObserverResult`). The library applies `annotation.observable()` from [`yummies/mobx`](https://github.com/js2me/yummies). [`Query`](https://js2me.github.io/mobx-tanstack-query/api/Query.html#resultobservable-queryfeature) stores the payload on a private `_result` and exposes TanStack fields via getters; **`Mutation` decorates the public `result` field directly** — there is no `_result`.
160
+
161
+
-**Default** — when omitted, behaviour matches **`'deep'`** (deep observability for plain objects and arrays in the result).
162
+
-**`'ref'`** — only the reference to the result object is tracked; reactions run when the whole result is replaced, not when nested fields change in place.
163
+
-**`'shallow'`** / **`'struct'`** — shallow or structural comparison for nested properties.
164
+
-**`false`** — do not decorate `result` (rare; you lose automatic MobX tracking for the result blob).
Mutation result (The same as returns the [`useMutation` hook](https://tanstack.com/query/latest/docs/framework/react/reference/useMutation))
201
+
202
+
::: info `observable.deep` is configurable
203
+
The badge reflects the **default**: the public `result` property is decorated as deep observable (unlike `Query`, which uses a private `_result` behind getters). Change the MobX flavour with [`resultObservable`](#resultobservable-mutationfeature) (`ref`, `shallow`, `struct`, `true`, or `false`).
Copy file name to clipboardExpand all lines: docs/api/Query.md
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -295,6 +295,10 @@ This field is needed for `enableOnDemand` option
295
295
296
296
Query original result (The same as returns the [`useQuery` hook](https://tanstack.com/query/latest/docs/framework/react/reference/useQuery))
297
297
298
+
::: info `observable.deep` is configurable
299
+
The badge reflects the **default**: the internal `_result` field is decorated as deep observable. You can change the MobX flavour (`ref`, `shallow`, `struct`, `true`, or `false`) with the [`resultObservable`](#resultobservable-queryfeature) query feature.
300
+
:::
301
+
298
302
### `setData(updater, options)`
299
303
300
304
Set data for current query (Uses [queryClient.setQueryData](https://tanstack.com/query/latest/docs/reference/QueryClient#queryclientsetquerydata))
[_Can be specified using `QueryClient`_](https://js2me.github.io/mobx-tanstack-query/api/QueryClient.html#queryfeatures)
759
+
760
+
Chooses how MobX observes the internal TanStack Query result object (`_result`). The library applies [`annotation.observable()`](https://github.com/js2me/yummies) from `yummies/mobx`, so this maps directly to MobX flavours: `ref`, `deep`, `shallow`, `struct`, or `true` / `false`.
761
+
762
+
-**Default** — when omitted, behaviour matches **`'deep'`** (deep observability for plain objects and arrays in the result).
763
+
-**`'ref'`** — only the reference to the result object is tracked; use when the observer should react when the whole result is replaced, not when nested fields change in place.
764
+
-**`'shallow'`** / **`'struct'`** — shallow or structural comparison for nested properties.
765
+
-**`false`** — do not decorate `_result` with an observable annotation (rare; you lose automatic MobX tracking for the result blob).
766
+
767
+
Example:
768
+
769
+
```ts
770
+
const query =newQuery({
771
+
queryClient,
772
+
resultObservable: 'ref',
773
+
queryKey: ['pets'],
774
+
queryFn: async () =>api.fetchPets(),
775
+
});
776
+
```
777
+
752
778
## Recommendations
753
779
754
780
### Don't forget about `abortSignal`s or `lazy` option
0 commit comments