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

[tanstack/query] Error type not being propagated to the generated queryOptions methods #1486

Closed
vitorcamachoo opened this issue Dec 26, 2024 · 0 comments · Fixed by #1489
Closed
Assignees
Labels
bug Something isn't working @kubb/plugin-react-query

Comments

@vitorcamachoo
Copy link

vitorcamachoo commented Dec 26, 2024

What version of kubb is running?

3.3.4

What kind of platform do you use?

MacOS

How does your kubb.config.ts config look like

export default defineConfig({
  input: {
    path: './schema.yaml',
  },
  output: {
    clean: true,
    path: './src',
  },
  plugins: [
    pluginOas({
      validate: true,
      // @ts-ignore
      output: false,
    }),
    pluginTs({
      output: {
        path: './types',
        banner: `
          /**
           * Generated by kubb.
           * Do not edit manually.
           * Shape API
           */        
        `,
      },
      exclude: [],
      enumType: 'asConst',
      enumSuffix: 'Enum',
      dateType: 'string',
      unknownType: 'unknown',
      optionalType: 'questionToken',
      oasType: false,
      transformers: {
        name: (name, type) => {
          if (type === 'file') return `${name[0].toLowerCase() + name.slice(1)}Schema`;
          return `${name}Schema`;
        },
      },
    }),
    pluginClient({
      importPath: '../../client.kubb.ts',
      output: {
        path: './api/index.ts',
        barrelType: 'propagate',
        banner: `
          /**
           * Generated by kubb.
           * Do not edit manually.
           * Shape API
           */        
        `,
      },
    }),
    pluginReactQuery({
      client: {
        importPath: '../../client.kubb.ts',
      },
      output: {
        path: './hooks/index.ts',
        banner: `
        /**
         * Generated by kubb.
         * Do not edit manually.
         * Shape API
        */        
       `,
      },
      paramsCasing: 'camelcase',
      suspense: {},
    }),
  ],
});

Swagger/OpenAPI file?

No response

What version of external packages are you using(@tanstack-query, MSW, React, Vue, ...)

"@tanstack/react-query": "5.52.1",
"react": "18.3.1",
"react-dom": "18.3.1",
"msw": "1.1.0",

What steps can reproduce the bug?

In my project, I aim to utilize the query options factories provided by Kubb to improve our management of queries and mutations. We are currently transitioning from Orval to Kubb, but we have encountered some issues that are hindering our migration.

We prefer to use the generated query options factories and directly implement the useMutation and useQuery hooks in our components. This approach would enhance our management of these hooks in the long run. However, I have discovered that when using the query options factory methods, the error is not integrated into the query options interface. As a result, the error is always of the DefaultError type, which is simply an Error object.
Screenshot 2024-12-26 at 16 41 06

How often does this bug happen?

Every time

What is the expected behavior?

No response

Additional information

https://discord.com/channels/1117538769235615835/1321868663321661571/1321868663321661571

@vitorcamachoo vitorcamachoo added the bug Something isn't working label Dec 26, 2024
@stijnvanhulle stijnvanhulle self-assigned this Jan 3, 2025
@stijnvanhulle stijnvanhulle linked a pull request Jan 3, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working @kubb/plugin-react-query
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants