Skip to content

fix(query): prioritize query over mutation for non-GET operations in generateQueryHook #2027

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

Conversation

Edward-Upton
Copy link
Contributor

@Edward-Upton Edward-Upton commented Apr 14, 2025

Status

READY

Fix #2025

Description

Ensures that only one of the queries or mutations are generated, giving priority to queries.

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

Run on the test repo that shows the bug in action

https://github.com/Edward-Upton/orval-duplicate-hook-bug

@melloware
Copy link
Collaborator

Running the tests now!

@melloware melloware requested a review from soartec-lab April 14, 2025 17:23
Copy link
Member

@soartec-lab soartec-lab left a comment

Choose a reason for hiding this comment

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

@Edward-Upton

Thank you for the nice correction. I made a comment.
I think it needs to be reflected in the documentation, but I'll think about it for a bit.

@soartec-lab soartec-lab self-assigned this Apr 15, 2025
@Edward-Upton Edward-Upton force-pushed the fix/prioritise-query-over-mutations-react-query branch from 8498b30 to f4eb118 Compare April 15, 2025 12:06
@Edward-Upton
Copy link
Contributor Author

I have resolved the comments, thanks for the review 😄

Copy link
Member

@soartec-lab soartec-lab left a comment

Choose a reason for hiding this comment

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

@Edward-Upton
Thanks!
I thought about documentation. Please clarify the specifications in the guide for the following options.

  1. Only valid when the verbs of the two mutations are not get and not query
  2. Prioritize output.mutation over output.orverride.mutation

Could you update docs ?

@Edward-Upton Edward-Upton force-pushed the fix/prioritise-query-over-mutations-react-query branch from f4eb118 to 3d8617b Compare April 15, 2025 14:59
@Edward-Upton
Copy link
Contributor Author

I have updated the docs, and fixed the issue that was causing the build failure.

Copy link
Member

@soartec-lab soartec-lab left a comment

Choose a reason for hiding this comment

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

It's good !

@soartec-lab soartec-lab merged commit b0833b7 into orval-labs:master Apr 16, 2025
@AllieJonsson
Copy link
Contributor

It seems like this change broke samples, where we now get multiple implementation of the hooks

@soartec-lab
Copy link
Member

@AllieJonsson
Oh, will that be fixed by just re-running orval in samples?

@AllieJonsson
Copy link
Contributor

@soartec-lab No, I tried generating samples in #2035 but the issue persists

@soartec-lab
Copy link
Member

@AllieJonsson
Thanks for letting me know.

@Edward-Upton
It seems like the query is being treated as a mutation in a way that we didn't intend. Can you confirm this?

@AllieJonsson
Copy link
Contributor

AllieJonsson commented Apr 17, 2025

@soartec-lab isn't it weird that we don't see if samples break in the PR, but in the following PRs? That must mean that we don't correctly build/test samples?
Could we maybe try to add yarn update-samples to the workflow, before running yarn test:ci?
#2037

@soartec-lab soartec-lab added bug Something isn't working tanstack-query TanStack Query related issue labels Apr 17, 2025
@soartec-lab soartec-lab added this to the 7.9.0 milestone Apr 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tanstack-query TanStack Query related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicate non-infinite hooks generated when infinite query enabled for POST endpoints
4 participants