UNPKG

1.82 kBTypeScriptView Raw
1import { Headers, Request } from 'apollo-server-env';
2import type { BaseContext, GraphQLExecutionResult, ValueOrPromise, WithRequired } from 'apollo-server-types';
3import { default as GraphQLOptions } from './graphqlOptions';
4export interface HttpQueryRequest {
5 method: string;
6 query: Record<string, any> | Array<Record<string, any>>;
7 options: GraphQLOptions | ((...args: Array<any>) => ValueOrPromise<GraphQLOptions>);
8 request: Pick<Request, 'url' | 'method' | 'headers'>;
9}
10interface ApolloServerHttpResponse {
11 headers?: Record<string, string>;
12 status?: number;
13}
14interface HttpQueryResponse {
15 graphqlResponse: string;
16 responseInit: ApolloServerHttpResponse;
17}
18export declare class HttpQueryError extends Error {
19 statusCode: number;
20 isGraphQLError: boolean;
21 headers?: {
22 [key: string]: string;
23 };
24 constructor(statusCode: number, message: string, isGraphQLError?: boolean, headers?: {
25 [key: string]: string;
26 });
27}
28export declare function isHttpQueryError(e: unknown): e is HttpQueryError;
29export declare function throwHttpGraphQLError<E extends Error>(statusCode: number, errors: Array<E>, options?: Pick<GraphQLOptions, 'debug' | 'formatError'>, extensions?: GraphQLExecutionResult['extensions'], headers?: Headers): never;
30export declare function runHttpQuery(handlerArguments: Array<any>, request: HttpQueryRequest, csrfPreventionRequestHeaders?: string[] | null): Promise<HttpQueryResponse>;
31export declare function processHTTPRequest<TContext extends BaseContext>(options: WithRequired<GraphQLOptions<TContext>, 'cache' | 'plugins'> & {
32 context: TContext;
33}, httpRequest: HttpQueryRequest): Promise<HttpQueryResponse>;
34export declare function cloneObject<T extends Object>(object: T): T;
35export {};
36//# sourceMappingURL=runHttpQuery.d.ts.map
\No newline at end of file