Skip to content
IC Reactor

QueryFactoryMethods

Defined in: react/src/types.ts:542

The members every args-late query factory function carries (createQueryFactory, createSuspenseQueryFactory, createInfiniteQueryFactory, createSuspenseInfiniteQueryFactory).

A factory makes one query per set of args, so there was no key to name all of them: invalidating a list after a mutation meant keeping the args of each instance around. These address every query the factory returns at once.

getQueryKey: () => readonly unknown[]

Defined in: react/src/types.ts:562

The key prefix every query of this factory shares, whatever its args: the canister (the config’s callConfig.canisterId, else the reactor’s) and the method, plus the reactor’s transform segment and any agent or effective-target segment the config’s callConfig adds, and for an infinite factory its config queryKey. TanStack Query matches keys by prefix, so the prefix covers every args instance and every infinite page set. Queries of the same method made elsewhere share it too.

readonly unknown[]

const getBalance = createQueryFactory(ledger, {
functionName: "icrc1_balance_of",
})
// Every cached balance, whatever the account
ledger.queryClient.getQueriesData({ queryKey: getBalance.getQueryKey() })

invalidate: () => Promise<void>

Defined in: react/src/types.ts:574

Invalidate every query of this factory, whatever its args, on the reactor’s QueryClient. It resolves once the active ones have refetched; a refetch that fails does not reject it.

Promise<void>

// After a transfer, refresh every balance on screen
await getBalance.invalidate()