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

[tanstack query] Allow to customize the query option identifier suffix #1722

Open
lucsky opened this issue Feb 15, 2025 · 3 comments
Open

[tanstack query] Allow to customize the query option identifier suffix #1722

lucsky opened this issue Feb 15, 2025 · 3 comments
Labels
feature 🚀 New feature or request

Comments

@lucsky
Copy link

lucsky commented Feb 15, 2025

Description

Right now the query option identifier suffix generated by the @tanstack/query-core plugin is hardcoded to Options. I would love to be able to configure this to set it to something else.

@lucsky lucsky added the feature 🚀 New feature or request label Feb 15, 2025
@mrlubos
Copy link
Member

mrlubos commented Feb 15, 2025

Out of curiosity @lucsky, what's the naming pattern you prefer?

@lucsky
Copy link
Author

lucsky commented Feb 16, 2025

@mrlubos I use the Query and Mutation suffixes, it's not really a preference but rather just a convention that my team have adopted.

Come to think of it both Options and Query/Mutation make sense depending on how you look at it.

  • xxxOptions make sense because what you get is the result of a call to queryOptions
  • xxxQuery/xxxMutation make sense because it is what you pass to useQuery or useMutation

But yes, that means it would require two configuration options, one for queries and one for mutations. Too much? 😁

@MartinPivka
Copy link

To me ...Options makes more sense, since even Tanstack itsels calls it "options" in their codebase

export function useQuery(
  options: UseQueryOptions,
  queryClient?: QueryClient,
): UseQueryReturnType

I would go even further and call it xyFindOneQueryOptions and xyCreateMutationOptions 😄

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