fix(tanstack-query): default enabled option not working#840
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe changes update the handling of the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant ProcedureUtils
participant QueryOptions
Caller->>ProcedureUtils: call queryOptions({ input })
ProcedureUtils->>QueryOptions: create options object
alt input === skipToken
QueryOptions-->>Caller: options.enabled = false
else
QueryOptions-->>Caller: options.enabled = undefined
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Possibly related PRs
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (16)
🧰 Additional context used🧬 Code Graph Analysis (1)packages/vue-query/src/procedure-utils.ts (1)
⏰ 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). (4)
🔇 Additional comments (26)
✨ Finishing Touches
🧪 Generate 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where the default enabled option was not working correctly in tanstack-query. The fix involves changing the enabled property from requiring a boolean value to allowing boolean | undefined in type definitions, and updating the logic to return undefined instead of true when input is not a skipToken.
- Updates type definitions to allow
undefinedas a valid value for theenabledproperty - Changes enabled logic from
input !== skipTokentoinput === skipToken ? false : undefined - Updates all corresponding test expectations to match the new behavior
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/vue-query/src/types.ts | Updates type definitions to allow enabled: ComputedRef<boolean | undefined> |
| packages/vue-query/src/procedure-utils.ts | Changes enabled logic to return undefined instead of true for non-skipToken inputs |
| packages/vue-query/src/procedure-utils.test.ts | Updates test expectations from true to undefined |
| packages/tanstack-query/src/types.ts | Updates type definitions to allow enabled: boolean | undefined |
| packages/tanstack-query/src/procedure-utils.ts | Changes enabled logic to return undefined instead of true for non-skipToken inputs |
| packages/tanstack-query/src/procedure-utils.test.ts | Updates test expectations from true to undefined |
| packages/tanstack-query/src/procedure-utils.test-d.ts | Updates TypeScript type tests to expect boolean | undefined |
| packages/svelte-query/src/types.ts | Updates type definitions to allow enabled: boolean | undefined |
| packages/svelte-query/src/procedure-utils.ts | Changes enabled logic to return undefined instead of true for non-skipToken inputs |
| packages/svelte-query/src/procedure-utils.test.tsx | Updates test expectations from true to undefined |
| packages/solid-query/src/types.ts | Updates type definitions to allow enabled: boolean | undefined |
| packages/solid-query/src/procedure-utils.ts | Changes enabled logic to return undefined instead of true for non-skipToken inputs |
| packages/solid-query/src/procedure-utils.test.ts | Updates test expectations from true to undefined |
| packages/react-query/src/types.ts | Updates type definitions to allow enabled: boolean | undefined |
| packages/react-query/src/procedure-utils.ts | Changes enabled logic to return undefined instead of true for non-skipToken inputs |
| packages/react-query/src/procedure-utils.test.ts | Updates test expectations from true to undefined |
There was a problem hiding this comment.
Summary of Changes
Hello @unnoq, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request addresses an issue where the enabled option in TanStack Query was not behaving as expected, specifically regarding its default value. My changes ensure that when skipToken is used, enabled is explicitly false, and otherwise, it defaults to undefined. This aligns the behavior with how TanStack Query typically handles default enabled states, providing a more consistent and predictable experience across the various framework integrations.
Highlights
- Corrected 'enabled' option logic: I've corrected the logic for the
enabledproperty withinprocedure-utils.tsfiles across multiple packages (react-query,solid-query,svelte-query,tanstack-query, andvue-query). Previously,enabledwas implicitly set totruewhenskipTokenwas not used. Now, it explicitly defaults toundefinedin such cases, aligning with the expected behavior of TanStack Query. - Updated 'enabled' type definition: To accommodate the new default behavior, I've updated the type definition of the
enabledproperty in the respectivetypes.tsfiles. It now correctly allows forundefinedin addition toboolean. - Synchronized test expectations: I've adjusted the test expectations in
procedure-utils.test.tsandprocedure-utils.test-d.tsfiles. Tests now correctly assert thatoptions.enabledisundefinedwhenskipTokenis not present, reflecting the changes in the core logic.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request fixes an issue with the enabled option in query utilities not respecting user-provided values or TanStack Query defaults. The change to return undefined instead of true for the enabled property when a query is not explicitly disabled is correct and aligns with TanStack Query's behavior. The fix has been applied consistently across all packages, and the corresponding type definitions and tests have been updated accordingly. Overall, this is a solid fix. I've added one suggestion to improve maintainability by reducing some code duplication.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
More templates
@orpc/arktype
@orpc/client
@orpc/contract
@orpc/experimental-durable-event-iterator
@orpc/hey-api
@orpc/json-schema
@orpc/nest
@orpc/openapi
@orpc/openapi-client
@orpc/react
@orpc/react-query
@orpc/server
@orpc/shared
@orpc/solid-query
@orpc/standard-server
@orpc/standard-server-aws-lambda
@orpc/standard-server-fetch
@orpc/standard-server-node
@orpc/standard-server-peer
@orpc/svelte-query
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/vue-colada
@orpc/vue-query
@orpc/zod
commit: |
Summary by CodeRabbit
enabledproperty tofalsewhen usingskipToken, and toundefinedotherwise.enabledproperty can now bebooleanorundefinedinstead of strictlyboolean.enabledasundefined(instead oftrue) when not usingskipToken.