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

feat(swr): add swrMutationOptions property to output.override.swr #1225

Conversation

soartec-lab
Copy link
Collaborator

Status

READY

Description

This PR is a follow up to #1223
I added a property swrMutationOptions to output.override.swr that extends only the options of useSWRMutation.

Related PRs

List related PRs against other branches:

#1223

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

  1. check generated hooks in tests

tests/generated/swr/petstore-override-swr/endpoints.ts:

/**
 * @summary Create a pet
 */
export const useCreatePets = <TError = AxiosError<Error>>(
  params: CreatePetsParams, options?: { swr?:SWRMutationConfiguration<Awaited<ReturnType<typeof createPets>>, TError, string, Arguments, Awaited<ReturnType<typeof createPets>>> & { swrKey?: string }, axios?: AxiosRequestConfig }
) => {

  const {swr: swrOptions, axios: axiosOptions} = options ?? {}

  const swrKey = swrOptions?.swrKey ?? getCreatePetsMutationKey();
  const swrFn = getCreatePetsMutationFetcher(params,axiosOptions);

  const query = useSWRMutation(swrKey, swrFn, {
     revalidate: true, 
    ...swrOptions
  })

  return {
    swrKey,
    ...query
  }
}

@soartec-lab soartec-lab added the enhancement New feature or request label Feb 18, 2024
@soartec-lab soartec-lab added this to the 6.26.0 milestone Feb 18, 2024
@soartec-lab
Copy link
Collaborator Author

the tests action is failed but, i fixed by #1226

@melloware melloware merged commit d5ccc8c into orval-labs:master Feb 18, 2024
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants