Code Monkey home page Code Monkey logo

Comments (4)

julianobrasil avatar julianobrasil commented on May 24, 2024

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.

julianobrasil avatar julianobrasil commented on May 24, 2024

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:

const swrMutationFetcherOptions =
!mutator && isRequestOptions ? 'options?: AxiosRequestConfig' : '';

And here (my use case uses split-tags, so that's how I got here):

hasGlobalMutator: !!output.override.mutator,

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.

Junlol avatar Junlol commented on May 24, 2024

I’ve encountered the same issue, and for now, I’ve downgraded to version 6.23.0.

from orval.

soartec-lab avatar soartec-lab commented on May 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.