chore: update svelte examples and tests from runes PR #9692
main fromrefs/pull/9692/head·merged by lachlancollins View on GitHub🎯 Changes#
Takes some of the changes from the svelte runes adapter branch and applies them here
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested this code locally with
pnpm test:pr.
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
Summary by CodeRabbit#
Documentation
- Corrected Devtools option type to primitive boolean across React, Solid, Svelte, and Vue docs.
- Updated Svelte reactivity examples to use a relative /api/data endpoint.
Chores
- Svelte examples now use relative API paths; add mutation encodes parameters; header shows current interval; SSR layout simplified to synchronous load.
Style
- Removed extraneous comments/blank lines in Svelte example configs; minor formatting cleanups.
Tests
- Adjusted Svelte Query tests and fixtures to match updated UI output and defaults.
- 1
Walkthrough#
Documentation updates change initialIsOpen type annotations from Boolean to boolean across frameworks. Svelte docs/examples switch API endpoints to relative paths. Several Svelte example configs have comment/whitespace cleanup. One SSR load function becomes synchronous. Tests adjust output and expectations for mutation failure reason and mutation state rendering.
Changes#
Cohort / File(s) Summary Docs: Devtools type annotation (Boolean → boolean) docs/framework/react/devtools.md,docs/framework/solid/devtools.md,docs/framework/svelte/devtools.md,docs/framework/vue/devtools.mdUpdate initialIsOpen type from Boolean to boolean in docs; no runtime/control-flow changes. Docs: Svelte reactivity endpoint docs/framework/svelte/reactivity.mdReplace fetch target from hardcoded http://localhost:5173/... to relative /api/data; remove local endpoint constant where applicable.Examples: Svelte endpoint and UI tweaks examples/svelte/auto-refetching/src/routes/+page.svelte,examples/svelte/optimistic-updates/src/routes/+page.svelte,examples/svelte/ssr/src/routes/+layout.ts,examples/svelte/star-wars/src/routes/+page.svelte,examples/svelte/optimistic-updates/src/routes/api/data/+server.tsUse relative API paths; encode query param in add mutation; dynamic header text; make SSR load sync (remove async); minor formatting; change array type syntax (Todo[] → Array). Examples: Svelte config whitespace/comments cleanup examples/svelte/auto-refetching/svelte.config.js,examples/svelte/basic/svelte.config.js,examples/svelte/optimistic-updates/svelte.config.js,examples/svelte/playground/svelte.config.js,examples/svelte/simple/svelte.config.js,examples/svelte/ssr/svelte.config.js,examples/svelte/star-wars/svelte.config.jsRemove comment lines and extra blank lines; no behavioral/config changes. Tests: createMutation failure display packages/svelte-query/tests/createMutation/FailureExample.svelte,packages/svelte-query/tests/createMutation/createMutation.test.tsUI: show raw failureCount; change failureReason fallback to 'undefined'. Tests updated to expect "undefined" for failure reason. Tests: useMutationState UI and expectations packages/svelte-query/tests/useMutationState/BaseExample.svelte,packages/svelte-query/tests/useMutationState/useMutationState.test.tsReplace reactive derived display with inline JSON of statuses; add Success/Error buttons. Tests now click by role and assert "Data: [...]" strings, including filtered cases. Sequence Diagram(s)#
sequenceDiagram autonumber participant User as User participant SvelteSSR as +layout.ts (SSR) participant QueryClient as QueryClient User->>SvelteSSR: Request page Note over SvelteSSR: Synchronous load() returns data SvelteSSR->>QueryClient: new QueryClient() SvelteSSR-->>User: { queryClient }Estimated code review effort#
🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs#
- TanStack/query#9630 — Touches the same Svelte test component (FailureExample.svelte); likely related adjustments to displayed fields/object shorthand in createMutation tests.
Suggested labels#
package: svelte-query,documentationPoem#
A nibble of docs, a hop through tests, I twitch my whiskers at boolean quests. Endpoints now near, no localhost fear, SSR sprints—sync speed, so clear. Mutations confess what they’ve undefined, Carrots counted, states aligned. Thump! Release time—changes refined.
Pre-merge checks and finishing touches#
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution Title Check ⚠️ Warning The title only mentions updating Svelte examples and tests from a “runes PR,” which is a vague internal reference that does not convey specific changes to other frameworks or documentation. It omits significant documentation updates such as type annotation changes across multiple framework docs and endpoint adjustments in the Svelte reactivity guide. As a result, it fails to capture the full scope and primary purpose of the changeset. Please update the title to succinctly reflect the main changes made in this pull request, including documentation type annotation updates and endpoint standardizations alongside Svelte examples and tests. Remove the ambiguous “runes PR” reference to improve clarity. A more descriptive title will help teammates quickly understand the scope of the changes without scanning the full diff. Description Check ⚠️ Warning Although the pull request description follows the required template, the “## 🎯 Changes” section is overly generic and does not detail which modifications are applied or the motivation behind them. It simply states that changes from the Svelte runes adapter branch are included without specifying the actual updates. This lack of specificity makes it difficult for reviewers to understand the scope of the changes at a glance. Please expand the “## 🎯 Changes” section to include a clear summary of the specific updates such as boolean type annotation adjustments in documentation, fetch endpoint standardization, Svelte example refactoring, and test expectation updates. Briefly explain the motivation for each change to give reviewers context. This will ensure the description is informative and adheres to the repository’s contribution guidelines. ✅ Passed checks (1 passed)
Check name Status Explanation Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped. ✨ Finishing touches
- 📝 Generate Docstrings
🧪 Generate unit tests
- Create PR with unit tests
- Post copyable unit tests in a comment
- Commit unit tests in branch `tweak-svelte-tests`
Comment `@coderabbitai help` to get the list of available commands and usage tips.github-actions[bot](GitHub profile, opens in a new tab) added labelsdocumentation
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: svelte-query
View your CI Pipeline Execution ↗ for commit 8f45f04866e50106e4085d78a255f020d6a5d75e
Command Status Duration Result nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded 42s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 1s View ↗
☁️ Nx Cloud last updated this comment at
2025-09-26 12:48:04UTCMore templates
- @tanstack/query-example-angular-auto-refetching
- @tanstack/query-example-angular-basic
- @tanstack/query-example-angular-basic-persister
- @tanstack/query-example-angular-devtools-panel
- @tanstack/query-example-angular-infinite-query-with-max-pages
- @tanstack/query-example-angular-optimistic-updates
- @tanstack/query-example-angular-pagination
- @tanstack/query-example-angular-query-options-from-a-service
- @tanstack/query-example-angular-router
- @tanstack/query-example-angular-rxjs
- @tanstack/query-example-angular-simple
- @tanstack/query-example-react-algolia
- @tanstack/query-example-react-auto-refetching
- @tanstack/query-example-react-basic
- @tanstack/query-example-react-basic-graphql-request
- @tanstack/query-example-chat
- @tanstack/query-example-react-default-query-function
- @tanstack/query-example-react-devtools-panel
- @tanstack/query-example-eslint-legacy
- @tanstack/query-example-react-infinite-query-with-max-pages
- @tanstack/query-example-react-load-more-infinite-scroll
- @tanstack/query-example-react-nextjs
- @tanstack/query-example-react-nextjs-app-prefetching
- @tanstack/query-example-nextjs-suspense-streaming
- @tanstack/query-example-react-offline
- @tanstack/query-example-react-optimistic-updates-cache
- @tanstack/query-example-react-optimistic-updates-ui
- @tanstack/query-example-react-pagination
- @tanstack/query-example-react-playground
- @tanstack/query-example-react-prefetching
- @tanstack/query-example-react-react-native
- @tanstack/query-example-react-router
- @tanstack/query-example-react-rick-morty
- @tanstack/query-example-react-shadow-dom
- @tanstack/query-example-react-simple
- @tanstack/query-example-react-star-wars
- @tanstack/query-example-react-suspense
- @tanstack/query-example-solid-astro
- @tanstack/query-example-solid-basic
- @tanstack/query-example-solid-basic-graphql-request
- @tanstack/query-example-solid-default-query-function
- @tanstack/query-example-solid-simple
- @tanstack/query-example-solid-start-streaming
- @tanstack/query-example-svelte-auto-refetching
- @tanstack/query-example-svelte-basic
- @tanstack/query-example-svelte-load-more-infinite-scroll
- @tanstack/query-example-svelte-optimistic-updates
- @tanstack/query-example-svelte-playground
- @tanstack/query-example-svelte-simple
- @tanstack/query-example-svelte-ssr
- @tanstack/query-example-svelte-star-wars
- @tanstack/query-example-vue-2.6-basic
- @tanstack/query-example-vue-2.7-basic
- @tanstack/query-example-vue-basic
- @tanstack/query-example-vue-dependent-queries
- @tanstack/query-example-vue-nuxt3
- @tanstack/query-example-vue-persister
- @tanstack/query-example-vue-simple
@tanstack/angular-query-experimental
npm i https://pkg.pr.new/@tanstack/angular-query-experimental@9692@tanstack/eslint-plugin-query
npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@9692@tanstack/query-async-storage-persister
npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@9692@tanstack/query-broadcast-client-experimental
npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@9692@tanstack/query-core
npm i https://pkg.pr.new/@tanstack/query-core@9692@tanstack/query-devtools
npm i https://pkg.pr.new/@tanstack/query-devtools@9692@tanstack/query-persist-client-core
npm i https://pkg.pr.new/@tanstack/query-persist-client-core@9692@tanstack/query-sync-storage-persister
npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@9692@tanstack/react-query
npm i https://pkg.pr.new/@tanstack/react-query@9692@tanstack/react-query-devtools
npm i https://pkg.pr.new/@tanstack/react-query-devtools@9692@tanstack/react-query-next-experimental
npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@9692@tanstack/react-query-persist-client
npm i https://pkg.pr.new/@tanstack/react-query-persist-client@9692@tanstack/solid-query
npm i https://pkg.pr.new/@tanstack/solid-query@9692@tanstack/solid-query-devtools
npm i https://pkg.pr.new/@tanstack/solid-query-devtools@9692@tanstack/solid-query-persist-client
npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@9692@tanstack/svelte-query
npm i https://pkg.pr.new/@tanstack/svelte-query@9692@tanstack/svelte-query-devtools
npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@9692@tanstack/svelte-query-persist-client
npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@9692@tanstack/vue-query
npm i https://pkg.pr.new/@tanstack/vue-query@9692@tanstack/vue-query-devtools
npm i https://pkg.pr.new/@tanstack/vue-query-devtools@9692commit:
8f45f04Codecov Report#
:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 89.20%. Comparing base (
db60bdd) to head (8f45f04). :warning: Report is 1 commits behind head on main.Additional details and impacted files
@@ Coverage Diff @@ ## main #9692 +/- ## =========================================== + Coverage 46.38% 89.20% +42.82% =========================================== Files 214 18 -196 Lines 8488 176 -8312 Branches 1927 31 -1896 =========================================== - Hits 3937 157 -3780 + Misses 4108 18 -4090 + Partials 443 1 -442Components Coverage Δ @tanstack/angular-query-experimental ∅ <ø> (∅)@tanstack/eslint-plugin-query ∅ <ø> (∅)@tanstack/query-async-storage-persister ∅ <ø> (∅)@tanstack/query-broadcast-client-experimental ∅ <ø> (∅)@tanstack/query-codemods ∅ <ø> (∅)@tanstack/query-core ∅ <ø> (∅)@tanstack/query-devtools ∅ <ø> (∅)@tanstack/query-persist-client-core ∅ <ø> (∅)@tanstack/query-sync-storage-persister ∅ <ø> (∅)@tanstack/query-test-utils ∅ <ø> (∅)@tanstack/react-query ∅ <ø> (∅)@tanstack/react-query-devtools ∅ <ø> (∅)@tanstack/react-query-next-experimental ∅ <ø> (∅)@tanstack/react-query-persist-client ∅ <ø> (∅)@tanstack/solid-query ∅ <ø> (∅)@tanstack/solid-query-devtools ∅ <ø> (∅)@tanstack/solid-query-persist-client ∅ <ø> (∅)@tanstack/svelte-query 87.58% <ø> (ø)@tanstack/svelte-query-devtools ∅ <ø> (∅)@tanstack/svelte-query-persist-client 100.00% <ø> (ø)@tanstack/vue-query ∅ <ø> (∅)@tanstack/vue-query-devtools ∅ <ø> (∅):rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Actionable comments posted: 0
🧹 Nitpick comments (5)
packages/svelte-query/tests/useMutationState/BaseExample.svelte (2)
26-27: Confirm calling mutate on the store value ($store) vs the store objectTypical Svelte Query usage is
successMutation.mutate()(no$), while$successMutationis usually the state value. If methods are exposed on the store object (not the value), the current calls might fail. If intentional in this branch, ignore; otherwise, prefer the non-$form to avoid unnecessary subscriptions in handlers.Apply if appropriate:
-<button on:click={() => $successMutation.mutate()}>Success</button> -<button on:click={() => $errorMutation.mutate()}>Error</button> +<button on:click={() => successMutation.mutate()}>Success</button> +<button on:click={() => errorMutation.mutate()}>Error</button>
29-31: Stabilize selector surface for tests (optional)Relying on the literal "Data: ..." string couples tests to UI copy. Consider a test id to decouple formatting.
-<div> - Data: {JSON.stringify($mutationState.map((state) => state.status))} -</div> +<div data-testid="mutation-state"> + {JSON.stringify($mutationState.map((state) => state.status))} +</div>If adopted, update tests to assert via
getByTestId('mutation-state').packages/svelte-query/tests/useMutationState/useMutationState.test.ts (3)
36-45: Good a11y query upgrade; consider async assertions to reduce flakinessSwitch to
getByRoleis solid. For DOM updates driven by timers and promises,findByTextis more robust thangetByText.-expect(rendered.getByText('Data: ["success"]')).toBeInTheDocument() +await rendered.findByText('Data: ["success"]') ... -expect(rendered.getByText('Data: ["success","error"]')).toBeInTheDocument() +await rendered.findByText('Data: ["success","error"]')Also, verify that the ordering from
useMutationStateis deterministic so the array order assertion won’t flake.
71-80: Filter test reads well; prefer async query for stabilityUse
findByTextto await DOM updates post timers.-expect(rendered.getByText('Data: []')).toBeInTheDocument() +await rendered.findByText('Data: []') ... -expect(rendered.getByText('Data: ["error"]')).toBeInTheDocument() +await rendered.findByText('Data: ["error"]')
106-115: Key-filter test is clear; use async assertionsSame async assertion tweak to avoid timing flakes.
-expect(rendered.getByText('Data: ["success"]')).toBeInTheDocument() +await rendered.findByText('Data: ["success"]') ... -expect(rendered.getByText('Data: ["success"]')).toBeInTheDocument() +await rendered.findByText('Data: ["success"]')📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between db60bddc961df287b4ea4d628c84fe27b07fbbff and 8f45f04866e50106e4085d78a255f020d6a5d75e.
📒 Files selected for processing (21)
docs/framework/react/devtools.md(1 hunks)docs/framework/solid/devtools.md(1 hunks)docs/framework/svelte/devtools.md(1 hunks)docs/framework/svelte/reactivity.md(2 hunks)docs/framework/vue/devtools.md(1 hunks)examples/svelte/auto-refetching/src/routes/+page.svelte(3 hunks)examples/svelte/auto-refetching/svelte.config.js(0 hunks)examples/svelte/basic/svelte.config.js(0 hunks)examples/svelte/optimistic-updates/src/routes/+page.svelte(1 hunks)examples/svelte/optimistic-updates/src/routes/api/data/+server.ts(1 hunks)examples/svelte/optimistic-updates/svelte.config.js(0 hunks)examples/svelte/playground/svelte.config.js(0 hunks)examples/svelte/simple/svelte.config.js(0 hunks)examples/svelte/ssr/src/routes/+layout.ts(1 hunks)examples/svelte/ssr/svelte.config.js(0 hunks)examples/svelte/star-wars/src/routes/+page.svelte(1 hunks)examples/svelte/star-wars/svelte.config.js(0 hunks)packages/svelte-query/tests/createMutation/FailureExample.svelte(1 hunks)packages/svelte-query/tests/createMutation/createMutation.test.ts(1 hunks)packages/svelte-query/tests/useMutationState/BaseExample.svelte(1 hunks)packages/svelte-query/tests/useMutationState/useMutationState.test.ts(3 hunks)
💤 Files with no reviewable changes (7)
- examples/svelte/star-wars/svelte.config.js
- examples/svelte/optimistic-updates/svelte.config.js
- examples/svelte/playground/svelte.config.js
- examples/svelte/simple/svelte.config.js
- examples/svelte/ssr/svelte.config.js
- examples/svelte/basic/svelte.config.js
- examples/svelte/auto-refetching/svelte.config.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Preview
- GitHub Check: Test
🔇 Additional comments (12)
examples/svelte/star-wars/src/routes/+page.svelte (1)
5-5: Formatting tweak looks goodInline closing parenthesis improves readability without altering behavior.
examples/svelte/ssr/src/routes/+layout.ts (1)
5-16: Synchronous load is appropriate here.Dropping
asynckeeps the signature valid and avoids needless promise wrapping since the body does not await anything.docs/framework/solid/devtools.md (1)
71-71: Primitivebooleanmatches TS conventionsGood call switching the docs to the lowercase primitive type; it aligns with TypeScript usage and the other framework docs.
docs/framework/react/devtools.md (1)
77-77: Consistent primitive type annotationThe lowercase
booleanis the correct TypeScript primitive and keeps this options list consistent across the docs.docs/framework/vue/devtools.md (1)
64-64: Vue docs now mirror the TS primitiveThanks for updating this to
boolean; it matches the actual prop typing and the rest of the documentation.docs/framework/svelte/devtools.md (1)
64-64: Svelte options reflect the right boolean typeLowercase
booleanis the right primitive and keeps parity with the other framework docs.examples/svelte/optimistic-updates/src/routes/api/data/+server.ts (1)
9-9: Type alias tweak looks goodArray<Todo>maintains identical semantics to the previousTodo[], so no runtime impact. 👍examples/svelte/optimistic-updates/src/routes/+page.svelte (1)
23-37: Relative endpoint improves portabilitySwitching to the relative
/api/datakeeps local/dev parity while avoiding hard-coded hostnames. All fetching logic still lines up with the server route.packages/svelte-query/tests/createMutation/createMutation.test.ts (1)
89-97: Expectation aligns with updated fallback renderingFailureExample.sveltenow renders the nullish failure reason as the literal stringundefined, so this revised assertion keeps the test in sync with the component output.packages/svelte-query/tests/createMutation/FailureExample.svelte (1)
22-23: Rendering tweak matches mutation state semanticsDisplaying the raw
failureCountand falling back to the string'undefined'for a nullishfailureReasonmirrors TanStack Query’s mutation state, so the UI now reflects the state machine more precisely and stays consistent with the updated test.examples/svelte/auto-refetching/src/routes/+page.svelte (1)
23-26: Great call hardening the mutation URL.Using
encodeURIComponentbefore interpolating user input into the fetch query string prevents accidental breakage (and avoids surprise characters in the request). Nicely done keeping the rest of the chain untouched.docs/framework/svelte/reactivity.md (1)
18-39: Docs update looks solid.Switching the snippets to the shared
/api/dataendpoint keeps the walkthrough aligned with the updated example and avoids localhost-only assumptions.lachlancollins merged this89be189
lachlancollins closed this
Sign in to join this conversation.
⚠️ No Changeset found#
Latest commit: 8f45f04866e50106e4085d78a255f020d6a5d75e
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR