Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Replace jotai-urql with just urql #2351

Merged
merged 4 commits into from
Feb 15, 2024
Merged

Replace jotai-urql with just urql #2351

merged 4 commits into from
Feb 15, 2024

Conversation

sandhose
Copy link
Member

@sandhose sandhose commented Feb 12, 2024

This was unnecessarily complicated.
This replaces everything which used jotai-urql with just urql calls.

Next step is to replace the custom jotai-based router with tanstack router, but I prefer to do that in a second PR to make it easier to review.

For reviewers, most interesting changes are:

  • in src/app.tsx, the app root now loads the current user ID to allow giving a non-nullable user ID down the component tree, and avoid having a "is the user ID null" logic in every route
  • for error handling, I prefer to just throw if result.error is set and handle the error in the nearest error boundary
  • annoyingly, urql doesn't know it runs in suspense mode in its typings, so result.data is nullable, which should never happen unless result.error is set. So there is a lot of:
    const [result] = useQuery(...);
    if (result.error) throw result.error;
    if (!result.data) throw new Error(); // Suspense mode is enabled
  • the pagination logic was probably the biggest change. See src/pagination.tsx for the hooks, and src/components/BrowserSessionList.tsx for an example usage

@sandhose sandhose added A-Frontend Changes on the React frontend T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks. labels Feb 12, 2024
Copy link

cloudflare-workers-and-pages bot commented Feb 12, 2024

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: aef9c7a
Status: ✅  Deploy successful!
Preview URL: https://66afbf3b.matrix-authentication-service-docs.pages.dev
Branch Preview URL: https://quenting-remove-jotai-urql.matrix-authentication-service-docs.pages.dev

View logs

@sandhose sandhose requested a review from t3chguy February 12, 2024 12:42
Copy link
Member

@t3chguy t3chguy left a comment

Choose a reason for hiding this comment

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

Looks sane

@sandhose sandhose merged commit f0f7497 into main Feb 15, 2024
16 of 18 checks passed
@sandhose sandhose deleted the quenting/remove-jotai-urql branch February 28, 2024 16:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Frontend Changes on the React frontend T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants