altair-graphql-core
Version:
Several of the core logic for altair graphql client
94 lines • 2.84 kB
TypeScript
import { Observable } from 'rxjs';
import { HeaderState } from '../types/state/header.interfaces';
import { SelectedOperation } from '../types/state/query.interfaces';
interface ResolvedFileVariable {
name: string;
data: File;
}
export interface GraphQLRequestOptions {
url: string;
query: string;
method: string;
withCredentials?: boolean;
variables?: Record<string, unknown>;
extensions?: Record<string, unknown>;
headers?: HeaderState;
files?: ResolvedFileVariable[];
selectedOperation?: SelectedOperation;
batchedRequest?: boolean;
additionalParams?: Record<string, unknown>;
}
export interface GraphQLResponseData {
ok: boolean;
data: string;
headers: Headers;
status: number;
statusText: string;
url: string;
/**
* The timestamp when the request was started
*/
requestStartTimestamp: number;
/**
* The timestamp when the request was ended
*/
requestEndTimestamp: number;
/**
* The time taken to get the response in milliseconds
*/
resopnseTimeMs: number;
}
export interface GraphQLRequestHandler {
handle(request: GraphQLRequestOptions): Observable<GraphQLResponseData>;
generateCurl?(request: GraphQLRequestOptions): string;
destroy?(): void;
}
export declare enum MultiResponseStrategy {
/**
* Automatically determine the strategy based on the response
*/
AUTO = "auto",
/**
* Concatenate all responses
*/
CONCATENATE = "concatenate",
/**
* Append responses as a list
*/
APPEND = "append",
/**
* Patch the responses together following the GraphQL spec
*/
PATCH = "patch"
}
export declare const HTTP_HANDLER_ID = "http";
export declare const WEBSOCKET_HANDLER_ID = "websocket";
export declare const GRAPHQL_WS_HANDLER_ID = "graphql-ws";
export declare const APP_SYNC_HANDLER_ID = "app-sync";
export declare const ACTION_CABLE_HANDLER_ID = "action-cable";
export declare const GRAPHQL_SSE_HANDLER_ID = "graphql-sse";
export declare const REQUEST_HANDLER_IDS: {
readonly HTTP: "http";
readonly WEBSOCKET: "websocket";
readonly GRAPHQL_WS: "graphql-ws";
readonly APP_SYNC: "app-sync";
readonly ACTION_CABLE: "action-cable";
readonly GRAPHQL_SSE: "graphql-sse";
};
export type RequestHandlerIds = (typeof REQUEST_HANDLER_IDS)[keyof typeof REQUEST_HANDLER_IDS];
export interface RequestHandlerData {
/**
* Unique identifier for the handler
*/
id: string;
/**
* Function that returns a promise that resolves with the handler class (NOT an instance of the class)
*/
getHandler: () => Promise<GraphQLRequestHandler>;
/**
* The text to be shown for this handler in the Altair UI
*/
copyTag?: string;
}
export {};
//# sourceMappingURL=types.d.ts.map