16.0.7 • Published 4 months ago

@types/graphql-upload v16.0.7

Weekly downloads
920,866
License
MIT
Repository
github
Last release
4 months ago

Installation

npm install --save @types/graphql-upload

Summary

This package contains type definitions for graphql-upload (https://github.com/jaydenseric/graphql-upload#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/graphql-upload.

index.d.ts

// 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: 4.1

/* tslint:disable:no-unnecessary-generics */

import { IncomingMessage, ServerResponse } from "http";
import { GraphQLScalarType } from "graphql";
import { RequestHandler } from "express";
import { DefaultContext, DefaultState, Middleware } from "koa";
import { ReadStream } from "fs-capacitor";

export interface UploadOptions {
  maxFieldSize?: number | undefined;
  maxFileSize?: number | undefined;
  maxFiles?: number | undefined;
}

export interface GraphQLOperation {
  query: string;
  operationName?: null | string | undefined;
  variables?: null | unknown | undefined;
}

export function processRequest(
  request: IncomingMessage,
  response: ServerResponse,
  uploadOptions?: UploadOptions
): Promise<GraphQLOperation | GraphQLOperation[]>;

export function graphqlUploadExpress(
  uploadOptions?: UploadOptions
): RequestHandler;

export function graphqlUploadKoa <StateT = DefaultState, ContextT = DefaultContext>(
  uploadOptions?: UploadOptions
): Middleware<StateT, ContextT>;

export const GraphQLUpload: GraphQLScalarType;

export interface FileUpload {
  filename: string;
  mimetype: string;
  encoding: string;
  createReadStream(): ReadStream;
}

export class Upload {
  promise: Promise<FileUpload>;
  file?: FileUpload;
}

Additional Details

Credits

These definitions were written by Mike Marcacci.