-
-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(tanstack): make sure vue-query hooks' input is reactive #1185
Conversation
WalkthroughWalkthroughThe changes introduced involve enhancing the type handling and integration of Vue with the TanStack Query library. By implementing Changes
Possibly related issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (2)
- packages/plugins/tanstack-query/src/generator.ts (5 hunks)
- packages/plugins/tanstack-query/src/runtime/vue.ts (7 hunks)
Additional comments (13)
packages/plugins/tanstack-query/src/runtime/vue.ts (8)
- 8-8: Adding
QueryKey
as a type import from@tanstack/vue-query
is a good practice for ensuring type safety when working with query keys. This aligns well with the changes aimed at enhancing reactivity in Vue Query hooks.- 14-14: The addition of
MaybeRef
from Vue is crucial for the reactivity improvements in this PR. It allows the arguments and options in query hooks to be reactive, which is a significant enhancement for Vue applications using the TanStack Query library.- 64-65: Using
MaybeRef
for theargs
andoptions
parameters inuseModelQuery
is a key change that enables reactivity for these inputs. This is a critical improvement for integrating Vue's reactivity system with TanStack Query hooks.- 69-78: The use of computed properties for query options is a smart approach to ensure reactivity. It allows the options to dynamically respond to changes, leveraging Vue's reactivity system effectively. This pattern should be consistently applied across all query and mutation hooks to ensure uniform reactivity.
- 96-97: Applying
MaybeRef
to theargs
andoptions
parameters inuseInfiniteModelQuery
follows the same pattern asuseModelQuery
, ensuring consistency in handling reactivity across different types of queries. This consistency is important for the developer experience.- 100-109: The use of computed properties in
useInfiniteModelQuery
for handling query options is consistent with the approach inuseModelQuery
. This consistency in handling reactivity across query hooks is commendable and enhances the overall reactivity of the library.- 139-139: In
useModelMutation
, applyingMaybeRef
to theoptions
parameter is consistent with the changes made in query hooks. This ensures that mutation options can also benefit from Vue's reactivity system, making the library more versatile and reactive.- 167-173: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [161-181]
The use of computed properties for mutation options in
useModelMutation
is a good practice that aligns with the changes in query hooks. It ensures that mutation options are reactive, further integrating Vue's reactivity system into the library. The consistent application of this pattern across the library is beneficial for developers.packages/plugins/tanstack-query/src/generator.ts (5)
- 101-101: The introduction of
makeQueryArgsType
to dynamically determine theinputType
is a significant change. It enables the conditional wrapping of types withMaybeRef
based on the target framework, which is crucial for integrating Vue's reactivity system into the library. This function plays a pivotal role in ensuring that inputs to query hooks are reactive.- 590-590: Importing
MaybeRef
from Vue inmakeBaseImports
is essential for the changes made in this PR. It ensures thatMaybeRef
is available for use in generating query and mutation hooks, facilitating the integration of Vue's reactivity system into the library.- 612-619: The
makeQueryArgsType
function is well-implemented, providing a mechanism to conditionally wrap the type withMaybeRef
for Vue. This is a key enhancement for making inputs to query hooks reactive in Vue applications. The function's logic is clear and aligns with the objectives of the PR.- 639-641: The adjustment in
makeQueryOptions
to handleMaybeRef
for Vue is a necessary change that aligns with the overall goal of enhancing reactivity in Vue Query hooks. Wrapping the options type withMaybeRef
ensures that query options are reactive, which is a significant improvement for Vue applications.- 660-660: The update in
makeMutationOptions
to useMaybeRef
for Vue is consistent with the changes made to query options. This ensures that mutation options can also be reactive, further integrating Vue's reactivity system into the library. The consistency in handling reactivity across query and mutation hooks is commendable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- packages/plugins/tanstack-query/src/runtime/vue.ts (7 hunks)
Files skipped from review as they are similar to previous changes (1)
- packages/plugins/tanstack-query/src/runtime/vue.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- packages/plugins/tanstack-query/src/generator.ts (5 hunks)
Files skipped from review as they are similar to previous changes (1)
- packages/plugins/tanstack-query/src/generator.ts
Summary by CodeRabbit
MaybeRef
.MaybeRef
for more flexible Vue integration.