liveBook · Manning

Query key

As explained in React in Depth

A query key is an array of values that uniquely identifies a TanStack Query query and its parameters.

A query key is an array of values that identifies a TanStack Query query and its parameters. Use a single string for flat data, or add an object for identifiers, pagination, or filters. section 9.3.2

Choose key shapes that preserve the distinctions your cache must track:

  • ["customers"] identifies the complete customer list. section 9.3.2

Invalidating related customer data

After deleting a customer, invalidate the partial key ["customers"] to refresh customer-list queries, then invalidate ["customer", { id }] for the deleted record without discarding every individual-customer query. section 9.3.2

How React in Depth covers it

How deep it goes
Explains key composition and invalidation behavior, but stops short of cache hashing or serialization internals.
Examples
Illustrates customer lists, individual customers, pagination, name searches, and deletion-triggered invalidation.
What it assumes
Assumes query functions and basic useQuery or useMutation usage, while treating server argument passing as application code.
What you can do after
Apply it via TanStack Query to separate parameterized server data and invalidate related cache entries selectively.
How it connects
Connects useQuery and useMutation with cache invalidation and remote-data caching.

Also explained in

Compare how 2 books explain query key →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of React in Depth. The section links point to the parts of the book it draws on.