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.
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
QueryKeyas a type import from@tanstack/vue-queryis 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
MaybeReffrom 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
MaybeReffor theargsandoptionsparameters inuseModelQueryis 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
MaybeRefto theargsandoptionsparameters inuseInfiniteModelQueryfollows 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
useInfiniteModelQueryfor 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, applyingMaybeRefto theoptionsparameter 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
useModelMutationis 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
makeQueryArgsTypeto dynamically determine theinputTypeis a significant change. It enables the conditional wrapping of types withMaybeRefbased 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
MaybeReffrom Vue inmakeBaseImportsis essential for the changes made in this PR. It ensures thatMaybeRefis available for use in generating query and mutation hooks, facilitating the integration of Vue's reactivity system into the library.- 612-619: The
makeQueryArgsTypefunction is well-implemented, providing a mechanism to conditionally wrap the type withMaybeReffor 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
makeQueryOptionsto handleMaybeReffor Vue is a necessary change that aligns with the overall goal of enhancing reactivity in Vue Query hooks. Wrapping the options type withMaybeRefensures that query options are reactive, which is a significant improvement for Vue applications.- 660-660: The update in
makeMutationOptionsto useMaybeReffor 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.
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.
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.MaybeReffor more flexible Vue integration.