Add graphql-upload (#35276)

This commit is contained in:
Mike Marcacci
2019-05-13 10:46:51 -07:00
committed by Nathan Shively-Sanders
parent 8484eda4b8
commit f832cffd77
4 changed files with 76 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
import express from "express";
import Koa from "koa";
import { graphqlUploadExpress, graphqlUploadKoa } from "graphql-upload";
express()
.use(graphqlUploadExpress({ maxFileSize: 10000000, maxFiles: 10 }))
.listen(3000);
new Koa()
.use(graphqlUploadKoa({ maxFileSize: 10000000, maxFiles: 10 }))
.listen(3000);

40
types/graphql-upload/index.d.ts vendored Normal file
View File

@@ -0,0 +1,40 @@
// Type definitions for graphql-upload 8.0
// Project: https://github.com/jaydenseric/graphql-upload#readme
// Definitions by: Mike Marcacci <https://github.com/mike-marcacci>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.3
/* tslint:disable:no-unnecessary-generics */
import { IncomingMessage, ServerResponse } from "http";
import { GraphQLScalarType } from "graphql";
import { RequestHandler } from "express";
import { Middleware } from "koa";
export interface UploadOptions {
maxFieldSize?: number;
maxFileSize?: number;
maxFiles?: number;
}
export interface GraphQLOperation {
query: string;
operationName?: null | string;
variables?: null | unknown;
}
export function processRequest(
request: IncomingMessage,
response: ServerResponse,
uploadOptions?: UploadOptions
): Promise<GraphQLOperation | GraphQLOperation[]>;
export function graphqlUploadExpress(
uploadOptions?: UploadOptions
): RequestHandler;
export function graphqlUploadKoa <StateT = any, CustomT = {}>(
uploadOptions?: UploadOptions
): Middleware<StateT, CustomT>;
export const GraphQLUpload: GraphQLScalarType;

View File

@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true
},
"files": [
"index.d.ts",
"graphql-upload-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }