-
-
Couldn't load subscription status.
- Fork 126
fix(tanstack): improve typing of mutation errors #1066
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
Conversation
|
Important Auto Review SkippedReview was skipped due to path filters Files ignored due to path filters (1)
WalkthroughThe updates across the TanStack Query plugin focus on enhancing error handling by introducing a new Changes
Assessment against linked 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 (9)
- packages/plugins/tanstack-query/src/generator.ts (2 hunks)
- packages/plugins/tanstack-query/src/runtime-v5/index.ts (1 hunks)
- packages/plugins/tanstack-query/src/runtime-v5/react.ts (3 hunks)
- packages/plugins/tanstack-query/src/runtime-v5/svelte.ts (2 hunks)
- packages/plugins/tanstack-query/src/runtime/common.ts (2 hunks)
- packages/plugins/tanstack-query/src/runtime/index.ts (1 hunks)
- packages/plugins/tanstack-query/src/runtime/react.ts (2 hunks)
- packages/plugins/tanstack-query/src/runtime/svelte.ts (2 hunks)
- packages/plugins/tanstack-query/src/runtime/vue.ts (3 hunks)
Additional comments: 8
packages/plugins/tanstack-query/src/runtime/index.ts (1)
- 2-2: The addition of
QueryErrorandFetchFnto the exports from thecommonmodule enhances type safety and clarity for developers working with the TanStack Query plugin. This change aligns well with the PR's objectives to improve error handling mechanisms.packages/plugins/tanstack-query/src/runtime-v5/index.ts (1)
- 2-2: Exporting
QueryErrorandFetchFnin theruntime-v5directory ensures consistency across different versions of the TanStack Query plugin, aligning with the PR's objectives to standardize error handling and fetch functionality. This is a positive change for developers seeking a consistent experience across versions.packages/plugins/tanstack-query/src/runtime/react.ts (2)
- 22-22: Removing the local import of
FetchFnand relying on the export from thecommonmodule is a good practice for centralizing fetch functionality, enhancing maintainability and reusability across the plugin.- 113-124: The updates to the
useModelMutationfunction signature, including the addition ofTArgsandTErrortype parameters and adjustments to theoptionsparameter, significantly enhance type safety and error handling capabilities. This aligns well with the PR's objectives to improve error typing and handling within the plugin.packages/plugins/tanstack-query/src/runtime/common.ts (2)
- 31-41: The introduction of the
QueryErrortype is a significant improvement for error handling. It extends the standardErrorclass with additional properties for error information (info) and HTTP status code (status). This enhancement will provide more detailed error reporting, which is beneficial for debugging and error handling in applications using the TanStack Query plugin.- 82-82: The modification to the
fetcherfunction to utilize the newly introducedQueryErrortype for error handling is correctly implemented. By assigningerrData.errorto theinfoproperty and the response status to thestatusproperty of theQueryError, it ensures that errors thrown by thefetcherfunction are informative and consistent with the new error handling approach.packages/plugins/tanstack-query/src/generator.ts (2)
- 568-568: The import of the
QueryErrortype is correctly added. This import is necessary for the file to useQueryErrorin type annotations and assignments, aligning with the broader changes in the plugin to enhance error typing.- 570-570: Changing the
DefaultErrortype assignment toQueryErroris a logical step following the introduction of theQueryErrortype. This change ensures that the default error type used throughout the plugin is nowQueryError, which provides more detailed error information. This is a positive change for consistency and improved error handling.
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 (3 hunks)
- packages/plugins/tanstack-query/src/runtime/vue.ts (3 hunks)
Files skipped from review as they are similar to previous changes (2)
- packages/plugins/tanstack-query/src/generator.ts
- packages/plugins/tanstack-query/src/runtime/vue.ts
Fixes #1062
Summary by CodeRabbit
Summary by CodeRabbit
New Features
QueryErrorfor improved error handling across the application.UseSuspenseInfiniteQueryOptionsandUseSuspenseQueryOptionsfor enhanced query capabilities in React.Refactor
useModelMutationfunction signatures in React, Svelte, and Vue to support additional type parameters and options for better flexibility.QueryErrortype usage.FetchFntype across different frameworks for consistency.Chores