Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frontend(queries): refactor to unified query interface to help maintainability #1205

Merged
merged 18 commits into from
Nov 14, 2024

Conversation

ollibowers
Copy link
Collaborator

@ollibowers ollibowers commented Nov 3, 2024

Created an abstraction layer around useQuery and useMutation, to help standardise the settings and key usage:

  • created query/mutation hook factory functions
  • reworked ALL query keys (previously none matched)
  • added a staleTime for both static and user queries, as well as gcTime for static queries
    • previously staleTime was defaulted to 0, meaning queries always got refetched
    • this meant mutations (and similarly keys) theoretically did nothing as the cache never got considered
    • IMPORTANT: this means some bugs may appear where data isnt being invalidated at the right time... but triv fix if so

Next up (when i have more time again):

  • make it so that queryOptions doesnt have to be given in queries (change variadic type params)
  • make it so we dont have to do funky defaults for dependent queries
    • currently if we try use !, we hit non-null assertion typeerrors
    • might make a queryOption allowUnsetParams which auto does the enable key and allows undefined params

IMPORTANT: Also snuck in a graph refactor to finally fix the bubble highlighting on mutation...

@ollibowers ollibowers marked this pull request as ready for review November 3, 2024 15:51
@ollibowers ollibowers requested a review from a team as a code owner November 3, 2024 15:51
Copy link
Contributor

@martanman martanman left a comment

Choose a reason for hiding this comment

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

lgtm

@ollibowers ollibowers merged commit d9440ad into 331-staging Nov 14, 2024
8 checks passed
@ollibowers ollibowers deleted the feat/fe/react-query-key-refactor branch November 14, 2024 09:37
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