feat(react-query): add httpClientInjection: 'reactQueryMeta' option#2920
Draft
FR073N wants to merge 1 commit intoorval-labs:masterfrom
Draft
feat(react-query): add httpClientInjection: 'reactQueryMeta' option#2920FR073N wants to merge 1 commit intoorval-labs:masterfrom
FR073N wants to merge 1 commit intoorval-labs:masterfrom
Conversation
8a7fca6 to
f0a07a3
Compare
…s 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.
f0a07a3 to
cf1aaf9
Compare
Contributor
Author
|
@melloware Here I created the PR, but as you said we may need inputs to be sure this is acceptable. Thank you. |
Collaborator
|
Yep I would definitely like others input as this one concerns me. I am not against it I just have concerns! I will ask others to weigh in |
Collaborator
|
looks like merge conflicts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey team, I'd love to get your feedback on this implementation.
Fix #2887
Context
When using
client: 'react-query'withhttpClient: 'axios', there's no clean way to inject a configured axios instance at runtime. The custom mutator creates a singleton at import time, which blocks NPM package distribution, SSR, and test mocking.Linked to :
This PR
New option
httpClientInjection: 'reactQueryMeta'that leverages React Query's nativemetafeature:Consumer side:
Main benefit
With this option, you can build a real SDK from orval-generated code and publish it on NPM. The axios instance is injected by the consumer, not hardcoded in the package. Hooks return
Promise<T>instead ofPromise<AxiosResponse<T>>for SSR compatibility withdehydrate().Looking for feedback
If you use orval-generated code with react-query, I'd appreciate your input:
Tinstead ofAxiosResponse<T>— acceptable?Includes tests, docs, and a complete sample in
samples/react-query/queryclient-meta/.