Skip to content
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

Orval does not generate abort signal as third parameter in post request. #1434

Open
wengergruppe opened this issue Jun 4, 2024 · 0 comments
Labels
enhancement New feature or request tanstack-query TanStack Query related issue

Comments

@wengergruppe
Copy link

wengergruppe commented Jun 4, 2024

What are the steps to reproduce this issue?

generateOrval({

  input: {

    target: "http://localhost:56632/swagger/v1/swagger.json",

    override: {

      transformer: (inputSchema) => {

        return {

          ...inputSchema,

 

          components: {

            ...inputSchema.components,

            schemas: Object.entries(inputSchema.components?.schemas ?? {}).reduce(

              (acc, [schemaName, schema]) => ({

                ...acc,

                [schemaName]: {

                  ...schema,

                  required:

                    "properties" in schema && !isNil(schema.properties)

                      ? Object.keys(

                          reject(

                            (property) => "nullable" in property && !!property.nullable,

                            schema.properties

                          )

                        )

                      : schema

                }

              }),

              {}

            )

          }

        }

      }

    }

  },
  output: {

    target: path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../src/openapi/web-ui"),

    mode: "tags",

    client: "react-query",

    clean: true,

    urlEncodeParameters: true,

    prettier: true,

 

    override: {

      operations: {

        PostPartyLimits: {

          query: {

            useQuery: true,

            useMutation: false,

            signal: true

          }

        }

      },

      useNativeEnums: true,

      useTypeOverInterfaces: true,

      useBigInt: true,

 

      mutator: {

        path: "./src/http/custom-axios-instance.ts",

        name: "customInstance"

      }

    }

  }

})

What happens?

postPartyLimits does not have third parameter - signal?: AbortSignal.

export const postPartyLimits = (

    partyLimitsRequest: PartyLimitsRequest,

options?: SecondParameter<typeof customInstance>,) => {

     

      

      return customInstance<PartyLimitDto[]>(

      {url: `/PartyLimits`, method: 'POST',

      headers: {'Content-Type': 'application/json', },

      data: partyLimitsRequest

    },

      options);

    }

 

 

export const getPostPartyLimitsQueryKey = (partyLimitsRequest: PartyLimitsRequest,) => {

    return [`/PartyLimits`, partyLimitsRequest] as const;

    }

 

   

export const getPostPartyLimitsQueryOptions = <TData = Awaited<ReturnType<typeof postPartyLimits>>, TError = unknown>(partyLimitsRequest: PartyLimitsRequest, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof postPartyLimits>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}

) => {

 

const {query: queryOptions, request: requestOptions} = options ?? {};

 

  const queryKey =  queryOptions?.queryKey ?? getPostPartyLimitsQueryKey(partyLimitsRequest);

 

 

 

    const queryFn: QueryFunction<Awaited<ReturnType<typeof postPartyLimits>>> = ({ signal }) => postPartyLimits(partyLimitsRequest, requestOptions, signal);

 

     

 

     

 

   return  { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof postPartyLimits>>, TError, TData> & { queryKey: QueryKey }

}

What were you expecting to happen?

export const postPartyLimits = (

    partyLimitsRequest: PartyLimitsRequest,

options?: SecondParameter<typeof customInstance>, signal?: AbortSignal) => {

     

      

      return customInstance<PartyLimitDto[]>(

      {url: `/PartyLimits`, method: 'POST',

      headers: {'Content-Type': 'application/json', },

      data: partyLimitsRequest,signal

    },

      options);

    }

Any logs, error output, etc?

Any other comments?

Looked at the code:

!isBodyVerb && hasSignal ? "signal?: AbortSignal\n" : ""

 

const isBodyVerb = import_core2.VERBS_WITH_BODY.includes(verb);

 

import_core2.VERBS_WITH_BODY in this case equals to [ 'post', 'put', 'patch', 'delete' ]

verb = "post"

Why exists this condition. I use post request as query. Why for post request has no abort signal argument.

What versions are you using?

6.29.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tanstack-query TanStack Query related issue
Projects
None yet
Development

No branches or pull requests

2 participants