Skip to content

matchQuery types don't support partial keys #9680

@JosNun

Description

@JosNun

Describe the bug

If I type my query key as per the docs (https://tanstack.com/query/latest/docs/framework/react/typescript#typing-query-and-mutation-keys), matchQuery expects a full query key instead of a partial query key (even if the exact option of the QueryFilters is false.

Your minimal, reproducible example

https://stackblitz.com/edit/vitejs-vite-49gqkj84?file=src%2Fmain.tsx,src%2FApp.tsx

Steps to reproduce

  1. Type the query keys as per the docs (https://tanstack.com/query/latest/docs/framework/react/typescript#typing-query-and-mutation-keys)
  2. Try to use a partial key with matchQuery

Expected behavior

If exact isn't true (I believe this is the default), I would expect that I would be able to use a partial query key for the QueryFilter passed to matchQuery instead of having to pass a complete key.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

N/A

Tanstack Query adapter

react-query

TanStack Query version

5.90.2

TypeScript version

5.4.5

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions