Skip to content

[DEVSU-2860] apicalls to react query#739

Open
kttkjl wants to merge 16 commits intodevelopfrom
chore/DEVSU-2860-apicalls-to-react-query
Open

[DEVSU-2860] apicalls to react query#739
kttkjl wants to merge 16 commits intodevelopfrom
chore/DEVSU-2860-apicalls-to-react-query

Conversation

@kttkjl
Copy link
Member

@kttkjl kttkjl commented Feb 27, 2026

Migrates API calls across the application from ad-hoc api.get() calls to react-query, establishing a centralized, auto-generated query layer.

Query infrastructure (app/queries/)

  • queryKeys.ts — auto-generated from the OpenAPI spec via scripts/generateQueryKeys.ts; defines a typed, nested registry of all API route keys
  • get.ts — auto-generated react-query hooks (e.g. useReportSummaryAnalystComments, useReportSignatures) built on a shared useAuthedQuery wrapper that gates requests on the presence of an auth token

Code generation scripts (scripts/)

  • generateQueryKeys.ts — fetches the OpenAPI spec and emits queryKeys.ts
  • generateQueryHooks.ts — reads queryKeys.ts and emits a hook for every key entry in get.ts

Migration scope

  • ReportView subcomponents — AnalystComments, GenomicSummary, RapidSummary, Settings, TumourSummary, MutationBurden, Appendices, PatientInformation, KbMatches, and more
  • Shared components — SignatureCard, TumourSummaryEdit, UserSettingsDialog, AddEditVariantText
  • Top-level views — ReportsView, ReportsSearchView, MyReportsView, TemplateView, PrintView, PatientsView
  • Single source of truth for report (ReportView/index.tsx, ReportContext)

Report data is now fetched once at the ReportView level and distributed via context, removing duplicated fetch logic in child components
ReportContext types updated to reflect the full ReportType

Other

  • Removed useSignatures hook (superseded by generated hooks)
  • tsx added as a dev dependency for running the generation scripts (pinned to ^3.14.0 for Node 16 compatibility; upgrade to ^4.x planned with Node 20 migration)
  • Fixed AnalystComments test — queries were silently disabled due to missing SecurityContext.Provider (no auth token → enabled: false)

Future tasks

  • the linked useQuery calls in rapidSummary view can probably use the new hooks
  • update the build process to node 20 for up-to-date libraries (74 vulns atm)

@kttkjl
Copy link
Member Author

kttkjl commented Feb 27, 2026

Hooks all in, would probably need to revamp the usage of useContext(ReportContext) into useReport

but that useReport also coincides with the auto-generated API hooks, would probably rename useReport into useReportContext in the next commits while deprecating useContext(ReportContext)

@kttkjl
Copy link
Member Author

kttkjl commented Mar 2, 2026

Downgrading tsx to v3 for now, will make a ticket probably to migrate to node 20

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Test Results

    1 files  ±0    28 suites  ±0   5m 5s ⏱️ +11s
145 tests ±0  145 ✔️ ±0  0 💤 ±0  0 ±0 
142 runs  ±0  142 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit 1696853. ± Comparison against base commit 08c04b3.

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Test Results

    1 files  ±0    28 suites  ±0   4m 56s ⏱️ -10s
145 tests ±0  145 ✔️ ±0  0 💤 ±0  0 ±0 
142 runs  ±0  142 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit 03d2f19. ± Comparison against base commit 80ec189.

♻️ This comment has been updated with latest results.

@kttkjl kttkjl marked this pull request as ready for review March 3, 2026 00:14
@kttkjl kttkjl self-assigned this Mar 3, 2026
@kttkjl
Copy link
Member Author

kttkjl commented Mar 3, 2026

useReport API call and useReport with the context is probably confusing when importing ...

kttkjl and others added 4 commits March 3, 2026 16:39
  - bugfixed getImageDataURL when image is falsy
  - bugfixed useReport api to not cache result, to fix sidebar issue
  - removed unncessary comments
DEVSU-2860
Copy link
Contributor

@bnguyen-bcgsc bnguyen-bcgsc left a comment

Choose a reason for hiding this comment

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

In Tumour Summary, if I make changes and click save, the changes don't show up until I refresh the page

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