Skip to content

Conversation

@tnetennba3
Copy link
Contributor

Context

Changes proposed in this pull request

Guidance to review

Link to Trello ticket

Things to check

  • I have added any new ENV vars in all deployed environments and updated the .env.test files in the repo

@tnetennba3 tnetennba3 force-pushed the feat/tanstack-query-proof-of-concept branch 2 times, most recently from 0938e5e to 30842d5 Compare January 28, 2026 15:38
Replacing all uses of `createFetchStore` to use Tanstack Query
instead to handle state management. The immediate benefit of
this is that we're no longer debouncing each request which is
adding an artificial delay of 500ms for each request.

I also think the error handling is clearer because its colocated
with mutations via onError.

There are many more benefits to come with using Tanstack Query,
this is just a 1:1 replace to illustrate how it works.
For static data, we should fetch server-side in Astro and pass in
to the component.
I thought it was clearer to have everything colated together rather
than separate screens in /screens because it's not clear where the
logical separation is.

I have also adopted the naming conventions we use in the API and
database for consistency:
 - themes > selected themes
 - generated themes > candidate themes
 - answers > responses
The main motivations behind this refactor is:
 - Replacing all instances of `createFetchStore` with either TanStack
   Query for dynamic data and server-side fetch in Atsro for static data
 - Breaking down into smaller and better encapsulated components that
   own the relevant queries, mutations and state
 - Add disabled state to prevent duplicate reuqests
Centralise API routes, query keys, and data fetching logic into
resource-based query files. This removes scattered fetch calls and
route helpers from components, making it easier to understand where
data comes from and ensuring consistent error handling.

Components now import everything they need (types, queries, mutations)
from a single query file per resource, reducing cognitive overhead                                                                                              when working with API data.
@tnetennba3 tnetennba3 force-pushed the feat/tanstack-query-proof-of-concept branch from 30842d5 to a3131eb Compare January 28, 2026 15:38
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