Skip to content

Feature Request: Add operationId to queryKey for better React Query hook identification #2096

@adam-flo

Description

@adam-flo

Is your feature request related to a problem? Please describe.

Currently, when generating React Query hooks using Orval, the queryKey returned from the ...QueryKey functions only includes the API path, for example:

return [`/some/path`] as const;

This makes it difficult to uniquely identify or cache queries in larger projects where many paths may be dynamic or similar.


Describe the solution you’d like

I’d like to request an option in Orval’s config to include the operationId alongside the API path in the queryKey, like:

return ['getSomeData', `/some/path`] as const;

Describe alternatives you’ve considered

We are currently using a custom post-generation script to parse the generated api-docs.ts and inject the operationId manually, but this approach is brittle and could break with future Orval updates.


Additional context

It would be great if this could be implemented as an opt-in configuration flag, for example:

reactQuery:
  includeOperationIdInQueryKey: true

Thanks for the great tool and all your hard work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    tanstack-queryTanStack Query related issue

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions