@brickkit/core/tanstack-query
TanStack Query options and keys for the typed client's actions.
@brickkit/core/tanstack-query exports 3 names: 1 function, 2 types.
import { createBrickQueryClient } from "@brickkit/core/tanstack-query";Functions
| Function | Description |
|---|---|
createBrickQueryClient | Query helpers share the ordinary Brick HTTP client, including custom routes. |
createBrickQueryClient
function createBrickQueryClient<T extends Record<string, unknown>>(
options: BrickClientOptions & { contract: T },
): BrickQueryClient<T>Query helpers share the ordinary Brick HTTP client, including custom routes.
Parameters
| Name | Type | Description |
|---|---|---|
options | BrickClientOptions & { contract: T } |
Returns BrickQueryClient<T>
Source: packages/core/src/tanstack-query.ts:63
Types
BrickQueryAction
type BrickQueryAction<A> = BrickActionCaller<A> & {
/** Omit options for an action-wide invalidation key. */
queryKey: {
(): ActionKey;
(options: {
input: InferActionInput<A>;
}): DataTag<ActionKey, InferActionOutput<A>>;
};
queryOptions: (...args: InputArgs<A>) => {
queryKey: DataTag<ActionKey, InferActionOutput<A>>;
queryFn: (
context: Pick<QueryFunctionContext, "signal">,
) => Promise<InferActionOutput<A>>;
};
mutationOptions: (options?: { request?: BrickCallOptions }) => {
mutationKey: ActionKey;
mutationFn: (input: InferActionInput<A>) => Promise<InferActionOutput<A>>;
};
};Source: packages/core/src/tanstack-query.ts:35
BrickQueryClient
type BrickQueryClient<T> = T extends
| BrickClientAction<infer _I, infer _O, infer _E>
| Action<infer _AI, infer _AO, infer _AC, infer _AE>
| ((...args: never[]) => unknown)
? BrickQueryAction<T>
: { [K in keyof T]: BrickQueryClient<T[K]> };