Skip to content

refactor: replace useSanity with a TanStack Query layer over Sanity - #301

Open
Tomahawk2191 wants to merge 12 commits into
mainfrom
refactor/sanity-query-layer
Open

Tomahawk2191 wants to merge 12 commits into
mainfrom
refactor/sanity-query-layer

Conversation

@Tomahawk2191

@Tomahawk2191 Tomahawk2191 commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

What was the ticket?

N/A

What did I do?

Part 1 of 5 in the TanStack Query + React Router refactor. Stack: #301 → #302 → #303 → #304 → #305. Review and merge in order.

Replaces the useSanity hook with a typed TanStack Query layer over Sanity.

  • Adds @tanstack/react-query with a shared queryClient (staleTime: Infinity, since Sanity content doesn't change within a session).
  • Adds GROQ TypeGen: queries are written with defineQuery and result types are generated into src/sanity/queries/types.gen.ts (bun run typegen).
  • Splits Sanity access into one module per content type under src/sanity/queries/ (copyQuery, directorsQuery, teamsQuery, showcasesQuery, valuesQuery, linksQuery), each exporting queryOptions with a select that shapes data for the UI.
  • Deletes src/services/useSanity.ts, src/client.ts and the page-level types.ts files.
  • Images: all Sanity image URLs go through urlFor, which requests auto=format, fit=max and quality 75. Director and showcase images are requested at fixed widths (650px and 1440px) instead of full size.
  • ChooseYourCharacter preloads director images with React's preload() so hovering a character no longer waits on a fresh image fetch.
  • The showcase carousel keeps visited and adjacent slides mounted and toggles hidden, so each image is fetched and decoded once instead of on every click.
  • Query fixes: dangling role references are filtered out, showcases are sorted by year then semester, and the landing teams query is shared between two sections.
  • Lint: enables the @tanstack/eslint-plugin-query rules in oxlint.

How did I test it?

Ran bun run lint, bun run typecheck, oxfmt --check and bun run build on this branch; all pass. e2e and manual browser testing still to do.

Required checks:

  • Did you conduct a self-review?
  • Have you written unit or integration tests?

What could go wrong in the future? What parts of your code should the reviewer pay the most attention to?

  • types.gen.ts is generated. After changing a GROQ query or the Sanity schema, run bun run typegen or the types will drift.
  • staleTime: Infinity means content edited in Sanity only shows up on a full page reload.
  • The image widths in directorsQuery.ts and showcasesQuery.ts are tied to the current layouts; if those components grow, bump the widths.

Additional Comments for the Reviewers

Supersedes the isaac/image-compression branch.

Screenshots

N/A, no visual changes intended.

@Tomahawk2191
Tomahawk2191 added this pull request to stack #306 November 14, 2026 19:23
@netlify

netlify Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for generatenu-website ready!

Name Link
🔨 Latest commit 8f5cfb3
🔍 Latest deploy log https://app.netlify.com/projects/generatenu-website/deploys/6af8c6196fb055bedc9602a6
😎 Deploy Preview https://deploy-preview-301--generatenu-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@Tomahawk2191
Tomahawk2191 marked this pull request as ready for review November 14, 2026 20:27
@Tomahawk2191
Tomahawk2191 requested a review from a team as a code owner November 14, 2026 20:27
@Tomahawk2191 Tomahawk2191 changed the title refactor/sanity query layer refactor: replace useSanity with a TanStack Query layer over Sanity Nov 14, 2026

@aahiltn aahiltn left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nice

This branch has not been deployed

No deployments
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