apollo-angular
Version:
Use your GraphQL data in your Angular app, with the Apollo Client
96 lines (91 loc) • 3.16 kB
TypeScript
import { Observable } from 'rxjs';
import { HttpHeaders, HttpContext, HttpClient } from '@angular/common/http';
import { ApolloLink } from '@apollo/client';
import { DocumentNode } from 'graphql';
import * as i0 from '@angular/core';
declare module '@apollo/client' {
interface DefaultContext extends Context {
}
}
type HttpRequestOptions = {
headers?: HttpHeaders | Record<string, string>;
withCredentials?: boolean;
useMultipart?: boolean;
httpContext?: HttpContext;
};
type RequestOptions = Omit<HttpRequestOptions, 'headers'> & {
headers?: HttpHeaders;
};
type URIFunction = (operation: ApolloLink.Operation) => string;
type FetchOptions = {
method?: string;
uri?: string | URIFunction;
includeExtensions?: boolean;
includeQuery?: boolean;
};
type OperationPrinter = (operation: DocumentNode) => string;
type Body = {
query?: string;
variables?: Record<string, any>;
operationName?: string;
extensions?: Record<string, any>;
};
interface Context extends FetchOptions, HttpRequestOptions {
}
type ExtractedFiles = {
clone: unknown;
files: Map<any, any>;
};
type ExtractFiles = (body: Body | Body[]) => ExtractedFiles;
declare class HttpLinkHandler extends ApolloLink {
private readonly httpClient;
private readonly options;
requester: (operation: ApolloLink.Operation) => Observable<ApolloLink.Result>;
private print;
constructor(httpClient: HttpClient, options: HttpLink.Options);
request(op: ApolloLink.Operation): Observable<ApolloLink.Result>;
}
declare namespace HttpLink {
interface Options extends FetchOptions, RequestOptions {
operationPrinter?: OperationPrinter;
useGETForQueries?: boolean;
extractFiles?: ExtractFiles;
}
}
declare class HttpLink {
private readonly httpClient;
constructor(httpClient: HttpClient);
create(options: HttpLink.Options): HttpLinkHandler;
static ɵfac: i0.ɵɵFactoryDeclaration<HttpLink, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<HttpLink>;
}
declare class HttpBatchLinkHandler extends ApolloLink {
private readonly httpClient;
private readonly options;
batcher: ApolloLink;
private batchInterval;
private batchMax;
private print;
constructor(httpClient: HttpClient, options: HttpBatchLink.Options);
private createOptions;
private createBody;
private createHeaders;
private createHttpContext;
private createBatchKey;
request(op: ApolloLink.Operation, forward: ApolloLink.ForwardFunction): Observable<ApolloLink.Result>;
}
declare namespace HttpBatchLink {
type Options = {
batchMax?: number;
batchInterval?: number;
batchKey?: (operation: ApolloLink.Operation) => string;
} & HttpLink.Options;
}
declare class HttpBatchLink {
private readonly httpClient;
constructor(httpClient: HttpClient);
create(options: HttpBatchLink.Options): HttpBatchLinkHandler;
static ɵfac: i0.ɵɵFactoryDeclaration<HttpBatchLink, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<HttpBatchLink>;
}
export { HttpBatchLink, HttpBatchLinkHandler, HttpLink, HttpLinkHandler };