-
-
Notifications
You must be signed in to change notification settings - Fork 529
Closed
Copy link
Labels
tanstack-queryTanStack Query related issueTanStack Query related issue
Milestone
Description
When the useOperationIdAsQueryKey flag is set to true, path parameters are not included in the generated query key.
This leads to incorrect cache behavior and makes it impossible to properly invalidate queries that depend on unique path parameters.
Example
Generated output:
export const getGetWorkspaceQueryKey = (workspaceId?: number, params?: GetWorkspaceParams) => {
return ["getWorkspace", ...(params ? [params] : [])] as const
}In this case, the workspaceId path parameter is missing from the query key.
Expected behavior
Path parameters should be included in the generated query key only if they are defined, for example:
export const getGetWorkspaceQueryKey = (workspaceId?: number, params?: GetWorkspaceParams) => {
return ["getWorkspace", ...(workspaceId !== undefined ? [workspaceId] : []), ...(params ? [params] : [])] as const
}viniciuspatzer, sikv007 and valeryq
Metadata
Metadata
Assignees
Labels
tanstack-queryTanStack Query related issueTanStack Query related issue