UNPKG

3.23 kBTypeScriptView Raw
1import { NgZone } from '@angular/core';
2import { ApolloClient, QueryOptions, MutationOptions, ApolloQueryResult, SubscriptionOptions, ApolloClientOptions, FetchResult } from '@apollo/client/core';
3import { Observable } from 'rxjs';
4import { QueryRef } from './query-ref';
5import { WatchQueryOptions, ExtraSubscriptionOptions, EmptyObject, NamedOptions, Flags } from './types';
6export declare class ApolloBase<TCacheShape = any> {
7 protected ngZone: NgZone;
8 protected flags?: Flags;
9 protected _client?: ApolloClient<TCacheShape>;
10 private useInitialLoading;
11 constructor(ngZone: NgZone, flags?: Flags, _client?: ApolloClient<TCacheShape>);
12 watchQuery<TData, TVariables = EmptyObject>(options: WatchQueryOptions<TVariables, TData>): QueryRef<TData, TVariables>;
13 query<T, V = EmptyObject>(options: QueryOptions<V, T>): Observable<ApolloQueryResult<T>>;
14 mutate<T, V = EmptyObject>(options: MutationOptions<T, V>): Observable<FetchResult<T>>;
15 subscribe<T, V = EmptyObject>(options: SubscriptionOptions<V, T>, extra?: ExtraSubscriptionOptions): Observable<FetchResult<T>>;
16 /**
17 * Get an access to an instance of ApolloClient
18 * @deprecated use `apollo.client` instead
19 */
20 getClient(): ApolloClient<TCacheShape>;
21 /**
22 * Set a new instance of ApolloClient
23 * Remember to clean up the store before setting a new client.
24 * @deprecated use `apollo.client = client` instead
25 *
26 * @param client ApolloClient instance
27 */
28 setClient(client: ApolloClient<TCacheShape>): void;
29 /**
30 * Get an access to an instance of ApolloClient
31 */
32 get client(): ApolloClient<TCacheShape>;
33 /**
34 * Set a new instance of ApolloClient
35 * Remember to clean up the store before setting a new client.
36 *
37 * @param client ApolloClient instance
38 */
39 set client(client: ApolloClient<TCacheShape>);
40 private ensureClient;
41 private checkInstance;
42}
43export declare class Apollo extends ApolloBase<any> {
44 private _ngZone;
45 private map;
46 constructor(_ngZone: NgZone, apolloOptions?: ApolloClientOptions<any>, apolloNamedOptions?: NamedOptions, flags?: Flags);
47 /**
48 * Create an instance of ApolloClient
49 * @param options Options required to create ApolloClient
50 * @param name client's name
51 */
52 create<TCacheShape>(options: ApolloClientOptions<TCacheShape>, name?: string): void;
53 /**
54 * Use a default ApolloClient
55 */
56 default(): ApolloBase<any>;
57 /**
58 * Use a named ApolloClient
59 * @param name client's name
60 */
61 use(name: string): ApolloBase<any>;
62 /**
63 * Create a default ApolloClient, same as `apollo.create(options)`
64 * @param options ApolloClient's options
65 */
66 createDefault<TCacheShape>(options: ApolloClientOptions<TCacheShape>): void;
67 /**
68 * Create a named ApolloClient, same as `apollo.create(options, name)`
69 * @param name client's name
70 * @param options ApolloClient's options
71 */
72 createNamed<TCacheShape>(name: string, options: ApolloClientOptions<TCacheShape>): void;
73 /**
74 * Remember to clean up the store before removing a client
75 * @param name client's name
76 */
77 removeClient(name?: string): void;
78}