apollo-client
Version:
A simple yet functional GraphQL client.
29 lines (28 loc) • 1.25 kB
TypeScript
import { NetworkInterface, createNetworkInterface } from './networkInterface';
import { GraphQLResult, Document } from 'graphql';
import { createApolloStore, ApolloStore, createApolloReducer } from './store';
import { QueryManager, WatchQueryOptions, ObservableQuery } from './QueryManager';
import { readQueryFromStore, readFragmentFromStore } from './data/readFromStore';
export { createNetworkInterface, createApolloStore, createApolloReducer, readQueryFromStore, readFragmentFromStore };
export default class ApolloClient {
networkInterface: NetworkInterface;
store: ApolloStore;
reduxRootKey: string;
initialState: any;
queryManager: QueryManager;
constructor({networkInterface, reduxRootKey, initialState}?: {
networkInterface?: NetworkInterface;
reduxRootKey?: string;
initialState?: any;
});
watchQuery: (options: WatchQueryOptions) => ObservableQuery;
query: (options: WatchQueryOptions) => Promise<GraphQLResult>;
mutate: (options: {
mutation: Document;
variables?: Object;
}) => Promise<GraphQLResult>;
reducer(): Function;
middleware: () => (store: ApolloStore) => (next: any) => (action: any) => any;
initStore(): void;
private setStore;
}