RspcTypescript apiTs rspc query core
@rspc/query-core
TypeScript API reference for @rspc/query-core, version 0.0.0-main-5a753130.
0.0.0-main-5a753130
Generated from the published type declarations for this exact release.
Public exports of @rspc/query-core at version 0.0.0-main-5a753130.
This page documents 0.0.0-main-5a753130. The documented version is 0.3.1.
Interfaces
BaseOptions
export interface BaseOptions<TProcedures extends ProceduresDef> {
rspc?: {
client?: AlphaClient<TProcedures>;
};
}
Context
export interface Context<TProcedures extends ProceduresDef> {
client: AlphaClient<TProcedures>;
queryClient: QueryClient;
}
SubscriptionOptions
export interface SubscriptionOptions<P extends ProcedureDef> {
enabled?: boolean;
onStarted?: () => void;
onData: (data: P["result"]) => void;
onError?: (err: P["error"] | rspc.Error) => void;
}
Type aliases
HookOptions
export type HookOptions<P extends ProceduresDef, T> = T & BaseOptions<P>;
KeyAndInput
export type KeyAndInput = [
string
] | [
string,
any
];
QueryOptionsOmit
export type QueryOptionsOmit<T> = Omit<T, "queryKey" | "queryFn">;
Functions
createQueryHookHelpers
export declare function createQueryHookHelpers<P extends ProceduresDef>(args: {
useContext(): Context<P> | null;
}): {
useContext: () => Context<P>;
useClient: () => AlphaClient<P>;
useExtractOps: <T extends BaseOptions<P>>(opts: T) => readonly [
AlphaClient<P>,
Omit<T, "rspc">
];
mapQueryKey: (keyAndInput: KeyAndInput, client: AlphaClient<P>) => any;
useQueryArgs: <K extends rspc.inferQueries<P>["key"] & string, O extends QueryOptionsOmit<QueryObserverOptions<rspc.inferQueryResult<P, K>, rspc.inferQueryError<P, K>, rspc.inferQueryResult<P, K>, rspc.inferQueryResult<P, K>, [
K,
rspc.inferQueryInput<P, K>
]>> & BaseOptions<P>>(keyAndInput: [
key: K,
...input: rspc._inferProcedureHandlerInput<P, "queries", K>
] | (() => [
key: K,
...input: rspc._inferProcedureHandlerInput<P, "queries", K>
]), opts?: O | undefined) => {
queryKey: any;
// … truncated, see the source link
throwOnError
export declare function throwOnError<TOk, TError>(res: rspc.Result<TOk, TError>): TOk | Promise<never>;
