Specta LogoSpecta
RspcTypescript apiTs rspc query core

@rspc/query-core

TypeScript API reference for @rspc/query-core, version 0.0.0-main-a5d698cd.

Generated from the published type declarations for this exact release.

Public exports of @rspc/query-core at version 0.0.0-main-a5d698cd.

This page documents 0.0.0-main-a5d698cd. The documented version is 0.3.1.

Interfaces

BaseOptions

export interface BaseOptions<TProcedures extends ProceduresDef> {
    rspc?: {
        client?: AlphaClient<TProcedures>;
    };
}

View source ↗

Context

export interface Context<TProcedures extends ProceduresDef> {
    client: AlphaClient<TProcedures>;
    queryClient: QueryClient;
}

View source ↗

SubscriptionOptions

export interface SubscriptionOptions<P extends ProcedureDef> {
    enabled?: boolean;
    onStarted?: () => void;
    onData: (data: P["result"]) => void;
    onError?: (err: P["error"] | rspc.Error) => void;
}

View source ↗

Type aliases

HookOptions

export type HookOptions<P extends ProceduresDef, T> = T & BaseOptions<P>;

View source ↗

KeyAndInput

export type KeyAndInput = [
    string
] | [
    string,
    any
];

View source ↗

QueryOptionsOmit

export type QueryOptionsOmit<T> = Omit<T, "queryKey" | "queryFn">;

View source ↗

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>
    ], never>> & 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

View source ↗

throwOnError

export declare function throwOnError<TOk, TError>(res: rspc.Result<TOk, TError>): TOk | Promise<never>;

View source ↗

On this page