Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat(guide): query keys — use the scaffold's generated constant, never an inline array (build42 Contact)#184

Open
agjs wants to merge 3 commits into
mainagjs/tsforge:mainfrom
fix/query-key-constant-idiomagjs/tsforge:fix/query-key-constant-idiomCopy head branch name to clipboard
Open

feat(guide): query keys — use the scaffold's generated constant, never an inline array (build42 Contact)#184
agjs wants to merge 3 commits into
mainagjs/tsforge:mainfrom
fix/query-key-constant-idiomagjs/tsforge:fix/query-key-constant-idiomCopy head branch name to clipboard

Conversation

@agjs

@agjs agjs commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Wall (build42 Contact)

Contact advanced past parent-FK/anatomy/no-jsx-computation to near-green, then rotated on nonConstantQueryKey (react-component-architecture): a useQuery/useMutation queryKey/mutationKey that is an inline array literal starting with a string (queryKey: ["contact", id]) is rejected — the model inlined the array instead of using the constant.

Fix (aligned to the scaffold — not an invented shape)

The scaffold's new:feature already generates CONTACT_QUERY_KEYS = { list: ["contact","list"] as const } (a static tuple, accessed as .list). The guide now teaches: reference that generated constant (queryKey: CONTACT_QUERY_KEYS.list) and invalidate the list in mutations' onSuccess with the same .list; add an extra key in the scaffold's style — a static tuple for a fixed key, a factory only for a parameterized one (detail: (id) => ["contact", id] as const); and never rewrite the static list tuple into a function (bare .list usages would hand React Query a function as the key → silently broken refresh).

An earlier iteration of this PR invented a hierarchical all/list()/detail() factory shape; the panel correctly flagged that it conflicts with the gate-green scaffold and creates a partial-apply footgun — corrected to match the scaffold exactly (root-caused from the generated Contact.constants.ts + the rule source).

Tests

boringstack-refine-prompt.test.ts pins the scaffold shape, property access (.list), same-constant invalidation, parameterized-only factory, and locks out both earlier mis-teachings (the inline-spread loophole and the .list() rewrite). Full core suite green. Panel PASS.

🤖 Generated with Claude Code

agjs added 3 commits July 24, 2026 06:19
…array queryKey) — build42 Contact

build42 Contact advanced past parent-FK/anatomy/no-jsx-computation to near-green, then rotated on
nonConstantQueryKey (react-component-architecture): a useQuery/useMutation queryKey/mutationKey whose
value is an array literal STARTING with a string (queryKey: ["contact", id]) is rejected. The guide
never mentioned query keys. Root-caused from the rule source (fires only on an ArrayExpression whose
first element is a string Literal) and front-loaded the exact idiom: define keys once in
<Feature>.constants.ts as a const (CONTACT_QUERY_KEYS.all/list/detail), reference them in the query,
and invalidate with the SAME constant in mutations' onSuccess (so the list refreshes). Noted the
spread-of-constant escape (only a bare-string-first array trips). New refine-prompt test. Full core suite green.
…reuse in the test

Panel PASS with ag1 notes, addressed: (1) the parenthetical taught that an inline spread passes the
rule — but  at the call site re-scatters the key even though it lints
clean. Reframed: the CALL SITE always references the constant factory (KEYS.list()/.detail(id)),
never an inline array; the spread lives INSIDE the constants file's detail(id) factory (single source
of truth). (2) The invalidation test only checked the pre-existing 'invalidateQueries' text; now it
asserts the exact constant reuse (invalidateQueries({ queryKey: CONTACT_QUERY_KEYS.all })) + the
no-inline-array / single-source guidance. Full core suite green.
…perty access) — not invented factories

Panel wrong-idiom (correct): my QUERY_KEYS shape (hierarchical all/list()/detail() factories, KEYS.list()
call, invalidate KEYS.all) CONFLICTED with what the scaffold's new:feature ALREADY generates gate-green:
  export const CONTACT_QUERY_KEYS = { list: ['contact','list'] as const };  // static tuple, accessed .list
It would have forced needless rewrites of working files + a partial-apply footgun (list becomes a function
but bare .list usages hand React Query a function as the key → broken refresh). Real scaffold features use
static tuples for fixed keys, factories ONLY for parameterized ones. build42's actual error was INLINING an
array, not the key shape. Rewrote the guidance to: USE the generated CONTACT_QUERY_KEYS.list (property, as
wired), invalidate with the SAME .list, and ADD keys in the scaffold's style — static tuple for fixed, a
factory only for a parameterized detail(id); never rewrite the static list into a function. Test now pins
the scaffold shape + property access + parameterized-only factory, and locks out BOTH earlier mis-teachings
(the inline-spread loophole and the .list() rewrite). Full core suite green.
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.