UNPKG

1.83 kBTypeScriptView Raw
1import { GraphQLScalarType } from "graphql";
2import { ValidatorOptions } from "class-validator";
3import { PubSubEngine, PubSubOptions } from "graphql-subscriptions";
4import { AuthChecker, AuthMode } from "../interfaces";
5import { Middleware } from "../interfaces/Middleware";
6import { ContainerType, ContainerGetter, IOCContainer } from "../utils/container";
7export declare type DateScalarMode = "isoDate" | "timestamp";
8export interface ScalarsTypeMap {
9 type: Function;
10 scalar: GraphQLScalarType;
11}
12export interface BuildContextOptions {
13 dateScalarMode?: DateScalarMode;
14 scalarsMap?: ScalarsTypeMap[];
15 /**
16 * Indicates if class-validator should be used to auto validate objects injected into params.
17 * You can also directly pass validator options to enable validator with a given options.
18 */
19 validate?: boolean | ValidatorOptions;
20 authChecker?: AuthChecker<any, any>;
21 authMode?: AuthMode;
22 pubSub?: PubSubEngine | PubSubOptions;
23 globalMiddlewares?: Array<Middleware<any>>;
24 container?: ContainerType | ContainerGetter<any>;
25 /**
26 * Default value for type decorators, like `@Field({ nullable: true })`
27 */
28 nullableByDefault?: boolean;
29}
30export declare abstract class BuildContext {
31 static dateScalarMode: DateScalarMode;
32 static scalarsMaps: ScalarsTypeMap[];
33 static validate: boolean | ValidatorOptions;
34 static authChecker?: AuthChecker<any, any>;
35 static authMode: AuthMode;
36 static pubSub: PubSubEngine;
37 static globalMiddlewares: Array<Middleware<any>>;
38 static container: IOCContainer;
39 static nullableByDefault: boolean;
40 /**
41 * Set static fields with current building context data
42 */
43 static create(options: BuildContextOptions): void;
44 /**
45 * Restore default settings
46 */
47 static reset(): void;
48}