Skip to content

feat: auto-resolve QueryClient in hooks from <QueryClientProvider />#345

Merged
radist2s merged 2 commits into
mainfrom
feat/simplified-hooks-usage
Jun 7, 2025
Merged

feat: auto-resolve QueryClient in hooks from <QueryClientProvider />#345
radist2s merged 2 commits into
mainfrom
feat/simplified-hooks-usage

Conversation

@radist2s

@radist2s radist2s commented Jun 7, 2025

Copy link
Copy Markdown
Collaborator

This update simplifies the usage of our React hooks by pulling the QueryClient directly from the <QueryClientProvider /> context. Now, hooks like useQuery, useMutation, and useFetching no longer require an explicitly passed client when initializing the API client - making them more ergonomic and reducing boilerplate.

  • What’s changed

    • Hooks (useQuery, useMutation, useFetching, etc.) will automatically grab the QueryClient from context.

    • You can omit the queryClient option when creating your API client if you only need it for hook-based operations.

    • Note: Low-level methods on the API client - such as setQueryData, getQueryData, etc. - still require you to supply a QueryClient when the client is instantiated.

  • Why

    • Improves developer experience by removing repetitive passing of the same QueryClient.

    • Aligns with TanStack React Query’s recommended pattern of using a provider for client injection.

@radist2s radist2s changed the title Feat/simplified hooks usage feat: auto-resolve QueryClient in hooks from <QueryClientProvider /> Jun 7, 2025
radist2s added 2 commits June 7, 2025 23:29
…eryClient from the `<QueryClientProvider />` context instead of requiring it to be passed in explicitly when the API Client created.
…Client from the `<QueryClientProvider />` context instead of requiring it to be passed in explicitly when the API Client created.
@radist2s radist2s force-pushed the feat/simplified-hooks-usage branch from c22f1ca to 8f0b86a Compare June 7, 2025 19:29
@changeset-bot

changeset-bot Bot commented Jun 7, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8f0b86a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@openapi-qraft/react Minor
@openapi-qraft/cli Minor
@openapi-qraft/plugin Minor
@openapi-qraft/tanstack-query-react-plugin Minor
@openapi-qraft/tanstack-query-react-types Minor
@openapi-qraft/openapi-typescript-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@radist2s radist2s marked this pull request as ready for review June 7, 2025 19:32
@radist2s radist2s merged commit f058231 into main Jun 7, 2025
13 checks passed
@radist2s radist2s deleted the feat/simplified-hooks-usage branch June 7, 2025 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant