Comments (4)
This issue is similar to #379, but while that one was just a matter of lacking documentation, this one is a real bug.
from orval.
The problem seems to be that the library assumes that if the mutator is overridden, it doesn't use Axios
, therefore it doesn't add the arguments or the imports:
Here:
orval/packages/swr/src/index.ts
Lines 695 to 696 in 15e9033
And here (my use case uses split-tags, so that's how I got here):
Maybe in more places too. One possible solution would be to add a isAxios
option to the override.mutator
attribute:
module.exports = {
test: {
output: {
....
client: 'swr',
override: {
mutator: {
path: './custom-instance.ts',
name: 'customInstance',
isAxios: true // 👈 This is a fix, not sure if it's acceptable
},
...
},
},
}
}
Then we could (pseudo code):
const swrMutationFetcherOptions =
(!mutator || (mutator && override?.mutator?.isAxios)) && isRequestOptions ? 'options?: AxiosRequestConfig' : '';
hasGlobalMutator: !!output.override.mutator && !output.override.mutator.isAxios,
from orval.
I’ve encountered the same issue, and for now, I’ve downgraded to version 6.23.0.
from orval.
Thank you for made this report.
I understood that when using a custom instance of Axios
, the settings of Axios
cannot be passed to the custom instance via hooks
.
I think a good solution is to specify a custom instance using Axios
via the orvrride property and i prefer to use isAxios: true
over clinet: 'axios'
because the custom instance may have additional clients in the future.
You can submit a PR and I'll submit in turn.
from orval.
Related Issues (20)
- msw generation does not import used models HOT 1
- Mock generation doesn't guarantee the required property mocking
- Is possible ignore the changes in the line of OpenAPI spec version ? HOT 2
- Another duplicate export edge case
- Specify mock property overrides for a specific schema HOT 2
- Support replacing types with custom ones when transforming the input HOT 5
- React Query: Regression in 6.25.0 caused by #1207 HOT 5
- Is possible ignore the changes in the line of OpenAPI spec version ?
- Orval generates wrong import paths in ESM-only package HOT 3
- usePrefetch+useSuspenseQuery incorrectly generates prefetchSuspenseQuery calls
- bug: readonly fields missing from mutation function input types
- Regression when updating from 6.21 to 6.22.0 HOT 2
- Add a react-query default mutationKey that is the name of the mutation function (e.g. useCreateUser)
- allOf with nullable: true does not generate nullable type
- type: 'null' generates invalid zod client
- `target="es6"` or newer in `tsconfig.json` results in `Your mutator file doesn't have the default exported function` HOT 2
- Unknown error type when using duplicate reference
- Vue: variable for path parameter was converted wrong
- Is it possible to disable mock generation for a specific endpoint? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from orval.