UNPKG

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