import { type EventCallable, type Store } from "effector"; import { type ApolloClient, type ApolloError, type DefaultContext, type DocumentNode, type MaybeMasked, type OperationVariables, type TypedDocumentNode } from "@apollo/client"; import { type Optional } from "../lib/optional.js"; import { type RemoteOperation, type RemoteOperationInternals } from "../remote_operation.js"; import { type QueryMeta } from "./controller.js"; interface CreateQueryOptions { /** Your {@link ApolloClient} instance that'll be used for making the query. */ client: ApolloClient | Store>; /** * A GraphQL Document with a single `query` for your operation. * It's passed directly to Apollo with no modifications. */ document: DocumentNode | TypedDocumentNode; /** Context passed to your Apollo Link. */ context?: DefaultContext | Store; /** The name of your query. Will be derived from `document` if abscent. */ name?: string; } export interface QueryInternals extends RemoteOperationInternals, Variables, QueryMeta> { push: EventCallable | null>; } export interface Query extends RemoteOperation, Variables, QueryMeta> { /** Start fetching data unconditionally. */ start: EventCallable>; /** Start fetching data if it is absent or stale. */ refresh: EventCallable>; /** Reset query state. Clears `$data`, `$error` and `$status` to their initial values. */ reset: EventCallable; /** * Latest data received from your `Query`. * * If there was an error during fetching, or if there was no request yet, * this store will be `null`. */ $data: Store | null>; /** * Latest {@link Query} error. * * If the data has been successfully fetched, or if there was no request yet, * the store will be `null`. */ $error: Store; meta: { /** The name of this query. */ name: string; /** The client this query will use to make requests. */ client: Store>; /** The document that contains your query and will be used to request data. */ document: TypedDocumentNode; }; /** * Internal tools, useful for testing. */ __: QueryInternals; } /** * A factory to create a GraphQL Query * * @param config Query configuration * @returns Query instance */ export declare function createQuery({ client, document, context, name, }: CreateQueryOptions): Query; export {};