Skip to content

perf(client): hoist the in-render dedupeFragments calls in the report screens - #4447

Open
gilgardosh wants to merge 1 commit into
claude/urql-step-5-loader-guardsfrom
claude/urql-step-6-dedupe-fragments
Open

perf(client): hoist the in-render dedupeFragments calls in the report screens#4447
gilgardosh wants to merge 1 commit into
claude/urql-step-5-loader-guardsfrom
claude/urql-step-6-dedupe-fragments

Conversation

@gilgardosh

Copy link
Copy Markdown
Collaborator

Step 6 of 10 in the urql quick-wins sequence — tracking doc in #4437.

⚠️ Stacked on #4446 (step 5) → #4444. Retarget as the stack merges.

What changed

Four report screens passed dedupeFragments(XDocument) straight into useQuery:

  • reports/tax-report/index.tsx
  • reports/profit-and-loss-report/index.tsx
  • reports/corporate-tax-ruling-compliance-report/index.tsx
  • reports/vat-monthly-report/pcn-generator.tsx

dedupeFragments builds a new DocumentNode on every call, so each render handed urql a fresh object that it had to re-print and re-hash before arriving at the same operation key it had the render before. The tax report's document is 126 lines.

Each is now a module-scope constant. This isn't a new convention — vat-monthly-report/index.tsx already did exactly this and carries a comment explaining why; the four stragglers just never got the same treatment.

Scope

No behaviour change. The operation key was already stable, so nothing re-keys and no query re-fires. This only stops the repeated work of deriving that key.

No test. There's no behaviour to assert here, and a test that merely restates the refactor is noise. The net is the existing suite plus stories.test.tsx, which mounts these components against a real urql client.

yarn test:client   48 files, 373 passed, 0 skipped
yarn lint          0 errors
tsc --noEmit       clean
vite build         ✓ built in 6.17s

I ran a full production build on this one specifically, since the change moves work to module-evaluation time.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TbrGL3NndzRiEwJkwHxnbm


Generated by Claude Code

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved review comments remain, and the refactor is limited to stabilizing query documents.

Pull request overview

Hoists dedupeFragments() results to module scope in four report screens to avoid repeated document processing during renders.

Changes:

  • Stabilizes query documents in four report components.
  • Adds a client patch changeset.
File summaries
File Description
packages/client/src/components/reports/vat-monthly-report/pcn-generator.tsx Hoists the PCN query document.
packages/client/src/components/reports/tax-report/index.tsx Hoists the tax report query document.
packages/client/src/components/reports/profit-and-loss-report/index.tsx Hoists the profit-and-loss query document.
packages/client/src/components/reports/corporate-tax-ruling-compliance-report/index.tsx Hoists the compliance report query document.
.changeset/urql-hoist-dedupe-fragments.md Documents the client patch release.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

… screens

Four report screens passed `dedupeFragments(XDocument)` straight into `useQuery`.
`dedupeFragments` builds a new `DocumentNode` on every call, so each render
handed urql a fresh object it had to re-print and re-hash before arriving at the
same operation key as last time. The tax report's document is 126 lines.

Each is now a module-scope constant, matching `vat-monthly-report/index.tsx`,
which already did this and carries a comment explaining why.

No behaviour change: the operation key was already stable, so nothing re-keys or
re-fires. This only stops the repeated work of deriving it. No test accompanies
it — there is no behaviour to assert, and a test restating the refactor would be
noise; the existing suite plus `stories.test.tsx`, which mounts these
components, is the net.

Step 6 of the urql quick-wins sequence.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TbrGL3NndzRiEwJkwHxnbm
@gilgardosh
gilgardosh force-pushed the claude/urql-step-6-dedupe-fragments branch from 59be74d to 8a974ea Compare September 12, 2026 12:44
@gilgardosh
gilgardosh deployed to accounter-fullstack September 12, 2026 12:44 — with GitHub Actions Active
@gilgardosh
gilgardosh deployed to accounter-fullstack September 12, 2026 12:44 — with GitHub Actions Active
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.

3 participants