Skip to content

Error in Query generation #54

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,
  });
}```

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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