-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
No import statements for HTTP exceptions (react-query) #1267
Comments
I managed to create temporary workaround using npm library diff --git a/node_modules/@orval/query/dist/index.js b/node_modules/@orval/query/dist/index.js
index c8621a2..66842f9 100644
--- a/node_modules/@orval/query/dist/index.js
+++ b/node_modules/@orval/query/dist/index.js
@@ -2520,6 +2520,10 @@ var generateQueryHook = async ({
...queryKeyMutator ? [queryKeyMutator] : []
] : void 0;
}
+ const exceptionImports = response.definition.errors.split('|').map(value => value.trim()).filter(value => value !== 'void' && value !== 'unknown' && value !== 'null' && value !== 'undefined');
+ if(exceptionImports.length > 0) {
+ implementation += `import { ${exceptionImports.join(', ') } } from '../../api/schemas';\n`;
+ }
let isMutation = verb !== import_core2.Verbs.GET && override.query.useMutation;
if ((operationQueryOptions == null ? void 0 : operationQueryOptions.useMutation) !== void 0) {
isMutation = operationQueryOptions.useMutation; |
Please submit a PR! |
@melloware Wouldn't that be an issue on other clients? I cannot find code responsible for generating imports inside |
If I had to guess yes it's a problem for all clients if the code is in core. |
Adding @soartec-lab for thoughts |
What are the steps to reproduce this issue?
npx orval
and config:What happens?
Orval understands there are exceptions schemas and creates them
createGroupChannel401.ts, createGroupChannel409.ts
, uses them within react-query code but does not import them from schemas directory.What were you expecting to happen?
Create import statements for exceptions.
Any logs, error output, etc?
No specific errors.
What versions are you using?
Operating System: MacOS Sonoma 14.3.1 (M3 Pro)
Package Version: 6.25.0
Browser Version: Chrome 122.0.6261.129
The text was updated successfully, but these errors were encountered: