UNPKG

1.48 kBTypeScriptView Raw
1// Type definitions for graphql-upload 8.0
2// Project: https://github.com/jaydenseric/graphql-upload#readme
3// Definitions by: Mike Marcacci <https://github.com/mike-marcacci>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5// TypeScript Version: 4.1
6
7/* tslint:disable:no-unnecessary-generics */
8
9import { IncomingMessage, ServerResponse } from "http";
10import { GraphQLScalarType } from "graphql";
11import { RequestHandler } from "express";
12import { DefaultContext, DefaultState, Middleware } from "koa";
13import { ReadStream } from "fs-capacitor";
14
15export interface UploadOptions {
16 maxFieldSize?: number | undefined;
17 maxFileSize?: number | undefined;
18 maxFiles?: number | undefined;
19}
20
21export interface GraphQLOperation {
22 query: string;
23 operationName?: null | string | undefined;
24 variables?: null | unknown | undefined;
25}
26
27export function processRequest(
28 request: IncomingMessage,
29 response: ServerResponse,
30 uploadOptions?: UploadOptions
31): Promise<GraphQLOperation | GraphQLOperation[]>;
32
33export function graphqlUploadExpress(
34 uploadOptions?: UploadOptions
35): RequestHandler;
36
37export function graphqlUploadKoa <StateT = DefaultState, ContextT = DefaultContext>(
38 uploadOptions?: UploadOptions
39): Middleware<StateT, ContextT>;
40
41export const GraphQLUpload: GraphQLScalarType;
42
43export interface FileUpload {
44 filename: string;
45 mimetype: string;
46 encoding: string;
47 createReadStream(): ReadStream;
48}
49
50export type Upload = Promise<FileUpload>;