/// import { Readable } from "stream"; import type { ArrayElement, BuilderMethods, Field, Network, QueryInfo, ReturnFields, SearchOpts } from "./index.js"; import type { Options as RetryOptions } from "async-retry"; /** * GraphQL query class - encapsulates all logic, types, and methods required to resolve queries */ export declare class GraphQLQuery = any, TVars extends Record = any, TReturn extends Record = any> { queryVars: Record; queryFields: Record; queryInfo: QueryInfo & { name: string; }; _query: string | undefined; gqlURL: URL; config: { first: boolean; userProvided: boolean; numPages: number; numResults: number; retryOpts?: RetryOptions; }; resultTracker: { numResults: number; numPages: number; done: boolean; }; constructor({ url, network, retryConfig, query, queryName, opts, }: { url?: string | URL; network?: Network; retryConfig?: RetryOptions; query?: QueryInfo | false; queryName: string; opts?: SearchOpts; }); protected parseNetwork(network: Network | undefined): URL | undefined; /** * Builds a query from fields and variables, formatting it into a GQL compatible string. * stores built query under `this.query` (protected) - accessible via `.toQuery` * @returns `this` (chainable) */ protected buildQuery(): BuilderMethods>; /** * Primary query execution method - builds & runs the query, returning result nodes and updating cursor info in queryVars * @returns query result nodes */ getPage(): Promise; private trimmer; /** * Get the first result from the query * @returns the first result from the query - gets at maximum one page */ first(): Promise>; /** * Limiter on the number of pages a given query should resolve to * @param numPages Maximum number of pages to return * @returns this (chainable) */ protected maxPages(numPages: number): BuilderMethods>; /** * Limiter on the maximum number of results a given query should resolve to * @param numResults Maximum number of results to return * @returns this (chainable) */ limit(numResults: number): BuilderMethods>; /** * Change the URL of the graphql endpoint to use * @param url: URL to use * @returns this (chainable) */ url(url: string | URL): BuilderMethods>; /** * Change the network of the graphql endpoint to use * @param network: network to use * @returns this (chainable) */ network(network: Network | undefined): BuilderMethods>; /** * Gets all results from the built query * @returns array of results */ all(): Promise; /** * Async generator, yields individual query result items */ generator(): AsyncGenerator>>; /** * Async generator, yields pages of results */ pageGenerator(): AsyncGenerator>; /** * Readable stream produced from `this.generator` * @returns a readable instance, with the "data" event yielding individual results */ stream(): { on(event: "data", listener: (res: ArrayElement) => any): any; } & Readable; /** * Provide a custom query string to resolve * @param query Query string to use * @returns result of the query - this method does not support paging or extraction */ query(query: string): GraphQLQuery; /** * Set the fields you want the query to return * @param fields - Object structured like a graphql query body, truthy values including, falsy excluding * @param skipFieldCheck - whether to skip JS level fields object shape validation * @returns `this` (chainable) */ fields = Field>(fields: T, skipFieldCheck?: boolean): BuilderMethods[]>>; /** * Sets variables/filters using an object * @param variables variable object to set * @returns this (chainable) */ variables(variables: Partial & any): BuilderMethods>; /** * Builds the current query and returns a ready to POST query string * @returns string form of the current query */ toQuery(): string; /** * Dummy method to access the internal `TReturn` generic type * @returns "tReturn" */ protected tReturn(): TReturn; /** * Dummy method to access the internal `TQuery` generic type * @returns "tQuery" */ protected tQuery(): TQuery; /** * Dummy method to access the internal `TVars` generic type * @returns "tVars" */ protected tVars(): TVars; /** * Resolves `this` by getting all results for the query (including paging) * @param onFulfilled - optional onFulfilled callback * @returns - all results for built query */ then(onFulfilled?: ((value: TReturn) => any | PromiseLike) | undefined | null, onRejected?: (value: Error) => any | PromiseLike | undefined | null): Promise; catch(onReject?: ((value: TReturn) => any | PromiseLike) | undefined | null): Promise; finally(onFinally?: (() => void) | null | undefined): Promise; }