UNPKG

3.38 kBTypeScriptView Raw
1import { IResolvers, IResolverValidationOptions } from '@graphql-tools/utils';
2import { Type } from '@nestjs/common';
3import { ModuleMetadata } from '@nestjs/common/interfaces';
4import { GraphQLSchema } from 'graphql';
5import { GraphQLDriver } from '.';
6import { DefinitionsGeneratorOptions } from '../graphql-ast.explorer';
7import { BuildSchemaOptions } from './build-schema-options.interface';
8export declare type Enhancer = 'guards' | 'interceptors' | 'filters';
9/**
10 * "GraphQLModule" options object.
11 */
12export interface GqlModuleOptions<TDriver extends GraphQLDriver = any> {
13 /**
14 * Path to mount GraphQL API
15 */
16 path?: string;
17 /**
18 * Type definitions
19 */
20 typeDefs?: string | string[];
21 /**
22 * Paths to files that contain GraphQL definitions
23 */
24 typePaths?: string[];
25 /**
26 * GraphQL server adapter
27 */
28 driver?: Type<TDriver>;
29 /**
30 * An array of modules to scan when searching for resolvers
31 */
32 include?: Function[];
33 /**
34 * Directive resolvers
35 */
36 directiveResolvers?: any;
37 /**
38 * Optional GraphQL schema (to be used or to be merged)
39 */
40 schema?: GraphQLSchema;
41 /**
42 * Extra resolvers to be registered.
43 */
44 resolvers?: IResolvers | Array<IResolvers>;
45 /**
46 * TypeScript definitions generator options
47 */
48 definitions?: {
49 path?: string;
50 outputAs?: 'class' | 'interface';
51 } & DefinitionsGeneratorOptions;
52 /**
53 * If enabled, GraphQL schema will be generated automatically
54 */
55 autoSchemaFile?: string | boolean;
56 /**
57 * Sort the schema lexicographically
58 */
59 sortSchema?: boolean;
60 /**
61 * Options to be passed to the schema generator
62 * Only applicable if "autoSchemaFile" = true
63 */
64 buildSchemaOptions?: BuildSchemaOptions;
65 /**
66 * Prepends the global prefix to the url
67 *
68 * @see [faq/global-prefix](Global Prefix)
69 */
70 useGlobalPrefix?: boolean;
71 /**
72 * Enable/disable enhancers for @ResolveField()
73 */
74 fieldResolverEnhancers?: Enhancer[];
75 /**
76 * Resolver validation options.
77 */
78 resolverValidationOptions?: IResolverValidationOptions;
79 /**
80 * Inherit missing resolvers from their interface types defined in the resolvers object.
81 */
82 inheritResolversFromInterfaces?: boolean;
83 /**
84 * Function to be applied to the schema letting you register custom transformations.
85 */
86 transformSchema?: (schema: GraphQLSchema) => GraphQLSchema | Promise<GraphQLSchema>;
87 /**
88 * Apply `transformSchema` to the `autoSchemaFile`
89 */
90 transformAutoSchemaFile?: boolean;
91 /**
92 * Context function
93 */
94 context?: any;
95}
96export interface GqlOptionsFactory<T extends Record<string, any> = GqlModuleOptions> {
97 createGqlOptions(): Promise<Omit<T, 'driver'>> | Omit<T, 'driver'>;
98}
99export interface GqlModuleAsyncOptions<TOptions extends Record<string, any> = GqlModuleOptions, TFactory = GqlOptionsFactory<TOptions>> extends Pick<ModuleMetadata, 'imports'> {
100 /**
101 * GraphQL server driver
102 */
103 driver?: TOptions['driver'];
104 useExisting?: Type<TFactory>;
105 useClass?: Type<TFactory>;
106 useFactory?: (...args: any[]) => Promise<Omit<TOptions, 'driver'>> | Omit<TOptions, 'driver'>;
107 inject?: any[];
108}
109//# sourceMappingURL=gql-module-options.interface.d.ts.map
\No newline at end of file