UNPKG

3.49 kBTypeScriptView Raw
1import { Observable } from 'rxjs';
2import { NgZone } from '@angular/core';
3import type { ApolloClientOptions, ApolloQueryResult, FetchResult, OperationVariables, QueryOptions, SubscriptionOptions, WatchFragmentResult } from '@apollo/client/core';
4import { ApolloClient } from '@apollo/client/core';
5import { QueryRef } from './query-ref';
6import type { EmptyObject, ExtraSubscriptionOptions, Flags, MutationOptions, MutationResult, NamedOptions, WatchFragmentOptions, WatchQueryOptions } from './types';
7import * as i0 from "@angular/core";
8export declare class ApolloBase<TCacheShape = any> {
9 protected readonly ngZone: NgZone;
10 protected readonly 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 watchFragment<TFragmentData = unknown, TVariables extends OperationVariables = EmptyObject>(options: WatchFragmentOptions<TFragmentData, TVariables>, extra?: ExtraSubscriptionOptions): Observable<WatchFragmentResult<TFragmentData>>;
19 subscribe<T, V extends OperationVariables = EmptyObject>(options: SubscriptionOptions<V, T>, extra?: ExtraSubscriptionOptions): Observable<FetchResult<T>>;
20 /**
21 * Get an instance of ApolloClient
22 */
23 get client(): ApolloClient<TCacheShape>;
24 /**
25 * Set a new instance of ApolloClient
26 * Remember to clean up the store before setting a new client.
27 *
28 * @param client ApolloClient instance
29 */
30 set client(client: ApolloClient<TCacheShape>);
31 private ensureClient;
32 private checkInstance;
33}
34export declare class Apollo extends ApolloBase<any> {
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}