Skip to content

Conversation

@CapitaineToinon
Copy link
Contributor

@CapitaineToinon CapitaineToinon commented Oct 15, 2025

🎯 Changes

This PR fixes #9762. The fix was simple, the queryClient passed as a prop should be forwarded to the useQueryClient hooks. I've also added simple rendering tests for SolidQueryClient and SolidQueryClientPanel

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run 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

  • Bug Fixes

    • DevTools and Panel now consistently honor an explicitly provided client, fixing prior fallback behavior and improving reliability.
    • More deterministic error behavior when no client is available.
  • Tests

    • Added unit tests validating client provisioning via props, context, and missing-client scenarios.
  • Chores

    • Added test setup, vitest configuration, coverage reporting, and new test scripts to streamline testing.
@changeset-bot
Copy link

changeset-bot bot commented Oct 15, 2025

🦋 Changeset detected

Latest commit: 1c060af

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tanstack/solid-query-devtools Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 15, 2025

Walkthrough

Updates Solid Query Devtools to accept an optional client prop in hooks, derive the internal client from that resolved value, add unit tests for client provisioning, introduce Vitest test setup/config, and add test scripts and a testing devDependency.

Changes

Cohort / File(s) Summary
Devtools client resolution
packages/solid-query-devtools/src/devtools.tsx, packages/solid-query-devtools/src/devtoolsPanel.tsx
Call useQueryClient(props.client) and change memoization to derive the exposed client solely from the resolved queryClient (remove previous fallback logic).
Unit tests
packages/solid-query-devtools/src/__tests__/*
Add tests asserting error when no QueryClient is present and no error when a QueryClient is provided via context or via the client prop for both Devtools and DevtoolsPanel.
Test setup & tooling
packages/solid-query-devtools/test-setup.ts, packages/solid-query-devtools/vite.config.ts, packages/solid-query-devtools/package.json
Add Vitest configuration (jsdom env, setup file, coverage, type check), register Solid testing cleanup in test-setup.ts, add test:lib and test:lib:dev scripts, and add @solidjs/testing-library devDependency.
Release metadata
.changeset/breezy-cobras-sniff.md
Add changeset noting a patch release: "Fixed client prop not working on SolidQueryDevtools and SolidQueryDevtoolsPanel".

Sequence Diagram(s)

sequenceDiagram autonumber actor App participant Devtools as SolidQueryDevtools participant Hook as useQueryClient participant Ctx as QueryClientProvider participant Panel as TanStack Devtools Panel App->>Devtools: render({ client? }) Devtools->>Hook: useQueryClient(props.client) alt client prop provided Hook-->>Devtools: return props.client else context provides client Hook->>Ctx: read context Ctx-->>Hook: return context client Hook-->>Devtools: client from context else none available Hook-->>Devtools: throw "No QueryClient" Devtools-->>App: render error end Devtools->>Panel: render({ client }) Panel-->>App: mounted 
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

package: query-devtools

Poem

A hop, a bop, I pass the client right,
No more trips in context’s night.
Tests nibble bugs till they’re small crumbs,
Vitest hums while the rabbit strums.
Devtools shine — a joyful bite! 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "fix: solid-query-devtools and panel query client" is fully related to the main change in the changeset. The title accurately reflects the core fix: forwarding the queryClient prop to the useQueryClient hooks in both SolidQueryDevtools and SolidQueryDevtoolsPanel components, enabling them to work outside a Query context. The title is concise, specific, and clearly summarizes the primary change from the developer's perspective.
Linked Issues Check ✅ Passed The pull request successfully addresses all requirements from the linked issue #9762. The core fix involves changing both devtools.tsx and devtoolsPanel.tsx from using useQueryClient() to useQueryClient(props.client), which forwards the client prop to enable the devtools to function outside a Query context. Additionally, unit tests were added to verify that the components handle QueryClient provisioning correctly through props and context, and a changeset was generated to document the fix in the release notes. All coding requirements from the linked issue are fulfilled.
Out of Scope Changes Check ✅ Passed All changes in this pull request are directly related to fixing issue #9762 and supporting that fix through testing infrastructure. The modifications to devtools.tsx and devtoolsPanel.tsx implement the core fix, while the new test files and configuration updates (package.json, vite.config.ts, test-setup.ts) provide the necessary testing framework and unit test coverage for the changes. The changeset documents the fix for release. No out-of-scope changes are present.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/solid-query-devtools/src/devtoolsPanel.tsx (1)

45-46: Fix correctly addresses issue #9762.

The changes properly forward props.client to useQueryClient, enabling the devtools to work outside a Query context when an explicit client is provided.

One minor observation: queryClient from useQueryClient is a constant value, so wrapping it in createMemo may not provide reactivity benefits. However, this pattern could be intentional for consistency with Solid's reactive patterns or defensive coding for future changes.

Consider simplifying to use queryClient directly if the memo serves no reactive purpose:

- const queryClient = useQueryClient(props.client) - const client = createMemo(() => queryClient) + const client = useQueryClient(props.client)

Then update references from client() to client:

 const devtools = new TanstackQueryDevtoolsPanel({ - client: client(), + client: client,
 createEffect(() => { - devtools.setClient(client()) + devtools.setClient(client) })
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b59925e and a462f6c.

📒 Files selected for processing (7)
  • packages/solid-query-devtools/package.json (2 hunks)
  • packages/solid-query-devtools/src/__tests__/devtools.test.tsx (1 hunks)
  • packages/solid-query-devtools/src/__tests__/devtoolsPanel.test.tsx (1 hunks)
  • packages/solid-query-devtools/src/devtools.tsx (1 hunks)
  • packages/solid-query-devtools/src/devtoolsPanel.tsx (1 hunks)
  • packages/solid-query-devtools/test-setup.ts (1 hunks)
  • packages/solid-query-devtools/vite.config.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-02T17:57:33.184Z
Learnt from: TkDodo PR: TanStack/query#9612 File: packages/query-async-storage-persister/src/asyncThrottle.ts:0-0 Timestamp: 2025-09-02T17:57:33.184Z Learning: When importing from tanstack/query-core in other TanStack Query packages like query-async-storage-persister, a workspace dependency "tanstack/query-core": "workspace:*" needs to be added to the package.json. 

Applied to files:

  • packages/solid-query-devtools/package.json
🧬 Code graph analysis (3)
packages/solid-query-devtools/src/__tests__/devtools.test.tsx (1)
packages/solid-query-devtools/src/devtools.tsx (1)
  • SolidQueryDevtools (50-100)
packages/solid-query-devtools/vite.config.ts (1)
packages/angular-query-experimental/scripts/prepack.js (1)
  • packageJson (67-67)
packages/solid-query-devtools/src/__tests__/devtoolsPanel.test.tsx (1)
packages/solid-query-devtools/src/devtoolsPanel.tsx (1)
  • SolidQueryDevtoolsPanel (44-86)
🔇 Additional comments (1)
packages/solid-query-devtools/src/__tests__/devtoolsPanel.test.tsx (1)

7-31: Excellent test coverage for the fix.

The tests validate all three key scenarios:

  1. Error when no QueryClient is available
  2. Success when QueryClient is provided via context
  3. Success when QueryClient is provided via props (addresses issue #9762)

The test structure is clear and the coverage is appropriate for validating the devtools component behavior.

@CapitaineToinon
Copy link
Contributor Author

Hey this is my first time contributing to this repo so let me know if I've done anything wrong.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/solid-query-devtools/src/__tests__/devtoolsPanel.test.tsx (1)

6-31: LGTM! Test coverage appropriately validates the client prop forwarding fix.

The test suite correctly covers the three key scenarios for QueryClient provisioning:

  1. Error when no client is available
  2. Successful rendering with context-provided client
  3. Successful rendering with prop-provided client (the fix for issue #9762)

The suite name is now correctly singular to match the component name.

Optional improvements for test robustness:

Consider these refinements to strengthen the test suite:

  1. Add cleanup to prevent state leakage:
 it('should not throw an error if query client is provided via context', () => { const queryClient = new QueryClient() + onCleanup(() => queryClient.clear()) expect(() => render(() => ( <QueryClientProvider client={queryClient}> <SolidQueryDevtoolsPanel /> </QueryClientProvider> )), ).not.toThrow() })
  1. Assert the specific error message in line 8-10:
 it('should throw an error if no query client has been set', () => { expect(() => render(() => <SolidQueryDevtoolsPanel />)).toThrow( - 'No QueryClient set, use QueryClientProvider to set one', + /No QueryClient set/, ) })
  1. Add edge-case test for precedence when both context and prop are provided:
it('should prioritize prop client over context client', () => { const contextClient = new QueryClient() const propClient = new QueryClient() expect(() => render(() => ( <QueryClientProvider client={contextClient}> <SolidQueryDevtoolsPanel client={propClient} /> </QueryClientProvider> )), ).not.toThrow() })
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a462f6c and 1c060af.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • .changeset/breezy-cobras-sniff.md (1 hunks)
  • packages/solid-query-devtools/src/__tests__/devtoolsPanel.test.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/breezy-cobras-sniff.md
🧰 Additional context used
🧬 Code graph analysis (1)
packages/solid-query-devtools/src/__tests__/devtoolsPanel.test.tsx (1)
packages/solid-query-devtools/src/devtoolsPanel.tsx (1)
  • SolidQueryDevtoolsPanel (44-86)
@nx-cloud
Copy link

nx-cloud bot commented Oct 16, 2025

View your CI Pipeline Execution ↗ for commit 1c060af

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 1m 6s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 6s View ↗

☁️ Nx Cloud last updated this comment at 2025-10-16 10:58:41 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 16, 2025

More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@9763 

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@9763 

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@9763 

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@9763 

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@9763 

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@9763 

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@9763 

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@9763 

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@9763 

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@9763 

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@9763 

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@9763 

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@9763 

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@9763 

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@9763 

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@9763 

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@9763 

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@9763 

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@9763 

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@9763 

commit: 1c060af

@codecov
Copy link

codecov bot commented Oct 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 45.68%. Comparing base (b59925e) to head (1c060af).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@ Coverage Diff @@ ## main #9763 +/- ## ========================================== + Coverage 45.56% 45.68% +0.12%  ========================================== Files 196 200 +4 Lines 8327 8390 +63 Branches 1895 1912 +17 ========================================== + Hits 3794 3833 +39  - Misses 4091 4110 +19  - Partials 442 447 +5 
Components Coverage Δ
@tanstack/angular-query-experimental 93.85% <ø> (ø)
@tanstack/eslint-plugin-query 83.36% <ø> (ø)
@tanstack/query-async-storage-persister 43.85% <ø> (ø)
@tanstack/query-broadcast-client-experimental 24.39% <ø> (ø)
@tanstack/query-codemods 0.00% <ø> (ø)
@tanstack/query-core 97.48% <ø> (ø)
@tanstack/query-devtools 3.48% <ø> (ø)
@tanstack/query-persist-client-core 80.00% <ø> (ø)
@tanstack/query-sync-storage-persister 84.61% <ø> (ø)
@tanstack/query-test-utils 77.77% <ø> (ø)
@tanstack/react-query 96.01% <ø> (ø)
@tanstack/react-query-devtools 10.00% <ø> (ø)
@tanstack/react-query-next-experimental ∅ <ø> (∅)
@tanstack/react-query-persist-client 100.00% <ø> (ø)
@tanstack/solid-query 78.06% <ø> (ø)
@tanstack/solid-query-devtools 61.90% <100.00%> (∅)
@tanstack/solid-query-persist-client 100.00% <ø> (ø)
@tanstack/svelte-query ∅ <ø> (∅)
@tanstack/svelte-query-devtools ∅ <ø> (∅)
@tanstack/svelte-query-persist-client ∅ <ø> (∅)
@tanstack/vue-query 71.10% <ø> (ø)
@tanstack/vue-query-devtools ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
@TkDodo TkDodo merged commit 8fe3b10 into TanStack:main Oct 16, 2025
9 checks passed
This was referenced Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment