Skip to content

fix(solid-query): fetch queries on status-only reads#10769

Open
raashish1601 wants to merge 2 commits into
TanStack:mainfrom
raashish1601:codex/10751-solid-query-curry-resource
Open

fix(solid-query): fetch queries on status-only reads#10769
raashish1601 wants to merge 2 commits into
TanStack:mainfrom
raashish1601:codex/10751-solid-query-curry-resource

Conversation

@raashish1601
Copy link
Copy Markdown
Contributor

@raashish1601 raashish1601 commented May 24, 2026

Fixes #10751

Summary

  • start the Solid query resource when derived status fields are read, so status-only consumers still subscribe and fetch on mount
  • keep error, failureReason, refetch, and promise reads from eagerly touching the resource to preserve error-boundary behavior
  • add regression coverage for curried queryOptions used with isPending / isError / isSuccess
  • add a patch changeset for @tanstack/solid-query

Tests

  • corepack pnpm --filter @tanstack/solid-query exec vitest run --config vitest.local.config.ts src/__tests__/useQuery.test.tsx using a temporary local copy of the package config with solid({ hot: false }); the default Windows run fails before imports with file:///@solid-refresh
  • corepack pnpm exec prettier --check .changeset/solid-query-status-resource.md packages/solid-query/src/useBaseQuery.ts packages/solid-query/src/__tests__/useQuery.test.tsx
  • corepack pnpm exec eslint --concurrency=auto -c eslint.config.js packages/solid-query/src/useBaseQuery.ts packages/solid-query/src/__tests__/useQuery.test.tsx
  • corepack pnpm --filter @tanstack/solid-query build
  • git diff --check

Local script note: corepack pnpm --filter @tanstack/solid-query test:eslint and test:types:tscurrent fail on this Windows checkout before reaching source files because checked-in symlink placeholders such as packages/solid-query/root.eslint.config.js are materialized as plain text (../../eslint.config.js).

Summary by CodeRabbit

  • Bug Fixes
    • Resources now initialize when status-only fields (e.g., pending/error/success flags) are read, preventing missing fetches for components that don't access data directly.
  • Tests
    • Added coverage verifying status-only and resource-only consumers trigger a single fetch and transition to success.
  • Documentation
    • Patch release note describing the behavior change for Solid Query resources.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1ffbdf6b-1769-40a0-bc66-2ba5eb8dccca

📥 Commits

Reviewing files that changed from the base of the PR and between c245a7d and 597b668.

📒 Files selected for processing (2)
  • packages/solid-query/src/__tests__/useQuery.test.tsx
  • packages/solid-query/src/useBaseQuery.ts

📝 Walkthrough

Walkthrough

Reading status or resource-related properties (e.g., isPending, isError, error, promise) now forces a Solid resource read so the observer subscription and fetch start even when data is never accessed.

Changes

Status-Triggered Resource Initialization

Layer / File(s) Summary
Status field resource tracking in useBaseQuery
packages/solid-query/src/useBaseQuery.ts
Defines resourceTrackingProps with status/resource property names and updates the proxy get handler to call queryResource() when these properties are accessed, starting the observer and fetch.
Test coverage for curried queryOptions status access
packages/solid-query/src/__tests__/useQuery.test.tsx
Imports queryOptions and adds tests that assert a single fetch occurs on mount when components only read status-like fields or perform void reads of resource/error fields using curried queryOptions.
Release notes for status-triggered resource behavior
.changeset/solid-query-status-resource.md
Adds a patch changeset documenting that Solid query resources now start when status fields are read, allowing curried queryOptions to fetch on mount without accessing data.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • chughgaurav
  • TkDodo

Poem

🐇 I nibbled a status, a quiet little clue,
A whisker-twitch peek and the fetching says "whoo!"
No more waiting for data to be spied,
A hop, a puff — the resource wakes inside. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: fixing SolidJS query fetching when only status fields are read, which is the core objective of this PR.
Description check ✅ Passed The description is substantially complete, covering changes, test coverage, and the underlying issue, though it deviates from the template's structured format with optional sections.
Linked Issues check ✅ Passed The PR directly addresses issue #10751 by ensuring queries start when status fields are read, which was the primary bug preventing curried queryOptions from working correctly.
Out of Scope Changes check ✅ Passed All changes are within scope: implementation fix in useBaseQuery.ts, regression tests in useQuery.test.tsx, and changeset documentation, all addressing the curried queryOptions reactivity bug.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Copy Markdown
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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/solid-query/src/useBaseQuery.ts`:
- Around line 102-124: resourceTrackingProps currently omits the query fields
that should trigger subscription/fetch (so reading them won’t call queryResource
via the Proxy): update the Set resourceTrackingProps to include 'error',
'failureReason', 'refetch', and 'promise' so the Proxy's has-check
(resourceTrackingProps.has(prop)) and the queryResource() call will run when
those properties are read; locate the Set declaration named
resourceTrackingProps and add those four PropertyKey strings to it to restore
mount-time subscription/fetch behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4cc9a6de-4e46-4d17-a1ab-29947986f752

📥 Commits

Reviewing files that changed from the base of the PR and between ba6e7be and c245a7d.

📒 Files selected for processing (3)
  • .changeset/solid-query-status-resource.md
  • packages/solid-query/src/__tests__/useQuery.test.tsx
  • packages/solid-query/src/useBaseQuery.ts

Comment thread packages/solid-query/src/useBaseQuery.ts
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.

queryOptions built via currying breaks SolidJS' Reactivity

1 participant