graphql-upload-ts
Version:
TypeScript-first middleware and Upload scalar for GraphQL multipart requests (file uploads) with support for Apollo Server, Express, Koa, and more.
33 lines • 1.32 kB
TypeScript
import type { IncomingMessage, ServerResponse } from 'node:http';
export declare const GRAPHQL_MULTIPART_REQUEST_SPEC_URL: "https://github.com/jaydenseric/graphql-multipart-request-spec";
export interface UploadOptions {
/**
* Maximum allowed size for non-file form fields (in bytes).
* This limits the size of text fields like 'operations' and 'map' JSON.
* @default 1_000_000 (1MB)
*/
maxFieldSize?: number;
/**
* Maximum allowed size for uploaded files (in bytes).
* This limits the size of actual file content being uploaded.
* @default 5_000_000 (5MB)
*/
maxFileSize?: number;
/**
* Maximum number of files allowed in a single request.
* @default Infinity
*/
maxFiles?: number;
}
export interface GraphQLOperation {
query: string;
operationName?: string | null;
variables?: Record<string, unknown> | null;
}
export type IncomingReq = Pick<IncomingMessage, 'headers' | 'pipe' | 'unpipe' | 'once' | 'resume' | 'readableEnded'> & {
body?: string;
rawBody?: string;
req?: IncomingMessage;
};
export declare function processRequest<T = GraphQLOperation | GraphQLOperation[]>(request: IncomingReq, response: Pick<ServerResponse, 'once'>, options?: UploadOptions): Promise<T>;
//# sourceMappingURL=process-request.d.ts.map