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

Reduce amount of used generics #732

Closed
3 tasks done
stijnvanhulle opened this issue Dec 17, 2023 — with Huly for GitHub · 0 comments
Closed
3 tasks done

Reduce amount of used generics #732

stijnvanhulle opened this issue Dec 17, 2023 — with Huly for GitHub · 0 comments
Labels
bug Something isn't working

Comments

Copy link
Collaborator

stijnvanhulle commented Dec 17, 2023

Today Kubb uses a couple of generics to override for example the response data. Kubb should not make it possible to override the data of a specific API(the response is defined in the Swagger so it cannot be changed). Users should use select if they want to change the data.

  • SWR plugin update
  • Tanstack query plugin update
  • client plugin update
export function findPetsByStatusQueryOptions<TData extends FindPetsByStatus['response'] = FindPetsByStatus['response'], TError = FindPetsByStatus['error']>(
  params?: FindPetsByStatus['queryParams'],
  options: FindPetsByStatus['client']['parameters'] = {},
): SWRConfiguration<TData, TError> {
  return {
    fetcher: async () => {
      const res = await client<TData, TError>({
        method: 'get',
        url: `/pet/findByStatus`,
        params,
        ...options,
      })
      return res
    },
  }
}

will become

export function findPetsByStatusQueryOptions(
  params?: FindPetsByStatus['queryParams'],
  options: FindPetsByStatus['client']['parameters'] = {},
) {
  return {
    fetcher: async () => {
      const res = await client<FindPetsByStatus['response'], FindPetsByStatus['error']>({
        method: 'get',
        url: `/pet/findByStatus`,
        params,
        ...options,
      })
      return res
    },
  }
}
@stijnvanhulle stijnvanhulle added the bug Something isn't working label Dec 17, 2023
@xPhentom xPhentom linked a pull request Dec 20, 2023 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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant