Skip to content

Error in Query generation #54

@Muzikanto

Description

@Muzikanto

command
yarn react-query-swagger /tanstack /post-queries-start-with-get /input:./swagger.json /output:src/api/axios-client.ts /template:Axios /minimal /serviceHost:. /use-recommended-configuration

version
react-query-swagger": "^15.12.6"

code

// use
 const userTasks = useGetAccountCardDetailsQuery({ body: userTasksBody }, {});

// types
export type GetAccountCardDetailsQueryParameters = {
  body?: Types.SearchCardDetailsRequest | undefined ;
}

// generated query
export function useGetAccountCardDetailsQuery<TSelectData = Types.AccountCardDetailsDto[], TError = unknown>(...params: any []): UseQueryResult<TSelectData, TError> {
  let options: UseQueryOptions<Types.AccountCardDetailsDto[], TError, TSelectData> | undefined = undefined;
  let axiosConfig: AxiosRequestConfig |undefined = undefined;
  let body: any = undefined;

  if (params.length > 0) {
    if (isParameterObject(params[0])) {
      // ERROR body is undefined
      ({ body,  } = params[0] as GetAccountCardDetailsQueryParameters);
      // FIX (body = params[0] as GetAccountCardDetailsQueryParameters);
      options = params[1];
      axiosConfig = params[2];
    } else {
      [body, options, axiosConfig] = params;
    }
  }

  const metaContext = useContext(QueryMetaContext);
  options = addMetaToOptions(options, metaContext);

  return useQuery<Types.AccountCardDetailsDto[], TError, TSelectData>({
    queryFn: axiosConfig ? (context) => __getAccountCardDetails(context, axiosConfig) : __getAccountCardDetails,
    queryKey: getAccountCardDetailsQueryKey(body), // ERROR body is undefined
    ...getAccountCardDetailsDefaultOptions as unknown as Omit<UseQueryOptions<Types.AccountCardDetailsDto[], TError, TSelectData>, 'queryKey'>,
    ...options,
  });
}```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions