Skip to content

react query generate partial key option #3789

@Andrew-Chen-Wang

Description

@Andrew-Chen-Wang

I'm having to do a lot of invalidations of queries. TanStack react query allows you to use partial query key matching via prefix. But using the OptionKey function doesn't allow this as it forces you to input all required parameters (in my case, it's required to input limit/offset, but the query key prefix shouldn't include the limit/offset search parameters).

The current solution is to write:

void queryClient.invalidateQueries({ queryKey: [{ _id: "getApiV1Endpoint" }] })

manually. If there was auto generated ids, that would be nice.

hm i guess you could do getApiV1Endpoint.name which works...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions