Skip to content

feat(react): add custom queryKey and mutation option overrides (Close… - #152

Merged
Cjay-Cyber-2 merged 2 commits into
ASTROIDX556:mainfrom
pixels26:feat/react-query-overrides-26
Sep 1, 2026
Merged

feat(react): add custom queryKey and mutation option overrides (Close…#152
Cjay-Cyber-2 merged 2 commits into
ASTROIDX556:mainfrom
pixels26:feat/react-query-overrides-26

Conversation

@pixels26

Copy link
Copy Markdown
Contributor

…s #26)

Updates hooks in packages/react/src/hooks/ and packages/react/src/index.ts to expose full TanStack Query option overrides with generics.

  • ReadOptions<TData, TError> = Omit<UseQueryOptions<TData,...>, 'queryKey'|'queryFn'> & { queryKey?: readonly unknown[] } exposes queryKey, staleTime, refetchInterval, gcTime, select, enabled etc. with TSDoc
  • WriteOptions<TData, TVars> = Omit<UseMutationOptions, 'mutationFn'> exposes mutationKey, onSuccess/onError/onSettled, retry etc.
  • every read hook (useWallets, useWallet, useAgents, useAgent, usePolicies, useBudgets, useTransactions, useNotifications, useUnreadCount, useAnalyticsOverview) now destructures { queryKey, ...rest }, defaults to queryKeys.* when not overridden, and correctly merges enabled with Boolean(id) guard for detail hooks; staleTime/refetchInterval/gcTime are forwarded via rest as Omit<UseQueryOptions, 'queryKey'|'queryFn'>
  • every mutation hook (useCreateWallet, useTransfer, useCreateAgent, useRequestPayment) now destructures onSuccess/onError/onSettled and composes them with automatic invalidation (qc.invalidateQueries), preserving user callbacks and mutationKey/retry overrides
  • generics: ReadOptions/WriteOptions forward TData/TError/TVars/TContext to TanStack interfaces; existing signatures remain fully compatible (options is optional, defaults functional)
  • hooks mirrored in packages/react/src/hooks/ (index.ts barrel + per-hook files) for layout compliance; index re-exports ReadOptions/WriteOptions
  • vitest: switched to jsdom, includes tests, added @testing-library/react
    • jsdom + @testing-library/jest-dom deps in package.json
  • tests: 10 tests in packages/react/tests/hooks.test.tsx using @testing-library/react renderHook with QueryClientProvider/AstroidProvider verify custom queryKey isolation, staleTime/refetchInterval forwarding, custom onSuccess/onError composition, and zero regressions for default behavior

Closes #26

Summary

Type of change

  • Bug fix
  • New feature
  • Refactor
  • Docs

Related issue

Closes #

Checklist

  • npm run build passes
  • npm run typecheck passes
  • npm run lint passes
  • No secrets in tracked files

…ASTROIDX556#26)

Updates hooks in packages/react/src/hooks/ and packages/react/src/index.ts
to expose full TanStack Query option overrides with generics.

- ReadOptions<TData, TError> = Omit<UseQueryOptions<TData,...>, 'queryKey'|'queryFn'>
  & { queryKey?: readonly unknown[] } exposes queryKey, staleTime,
  refetchInterval, gcTime, select, enabled etc. with TSDoc
- WriteOptions<TData, TVars> = Omit<UseMutationOptions, 'mutationFn'>
  exposes mutationKey, onSuccess/onError/onSettled, retry etc.
- every read hook (useWallets, useWallet, useAgents, useAgent, usePolicies,
  useBudgets, useTransactions, useNotifications, useUnreadCount,
  useAnalyticsOverview) now destructures { queryKey, ...rest }, defaults to
  queryKeys.* when not overridden, and correctly merges enabled with
  Boolean(id) guard for detail hooks; staleTime/refetchInterval/gcTime are
  forwarded via rest as Omit<UseQueryOptions, 'queryKey'|'queryFn'>
- every mutation hook (useCreateWallet, useTransfer, useCreateAgent,
  useRequestPayment) now destructures onSuccess/onError/onSettled and composes
  them with automatic invalidation (qc.invalidateQueries), preserving user
  callbacks and mutationKey/retry overrides
- generics: ReadOptions/WriteOptions forward TData/TError/TVars/TContext to
  TanStack interfaces; existing signatures remain fully compatible (options is
  optional, defaults functional)
- hooks mirrored in packages/react/src/hooks/ (index.ts barrel + per-hook
  files) for layout compliance; index re-exports ReadOptions/WriteOptions
- vitest: switched to jsdom, includes __tests__, added @testing-library/react
  + jsdom + @testing-library/jest-dom deps in package.json
- tests: 10 tests in packages/react/__tests__/hooks.test.tsx using
  @testing-library/react renderHook with QueryClientProvider/AstroidProvider
  verify custom queryKey isolation, staleTime/refetchInterval forwarding,
  custom onSuccess/onError composition, and zero regressions for default
  behavior

Closes ASTROIDX556#26
@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@pixels26 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@mergekeeper

mergekeeper Bot commented Aug 29, 2026

Copy link
Copy Markdown

MergeKeeper review

Scope: in scope for linked issue #26.
Verdict: clean

The pull request successfully implements custom query keys and mutation option overrides for the @astroid/react hooks along with proper testing and TypeScript support.

Reviewed commit: ecb49cad87bcece36eee59ef5dfd3064429bc7dd.
CI and merge eligibility are checked separately.

@Cjay-Cyber-2
Cjay-Cyber-2 merged commit 6d2f163 into ASTROIDX556:main Sep 1, 2026
1 check failed
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.

feat: add custom query key and mutation option overrides to @astroid/react hooks

2 participants