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
feat(react-query): add httpClientInjection: 'reactQueryMeta' for axios instance injection
Adds support for injecting axios instances at runtime via QueryClient.defaultOptions.meta,
enabling NPM package distribution, SSR, and mock injection without custom mutators.
Generated hooks automatically resolve the axios instance from:
- queries.meta.axiosInstance for queries
- mutations.meta.axiosInstance for mutations
HTTP functions now return Promise<T> (data unwrapped) instead of Promise<AxiosResponse<T>>
to ensure SSR dehydrate() can serialize the cache.
Use `httpClientInjection: 'reactQueryMeta'` to inject a configured axios instance at runtime via the QueryClient. This is useful when publishing generated code as an NPM package — consumers provide their own axios with interceptors, auth, and base URL.
The generated hooks are SSR-compatible — prefetch works out of the box with `dehydrate()`. See the [complete example](https://github.com/orval-labs/orval/blob/master/samples/react-query/queryclient-meta).
185
+
131
186
## Full Example
132
187
133
188
See the [complete React Query example](https://github.com/orval-labs/orval/blob/master/samples/react-query/basic) on GitHub.
Copy file name to clipboardExpand all lines: docs/content/docs/reference/configuration/output.mdx
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,6 +77,40 @@ export default defineConfig({
77
77
});
78
78
```
79
79
80
+
## httpClientInjection
81
+
82
+
**Type:**`'none' | 'reactQueryMeta'`
83
+
**Default:**`'none'`
84
+
85
+
Controls how the HTTP client instance is provided to generated hooks. When set to `reactQueryMeta`, the generated hooks read the axios instance from `QueryClient.defaultOptions.meta.axiosInstance` at runtime, enabling SDK-style distribution where consumers inject their own configured instance.
The generated hooks automatically resolve the instance via `useQueryClient()` inside `queryFn`/`mutationFn`. Falls back to default axios if not configured. Incompatible with custom `mutator`.
0 commit comments