From 424716686ca17af2b4d6f18f71e34138780e4912 Mon Sep 17 00:00:00 2001 From: Isman Usoh Date: Tue, 1 Mar 2016 12:40:21 +0700 Subject: [PATCH] Create express-graphql.d.ts --- express-graphql/express-graphql.d.ts | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 express-graphql/express-graphql.d.ts diff --git a/express-graphql/express-graphql.d.ts b/express-graphql/express-graphql.d.ts new file mode 100644 index 000000000..537439dbe --- /dev/null +++ b/express-graphql/express-graphql.d.ts @@ -0,0 +1,52 @@ +// Type definitions for express-graphql +// Project: https://www.npmjs.org/package/express-graphql +// Definitions by: Isman Usoh , Nitin Tutlani +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "express-graphql" { + import { Request, Response } from "express"; + + /** + * Used to configure the graphQLHTTP middleware by providing a schema + * and other configuration options. + */ + export type Options = ((req: Request) => OptionsObj) | OptionsObj + export type OptionsObj = { + /** + * A GraphQL schema from graphql-js. + */ + schema: Object, + + /** + * An object to pass as the rootValue to the graphql() function. + */ + rootValue?: Object, + + /** + * A boolean to configure whether the output should be pretty-printed. + */ + pretty?: boolean, + + /** + * An optional function which will be used to format any errors produced by + * fulfilling a GraphQL operation. If no function is provided, GraphQL's + * default spec-compliant `formatError` function will be used. + */ + formatError?: Function, + + /** + * A boolean to optionally enable GraphiQL mode. + */ + graphiql?: boolean, + }; + + type Middleware = (request: Request, response: Response) => void; + + /** + * Middleware for express; takes an options object or function as input to + * configure behavior, and returns an express middleware. + */ + export default function graphqlHTTP(options: Options): Middleware; +}