Skip to content

feat(parser-react): follow react-query/SWR queryFn references to their endpoints#9

Merged
officialCodeWork merged 1 commit into
developmentfrom
build/phase-1/step-1.3-queryfn-following
Jul 13, 2026
Merged

feat(parser-react): follow react-query/SWR queryFn references to their endpoints#9
officialCodeWork merged 1 commit into
developmentfrom
build/phase-1/step-1.3-queryfn-following

Conversation

@officialCodeWork

Copy link
Copy Markdown
Owner

Summary

TRACKER Step 1.3 — failure mode C5. useQuery({ queryKey: ["users"], queryFn: fetchUsers }) contains no URL at the call site; the endpoint lives inside fetchUsers, often in another file. The scanner now follows the reference.

What resolves now

Call site Endpoint How
useQuery({ queryKey: ["users"], queryFn: fetchUsers }) GET /api/users reference → api/users.ts → fetch inside
useMutation({ mutationFn: createUser }) POST /api/users method picked up from the inner fetch options
useQuery(["team"], fetchTeam) (v3 positional) GET /api/team arrow-const reference
useQuery({ queryFn: () => fetch("/api/stats")… }) GET /api/stats inline arrow body
useSWR(key, fetcher) key when it has shape, fetcher body otherwise SWR convention
  • The whole 1.1/1.2 machinery applies inside queryFns — constant folding and wrapper substitution work there for free.
  • DataSourceNode gains queryKey — cache identity recorded alongside the endpoint (groundwork for cache-sharing analysis, C7).
  • Poison assertion in the fixture: a query key (["team"]) must never be reported as an endpoint.

Eval movement

  • New fixture c5-queryfn-indirection (4 components, all forms).
  • Threshold ratcheted: minLineageRecall: 0.88.
  • Scorecard: 60 pass / 0 fail / 2 xfail / 0 unexpected-pass · precision 1.000 · recall 0.889 (was 0.857) · match accuracy 1.000.

Test plan

  • 44 unit tests green (5 new queryFn tests)
  • pnpm eval gate OK; schema regenerated (queryKey field), drift gate green

Documentation

  • TRACKER.md — 1.3 done, Status → 1.4

🤖 Generated with Claude Code

…r endpoints

Step 1.3 (TRACKER). Failure mode C5:

- endpointFromFunction: queryFn/mutationFn/fetcher expressions resolve to a
  function body — inline arrows directly, references via go-to-definition
  (cross-file) — and the first data source inside is extracted with the full
  1.1/1.2 machinery (constant folding + wrapper substitution work inside
  queryFns for free).
- Covers v4/v5 object form ({queryKey, queryFn} / {mutationFn}), v3
  positional forms (useQuery(key, fn) / useMutation(fn)), and SWR key-or-
  fetcher fallback. Mutations pick up the inner call's method (POST).
- DataSourceNode gains queryKey — the cache identity recorded alongside the
  endpoint, groundwork for cache-sharing analysis (C7).
- Fixture c5-queryfn-indirection with the poison assertion that a query KEY
  must never be reported as an endpoint.
- Thresholds ratcheted: minLineageRecall 0.88. Scorecard: 60 pass / 0 fail /
  2 xfail; recall 0.889. 44 unit tests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@officialCodeWork
officialCodeWork merged commit 67411c5 into development Jul 13, 2026
1 check passed
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.

2 participants