apollo-angular
Version:
Use your GraphQL data in your Angular app, with the Apollo Client
51 lines (50 loc) • 1.97 kB
TypeScript
import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { ApolloLink } from '@apollo/client';
import type { HttpLink } from './http-link';
import { Context } from './types';
import { prioritize } from './utils';
import * as i0 from "@angular/core";
export declare namespace HttpBatchLink {
type Options = {
batchMax?: number;
batchInterval?: number;
batchKey?: (operation: ApolloLink.Operation) => string;
} & HttpLink.Options;
}
export declare const defaults: {
readonly batchInterval: 10;
readonly batchMax: 10;
readonly uri: "graphql";
readonly method: "POST";
readonly withCredentials: false;
readonly includeQuery: true;
readonly includeExtensions: false;
readonly useMultipart: false;
};
/**
* Decides which value to pick from Context, Options or defaults
*/
export declare function pick<K extends keyof Omit<typeof defaults, 'batchInterval' | 'batchMax'>>(context: Context, options: HttpBatchLink.Options, key: K): ReturnType<typeof prioritize<Context[K] | HttpBatchLink.Options[K] | (typeof defaults)[K]>>;
export 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>;
}
export 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>;
}