forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpress-graphql.d.ts
60 lines (50 loc) · 1.97 KB
/
express-graphql.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Type definitions for express-graphql
// Project: https://www.npmjs.org/package/express-graphql
// Definitions by: Isman Usoh <https://github.com/isman-usoh>, Nitin Tutlani <https://github.com/nitintutlani>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../express/express.d.ts" />
declare module "express-graphql" {
import { Request, Response } from "express";
namespace graphqlHTTP {
/**
* 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,
/**
* A value to pass as the context to the graphql() function.
*/
context?: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.
*/
function graphqlHTTP(options: graphqlHTTP.Options): graphqlHTTP.Middleware;
export = graphqlHTTP;
}