Skip to content

Vue Query: It generates undefined function "useCallback" #1872

Open
@wiz-tajima

Description

@wiz-tajima

What are the steps to reproduce this issue?

  1. …generate on Vue3 project with config below:
import { config } from "dotenv";
import { defineConfig } from "orval";

export default () => {
  config();
  return defineConfig({
    "standard-frontend": {
      output: {
        mode: "tags",
        headers: true,
        workspace: "./openapi/client",
        target: "./endpoints",
        schemas: "./models",
        indexFiles: true,
        client: 'vue-query',
        urlEncodeParameters: true, // https://zenn.dev/hsato_workman/books/5f41b770d9221b/viewer/0bccda#urlencodeparameters
        override: {
          useDates: true,
          mutator: {
            path: "./mutator/use-custom-instance.ts",
            name: "useCustomInstance",
          },
          formData: {
            path: "./mutator/custom-form-data.ts",
            name: "customFormData",
          },
          query: {
            queryOptions: {
              path: "./openapi/client/mutator/custom-query-options.ts",
              name: "customTranQueryOptions",
            },
          },
          mock: {},
          operations: {},
        },
      },
      input: {
        target: "./openapi/openapi-docs.yml",
      },
    },
  });
};

What happens?

Orval generates code below:

export const usePostAuthLoginHook = () => {
        const postAuthLogin = useCustomInstance<void>();

        return useCallback((
    authLoginPostRequest: MaybeRef<AuthLoginPostRequest>,
 signal?: AbortSignal
) => {
        return postAuthLogin(
          {url: `/auths/login`, method: 'POST',
      headers: {'Content-Type': 'application/json', },
      data: authLoginPostRequest, signal
    },
          );
        }, [postAuthLogin])
      }

This code has critical problem: useCallback() doesn't exist on Vue.
So, this makes unavoidable error.

What were you expecting to happen?

Before orval version 6.29.0, it generates correct code.
Please make back.

Any logs, error output, etc?

Any other comments?

Probably, useCallback is made with setting mutator on orval.config.ts.

What versions are you using?

Operating System: … Linux (WSL)
Package Version: …6.29.1 ~ 7.4.1
Browser Version: N/A

Activity

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

Metadata

Metadata

Assignees

Labels

tanstack-queryTanStack Query related issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions