UNPKG

apollo-client

Version:
53 lines (52 loc) 1.81 kB
import { NetworkInterface } from './networkInterface'; import { ApolloStore } from './store'; import { GraphQLResult, Document } from 'graphql'; import { IdGetter } from './data/extensions'; import { Observable, Observer, Subscription } from './util/Observable'; export declare class ObservableQuery extends Observable<GraphQLResult> { subscribe(observer: Observer<GraphQLResult>): QuerySubscription; result(): Promise<GraphQLResult>; } export interface QuerySubscription extends Subscription { refetch(variables?: any): void; stopPolling(): void; startPolling(pollInterval: number): void; } export interface WatchQueryOptions { query: Document; variables?: { [key: string]: any; }; forceFetch?: boolean; returnPartialData?: boolean; pollInterval?: number; } export declare class QueryManager { private networkInterface; private store; private reduxRootKey; private dataIdFromObject; private pollingTimer; private queryListeners; private idCounter; constructor({networkInterface, store, reduxRootKey, dataIdFromObject}: { networkInterface: NetworkInterface; store: ApolloStore; reduxRootKey: string; dataIdFromObject?: IdGetter; }); broadcastNewStore(store: any): void; mutate({mutation, variables}: { mutation: Document; variables?: Object; }): Promise<GraphQLResult>; watchQuery(options: WatchQueryOptions): ObservableQuery; query(options: WatchQueryOptions): Promise<GraphQLResult>; fetchQuery(queryId: string, options: WatchQueryOptions): void; private getApolloState(); private startQuery(options, listener); private stopQuery(queryId); private broadcastQueries(); private generateQueryId(); private generateRequestId(); }