feat: replace hand-written bountyKeys with codegen-generated query keys#115
Conversation
|
@ryzen-xp is attempting to deploy a commit to the Threadflow Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughReplaces the hand-written bounty query key factory with codegen-generated React Query key helpers. Keys now delegate to generated hooks' getKey() methods, introduce typed variable wrappers, and add three new public key variants: active, organization, and project. Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/query/query-keys.ts`:
- Around line 24-26: The infinite key currently reuses the exact same getKey as
list (see infinite and useBountiesQuery.getKey) which can cause cache collisions
between useQuery and useInfiniteQuery; modify the infinite key to append a
distinguishing suffix (for example include a literal like "infinite" or a second
tuple element) while preserving the original getKey base so the list key stays
unchanged—update the infinite function to return the base getKey result combined
with the suffix to ensure unique cache entries for useInfiniteBounties.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
lib/query/query-keys.ts
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
lib/query/query-keys.ts (1)
25-30: Good fix for the list/infinite cache collision.The
"infinite"suffix differentiates infinite query keys from list query keys, preventing TanStack Query from treatinguseQueryanduseInfiniteQueryresults as the same cache entry. This properly addresses the previously flagged concern.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/query/query-keys.ts` around lines 25 - 30, The infinite query key now appends the "infinite" suffix to avoid cache collision with the list query; update the infinite function (in query-keys.ts) to build its key from useBountiesQuery.getKey({ query: params } as BountiesQueryVariables) and append "infinite" so that useInfiniteQuery and useQuery do not share the same cache entry (ensure the signature uses params?: Omit<BountyQueryInput, "page"> and the returned tuple is typed as const).
🧹 Nitpick comments (1)
lib/query/query-keys.ts (1)
52-56:BountyQueryKeyis missing the new key variants.The type union only covers
list,infinite, anddetail. ThebountyKeysobject also includeslists,active,organization, andprojectmethods, which should be added to the type for completeness. WhileBountyQueryKeyis currently not used elsewhere in the codebase, keeping the type union in sync with available keys prevents future type inconsistencies when this helper is adopted.♻️ Proposed fix to include all key variants
export type BountyQueryKey = + | ReturnType<typeof bountyKeys.lists> | ReturnType<typeof bountyKeys.list> | ReturnType<typeof bountyKeys.infinite> - | ReturnType<typeof bountyKeys.detail>; + | ReturnType<typeof bountyKeys.detail> + | ReturnType<typeof bountyKeys.active> + | ReturnType<typeof bountyKeys.organization> + | ReturnType<typeof bountyKeys.project>;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/query/query-keys.ts` around lines 52 - 56, Update the BountyQueryKey union to include all variants exposed by bountyKeys: add ReturnType<typeof bountyKeys.lists>, ReturnType<typeof bountyKeys.active>, ReturnType<typeof bountyKeys.organization>, and ReturnType<typeof bountyKeys.project> in addition to the existing list, infinite, and detail entries so the type stays in sync with the bountyKeys object.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/query/query-keys.ts`:
- Around line 1-13: The BountyQueryKey union is missing variants and should
include all return types from bountyKeys; update the type to union
ReturnType<typeof bountyKeys.lists>, ReturnType<typeof bountyKeys.list>,
ReturnType<typeof bountyKeys.infinite>, ReturnType<typeof bountyKeys.detail>,
ReturnType<typeof bountyKeys.active>, ReturnType<typeof
bountyKeys.organization>, and ReturnType<typeof bountyKeys.project> so
BountyQueryKey covers lists, list, infinite, detail, active, organization, and
project (reference bountyKeys and the BountyQueryKey type).
---
Duplicate comments:
In `@lib/query/query-keys.ts`:
- Around line 25-30: The infinite query key now appends the "infinite" suffix to
avoid cache collision with the list query; update the infinite function (in
query-keys.ts) to build its key from useBountiesQuery.getKey({ query: params }
as BountiesQueryVariables) and append "infinite" so that useInfiniteQuery and
useQuery do not share the same cache entry (ensure the signature uses params?:
Omit<BountyQueryInput, "page"> and the returned tuple is typed as const).
---
Nitpick comments:
In `@lib/query/query-keys.ts`:
- Around line 52-56: Update the BountyQueryKey union to include all variants
exposed by bountyKeys: add ReturnType<typeof bountyKeys.lists>,
ReturnType<typeof bountyKeys.active>, ReturnType<typeof
bountyKeys.organization>, and ReturnType<typeof bountyKeys.project> in addition
to the existing list, infinite, and detail entries so the type stays in sync
with the bountyKeys object.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
lib/query/query-keys.ts
Summary
Replaced hand-written
bountyKeyswith codegen-generated query keys usingexposeQueryKeys: true, establishing a single source of truth for all bounty query keys.Changes
Reviewed
generated.tskey exports:useBountiesQuery.getKey()useBountyQuery.getKey()useActiveBountiesQuery.getKey()useOrganizationBountiesQuery.getKey()useProjectBountiesQuery.getKey()Updated
lib/query/query-keys.tsto delegate to generatedgetKeymethods.Removed redundant hand-written key factories.
Existing hooks, handlers, and mutations now automatically use generated keys via
bountyKeys.Prefetch utilities already aligned — no changes needed.
Acceptance Criteria
Closes #107
Summary by CodeRabbit