-
-
Notifications
You must be signed in to change notification settings - Fork 38
Description
Describe the bug
The generated ensureQueryData.ts specifies Options<T, true>, which restricts the value of throwOnError to true or undefined and assumes that the query never fails.
However the default value of throwOnError is false, so in code currently generated by this tool, if it's not explicitly set by the user, causes both type (the function returns undefined while it's not meant to) and runtime (Query data cannot be undefined. Please make sure to return a value other than undefined from your query function) issues.
Potentially related to #148
To Reproduce
Generate the query code from any API schema and try to use any of the ensure* functions.
"dependencies": {
"@hey-api/client-fetch": "^0.4.3",
"@tanstack/react-query": "^5.60.2",
"@7nohe/openapi-react-query-codegen": "2.0.0-beta.3",
}Expected behavior
I think that ensure* functions should always throw an error.
Returning undefined is not supported by react-query and does not let you properly handle the failed query.