-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
QueryError
andFetchFn
to the exports from thecommon
module 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
QueryError
andFetchFn
in theruntime-v5
directory 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
FetchFn
and relying on the export from thecommon
module is a good practice for centralizing fetch functionality, enhancing maintainability and reusability across the plugin.- 113-124: The updates to the
useModelMutation
function signature, including the addition ofTArgs
andTError
type parameters and adjustments to theoptions
parameter, 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
QueryError
type is a significant improvement for error handling. It extends the standardError
class 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
fetcher
function to utilize the newly introducedQueryError
type for error handling is correctly implemented. By assigningerrData.error
to theinfo
property and the response status to thestatus
property of theQueryError
, it ensures that errors thrown by thefetcher
function are informative and consistent with the new error handling approach.packages/plugins/tanstack-query/src/generator.ts (2)
- 568-568: The import of the
QueryError
type is correctly added. This import is necessary for the file to useQueryError
in type annotations and assignments, aligning with the broader changes in the plugin to enhance error typing.- 570-570: Changing the
DefaultError
type assignment toQueryError
is a logical step following the introduction of theQueryError
type. 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
QueryError
for improved error handling across the application.UseSuspenseInfiniteQueryOptions
andUseSuspenseQueryOptions
for enhanced query capabilities in React.Refactor
useModelMutation
function signatures in React, Svelte, and Vue to support additional type parameters and options for better flexibility.QueryError
type usage.FetchFn
type across different frameworks for consistency.Chores