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.
Extended by
Section titled “Extended by”Properties
Section titled “Properties”getQueryKey
Section titled “getQueryKey”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.
Returns
Section titled “Returns”readonly unknown[]
Example
Section titled “Example”const getBalance = createQueryFactory(ledger, { functionName: "icrc1_balance_of",})
// Every cached balance, whatever the accountledger.queryClient.getQueriesData({ queryKey: getBalance.getQueryKey() })invalidate
Section titled “invalidate”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.
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”// After a transfer, refresh every balance on screenawait getBalance.invalidate()