mirror of
https://github.com/prdlk/dotfiles.git
synced 2026-11-03 11:37:36 +00:00
- 16 cross-shell utilities converted to sh/bash chezmoi executables: ai c2p cp-appid extract_agents fab gdc gh-sonr-org-migrate ghg-clone ghn gho git-summary launch_omp_livediff_overlay lc-elir mdcp mdp pj (ghg-clone not named ghg: unrelated cargo binary owns that name) - cwd/history helpers stay per-shell: yy c cd clip-last + ghg/ghn/gho cd-wrappers in bash/functions/ and zsh/functions/, loaded by rc files - fish keeps only shell-state functions; converted ones now hit PATH - cp-appid ignore gating moved to .local/bin path - dot_agents/skills: 82 skills materialized from dotstate storage so dot_claude skill symlinks resolve on fresh bootstrap; dotstate profile/symlinks.json released .agents/skills .bashrc .zshrc
63 lines
1.8 KiB
Markdown
63 lines
1.8 KiB
Markdown
# qk-include-dependencies: Include All Variables the Query Depends On
|
|
|
|
## Priority: CRITICAL
|
|
|
|
## Explanation
|
|
|
|
If your query function depends on a variable, that variable must be included in the query key. This ensures independent caching per variable combination and automatic refetching when dependencies change. Missing dependencies cause stale data bugs and cache collisions.
|
|
|
|
## Bad Example
|
|
|
|
```tsx
|
|
function UserPosts({ userId }: { userId: string }) {
|
|
// Missing userId in query key - all users share the same cache!
|
|
const { data } = useQuery({
|
|
queryKey: ['posts'],
|
|
queryFn: () => fetchPostsByUser(userId),
|
|
})
|
|
|
|
return <PostList posts={data} />
|
|
}
|
|
|
|
function FilteredTodos({ status, page }: { status: string; page: number }) {
|
|
// Missing filter parameters - won't refetch when filters change
|
|
const { data } = useQuery({
|
|
queryKey: ['todos'],
|
|
queryFn: () => fetchTodos({ status, page }),
|
|
})
|
|
|
|
return <TodoList todos={data} />
|
|
}
|
|
```
|
|
|
|
## Good Example
|
|
|
|
```tsx
|
|
function UserPosts({ userId }: { userId: string }) {
|
|
// userId included - each user has their own cache entry
|
|
const { data } = useQuery({
|
|
queryKey: ['posts', userId],
|
|
queryFn: () => fetchPostsByUser(userId),
|
|
})
|
|
|
|
return <PostList posts={data} />
|
|
}
|
|
|
|
function FilteredTodos({ status, page }: { status: string; page: number }) {
|
|
// All dependencies included - refetches when any change
|
|
const { data } = useQuery({
|
|
queryKey: ['todos', { status, page }],
|
|
queryFn: () => fetchTodos({ status, page }),
|
|
})
|
|
|
|
return <TodoList todos={data} />
|
|
}
|
|
```
|
|
|
|
## Context
|
|
|
|
- This is arguably the most important query key rule
|
|
- Applies whenever query function uses external variables
|
|
- Prevents subtle bugs where different contexts share cached data
|
|
- Works in conjunction with staleTime - even with long staleTime, changing keys triggers new fetches
|