1 | export interface ApolloFetch {
|
2 | (operation: GraphQLRequest): Promise<FetchResult>;
|
3 | (operation: GraphQLRequest[]): Promise<FetchResult[]>;
|
4 | use: (middlewares: MiddlewareInterface) => ApolloFetch;
|
5 | useAfter: (afterwares: AfterwareInterface) => ApolloFetch;
|
6 | batchUse: (middlewares: BatchMiddlewareInterface) => ApolloFetch;
|
7 | batchUseAfter: (afterwares: BatchAfterwareInterface) => ApolloFetch;
|
8 | }
|
9 | export interface GraphQLRequest {
|
10 | query?: string;
|
11 | variables?: object;
|
12 | operationName?: string;
|
13 | }
|
14 | export interface FetchResult {
|
15 | data: any;
|
16 | errors?: any;
|
17 | extensions?: any;
|
18 | }
|
19 | export declare type MiddlewareInterface = (request: RequestAndOptions, next: Function) => void;
|
20 | export declare type BatchMiddlewareInterface = (requests: RequestsAndOptions, next: Function) => void;
|
21 | export interface RequestAndOptions {
|
22 | request: GraphQLRequest;
|
23 | options: RequestInit;
|
24 | }
|
25 | export interface RequestsAndOptions {
|
26 | requests: GraphQLRequest[];
|
27 | options: RequestInit;
|
28 | }
|
29 | export declare type AfterwareInterface = (response: ResponseAndOptions, next: Function) => void;
|
30 | export declare type BatchAfterwareInterface = (response: ResponseAndOptions, next: Function) => void;
|
31 | export interface ResponseAndOptions {
|
32 | response: ParsedResponse;
|
33 | options: RequestInit;
|
34 | }
|
35 | export interface ParsedResponse extends Response {
|
36 | raw: string;
|
37 | parsed?: any;
|
38 | }
|
39 | export interface FetchOptions {
|
40 | uri?: string;
|
41 | customFetch?: (request: RequestInfo, init: RequestInit) => Promise<Response>;
|
42 | constructOptions?: (requestOrRequests: GraphQLRequest | GraphQLRequest[], options: RequestInit) => RequestInit;
|
43 | }
|
44 | export interface FetchError extends Error {
|
45 | response: ParsedResponse;
|
46 | parseError?: Error;
|
47 | }
|
48 | export interface BatchError extends Error {
|
49 | response: ParsedResponse;
|
50 | }
|