UNPKG

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