UNPKG

@gqty/solid

Version:

The No-GraphQL Client for React

51 lines (50 loc) 1.78 kB
import { prepass, type BaseGeneratedSchema, type Client } from 'gqty'; import type { CommonOptions, DefaultOptions, SolidClientOptions } from '.'; export type PrepareQueryHelpers<Schema extends BaseGeneratedSchema> = { prepass: typeof prepass<Schema>; }; type QueryOptions<Schema extends BaseGeneratedSchema> = { /** * Making selections before the component is rendered, allowing Suspense * to happen during first render. */ prepare?: (schema: Schema, helpers?: PrepareQueryHelpers<Schema>) => void; /** * Soft-refetch on the specified interval, skip this option to disable. */ refetchInterval?: number; /** * Soft-refetch when the browser regains connectivity. * * @default true */ refetchOnReconnect?: boolean; /** * Soft-refetch when user comes back to the browser tab. * * @default true */ refetchOnWindowVisible?: boolean; }; export type CreateQueryOptions<Schema extends BaseGeneratedSchema> = CommonOptions & DefaultOptions & QueryOptions<Schema>; export type CreateQuery<Schema extends BaseGeneratedSchema> = (options?: CreateQueryOptions<Schema>) => { (): Schema['query']; $state: { loading: boolean; error?: Error; }; $refetch: ( /** * Refetch even if the current cache is still fresh. * * @default true */ ignoreCache?: boolean) => Promise<void>; }; /** * Live Queries: A long-living cache subscription on the selections made for the * last successful fetch. Unsubscribing before a fetch starts, and resubscribe * after a fetch completes. */ export declare const createQuery: <Schema extends BaseGeneratedSchema>(client: Client<Schema>, clientOptions?: SolidClientOptions) => CreateQuery<Schema>; export {};