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(query): support custom-fetch-hook #1632

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

izumin5210
Copy link

@izumin5210 izumin5210 commented Sep 18, 2024

Status

READY

Description

Currently, Orval generates broken code when mutator is custom fetch client hook.

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

You can check by using sample app.

@melloware melloware added this to the 7.2.0 milestone Sep 18, 2024
@melloware
Copy link
Collaborator

Looks like build is failing?

@soartec-lab
Copy link
Member

Thank you for nice enhance !
I don't want to include the hooks concerns in the fetch package alone, so give me some time to think about how to get around that.

@soartec-lab
Copy link
Member

I've thought about this, and I'd like to have no query concerns in the fetch package.
But that would require me to do more refactoring, so I'll make another one after this PR is merged.

@soartec-lab
Copy link
Member

@izumin5210
Could you fix the failing tests?

if (mutator?.isHook) {
const fetchImplementationBody = `return ${operationName}(${fetchFnOptions});`;
fetchImplementation = `export const use${pascal(operationName)}Hook = (): (${args}) => ${retrunType} => {
const ${operationName} = ${mutator.name}<Awaited<${retrunType}>>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since operationName is confusing, how about naming it something like customHook, customMutator, or mutator, which makes it clear that it is a custom hook?

Suggested change
const ${operationName} = ${mutator.name}<Awaited<${retrunType}>>();
const customHook = ${mutator.name}<Awaited<${retrunType}>>();

@melloware melloware modified the milestones: 7.2.0, 7.2.1 Oct 18, 2024
@melloware melloware modified the milestones: 7.3.0, 7.3.1 Nov 16, 2024
@melloware melloware removed this from the 7.3.1 milestone Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants