Open ANTOSzbk opened 6 months ago
I managed to create temporary workaround using npm library patch-package
on @orval/query
, but I suppose correct patch should be applied to @orval/core
package.
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 @orval/query
and compiled @orval/core
is too hard to read
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