UNPKG

2.42 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/graphql-upload`
3
4# Summary
5This package contains type definitions for graphql-upload (https://github.com/jaydenseric/graphql-upload#readme).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/graphql-upload.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/graphql-upload/index.d.ts)
10````ts
11// Type definitions for graphql-upload 8.0
12// Project: https://github.com/jaydenseric/graphql-upload#readme
13// Definitions by: Mike Marcacci <https://github.com/mike-marcacci>
14// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
15// TypeScript Version: 4.1
16
17/* tslint:disable:no-unnecessary-generics */
18
19import { IncomingMessage, ServerResponse } from "http";
20import { GraphQLScalarType } from "graphql";
21import { RequestHandler } from "express";
22import { DefaultContext, DefaultState, Middleware } from "koa";
23import { ReadStream } from "fs-capacitor";
24
25export interface UploadOptions {
26 maxFieldSize?: number | undefined;
27 maxFileSize?: number | undefined;
28 maxFiles?: number | undefined;
29}
30
31export interface GraphQLOperation {
32 query: string;
33 operationName?: null | string | undefined;
34 variables?: null | unknown | undefined;
35}
36
37export function processRequest(
38 request: IncomingMessage,
39 response: ServerResponse,
40 uploadOptions?: UploadOptions
41): Promise<GraphQLOperation | GraphQLOperation[]>;
42
43export function graphqlUploadExpress(
44 uploadOptions?: UploadOptions
45): RequestHandler;
46
47export function graphqlUploadKoa <StateT = DefaultState, ContextT = DefaultContext>(
48 uploadOptions?: UploadOptions
49): Middleware<StateT, ContextT>;
50
51export const GraphQLUpload: GraphQLScalarType;
52
53export interface FileUpload {
54 filename: string;
55 mimetype: string;
56 encoding: string;
57 createReadStream(): ReadStream;
58}
59
60export class Upload {
61 promise: Promise<FileUpload>;
62 file?: FileUpload;
63}
64
65````
66
67### Additional Details
68 * Last updated: Thu, 17 Feb 2022 18:01:34 GMT
69 * Dependencies: [@types/graphql](https://npmjs.com/package/@types/graphql), [@types/express](https://npmjs.com/package/@types/express), [@types/koa](https://npmjs.com/package/@types/koa), [@types/fs-capacitor](https://npmjs.com/package/@types/fs-capacitor)
70 * Global values: none
71
72# Credits
73These definitions were written by [Mike Marcacci](https://github.com/mike-marcacci).
74
\No newline at end of file