Skip to content

Add name builder options to TanStack Query #2085

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

Open
mrlubos opened this issue May 28, 2025 · 7 comments
Open

Add name builder options to TanStack Query #2085

mrlubos opened this issue May 28, 2025 · 7 comments
Labels
feature 🚀 New feature or request

Comments

@mrlubos
Copy link
Member

mrlubos commented May 28, 2025

Discussed in https://github.com/orgs/hey-api/discussions/2084

Originally posted by TCLNA May 28, 2025
When generating a POST query that is effectively a search endpoint with a lot of options passed in the body, it generates a mutation. Is there a whitelist system for changing the generator behavior for this specific endpoint ? I tried to look at query-core but only found some config boolean flags.
If this does not exist i'm willing to put in the work btw.
Thanks a lot in advance! This is a great project that spared me do much time 🥹

@mrlubos mrlubos added the feature 🚀 New feature or request label May 28, 2025
@nickgraffis
Copy link

nickgraffis commented May 29, 2025

It says this in the docs, and it creates the options to be used in a query.

const query = useQuery({
  ...postLoansOptions({
    body: {
      query: {
        op: 'eq',
        args: { property: 'zipCode', value: '90815' },
      },
    },
  }),
});

just figured it out 😉 , hope it helps

@mrlubos
Copy link
Member Author

mrlubos commented May 29, 2025

@TCLNA can you share your spec with me?

@mrlubos
Copy link
Member Author

mrlubos commented May 29, 2025

@nickgraffis are the docs regarding this feature confusing?

@mrlubos mrlubos added the needs info ⏳ Further information is required label May 30, 2025
@nickgraffis
Copy link

No the docs are super clear, this was my fault.

I didn't really read the docs at first and because there is a addPetMutation I assumed that there would be an addPetQuery, but it is actually addPetOptions.

For example.

This seems to be working perfectly. Thanks for all the hard work.

@mrlubos
Copy link
Member Author

mrlubos commented May 30, 2025

Hmm, that's a fair point, I might (add an option allowing you to) rename it. Is the original account that started the discussion your alt btw or is that another person? Just so I know whether to close this issue

@nickgraffis
Copy link

@mrlubos nope not alternate, different person.

Rename it could be a cool option, but having said that, the docs are really clear, I just didn't read them carefully.

@TCLNA
Copy link

TCLNA commented May 30, 2025

Hey ! Sorry for the late response.

Thanks for pointing this out @nickgraffis ! I indeed just had a hard time finding the option function name, I wasn't careful enought reading the docs too.

@mrlubos mrlubos changed the title Is there an option for generating a POST endpoint as a query instead of a mutation ? Add name builder options to TanStack Query May 30, 2025
@mrlubos mrlubos removed the needs info ⏳ Further information is required label May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🚀 New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants