-
Notifications
You must be signed in to change notification settings - Fork 19
feat: introduce TanStack Query integration for bounties, including query options, keys, and prefetching utilities. #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ery options, keys, and prefetching utilities.
📝 WalkthroughWalkthroughAdds a React Query layer for bounties: a typed query-key factory, query option helpers for list/detail/infinite fetches (including a pages-flatten utility), and server-friendly prefetch utilities with a fresh QueryClient factory. Changes
Sequence Diagram(s)sequenceDiagram
participant Server as "Server Component"
participant QC as "QueryClient"
participant API as "bountiesApi"
Server->>QC: createQueryClient()
Server->>QC: prefetchQuery(bountyListQueryOptions(params))
QC->>API: call bountiesApi.list(params page/limit)
API-->>QC: PaginatedResponse<Bounty>
QC-->>Server: cache populated
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@lib/query/prefetch.ts`:
- Around line 32-37: prefetchBounty currently calls queryClient.prefetchQuery
with bountyDetailQueryOptions(id) even when id is empty (enabled flag is ignored
by prefetchQuery), so add a guard at the top of prefetchBounty to return early
when id is falsy/empty; keep the function signature and simply do if (!id)
return; before calling queryClient.prefetchQuery (reference prefetchBounty and
bountyDetailQueryOptions to locate the code).
In `@lib/query/query-keys.ts`:
- Around line 22-23: BountyQueryKey currently only includes ReturnType<typeof
bountyKeys.list | typeof bountyKeys.detail> but the codebase also uses
bountyKeys.infinite; update the union to include that variant (e.g.
ReturnType<typeof bountyKeys.list | typeof bountyKeys.detail | typeof
bountyKeys.infinite>) so the type covers all active bountyKeys variants used
(referencing bountyKeys and BountyQueryKey to locate the change).
…yKey` to include infinite query keys.
…y-keys-and-query-functions feat: introduce TanStack Query integration for bounties, including query options, keys, and prefetching utilities.
This pull request introduces a comprehensive query management system for bounties using React Query. The changes modularize query key generation, query option factories, and prefetch utilities, making it easier to fetch, cache, and prefetch bounty data throughout the application.
Query Key Management:
bountyKeysinquery-keys.tsfor granular cache control of bounty lists and details. Also exported a type helper for query keys.Query Option Factories:
bounty-queries.tsfor listing bounties (bountyListQueryOptions), fetching single bounty details (bountyDetailQueryOptions), and paginated/infinite queries (bountyInfiniteQueryOptions). Added a helper to flatten paginated results.Prefetch Utilities:
prefetch.tsto create a newQueryClientper request, and to prefetch bounty lists, details, and multiple bounties for server-side rendering or data hydration.Centralized Exports:
index.tsto re-export all query keys, query option factories, and prefetch utilities for easy import throughout the codebase.closes #27
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.