Skip to main content
Version: 1.x

getQueryData(...)

The method enables direct access to the QueryClient cache to retrieve the data for a specific Query. See the TanStack queryClient.getQueryData 🌴 documentation.

const data = qraft.<service>.<operation>.getQueryData(
parameters,
queryClient
);

Arguments​

  1. parameters: { path, query, header } | QueryKey
    • Required parameters to retrieve the data from the Query Cache.
    • Instead of an object with {path, query, header}, you can pass a QueryKey as an array which is also strictly-typed ✨
  2. queryClient: QueryClient
    • Required QueryClient instance to use

Returns​

The data from the Query Cache for the specific query, strictly-typed ✨

Example​

const pet = qraft.pet.getPetById.getQueryData(
{
path: { petId: 123 },
},
queryClient
);

expect(pet?.id).toEqual(123);