UNPKG

6.77 kBTypeScriptView Raw
1import { TypeStorage } from './TypeStorage';
2import { TypeMapper } from './TypeMapper';
3import { ObjectTypeComposer, ObjectTypeComposerDefinition } from './ObjectTypeComposer';
4import { InputTypeComposer, InputTypeComposerDefinition } from './InputTypeComposer';
5import { ScalarTypeComposer, ScalarTypeComposerDefinition } from './ScalarTypeComposer';
6import { EnumTypeComposer, EnumTypeComposerDefinition } from './EnumTypeComposer';
7import { InterfaceTypeComposer, InterfaceTypeComposerDefinition } from './InterfaceTypeComposer';
8import { UnionTypeComposer, UnionTypeComposerDefinition } from './UnionTypeComposer';
9import { Resolver, ResolverDefinition } from './Resolver';
10import { AnyType, NamedTypeComposer, ComposeInputTypeDefinition, ComposeOutputTypeDefinition } from './utils/typeHelpers';
11import { GraphQLSchema, GraphQLDirective, GraphQLType, GraphQLNamedType, SchemaDefinitionNode, GraphQLResolveInfo, SchemaExtensionNode, GraphQLScalarTypeConfig } from './graphql';
12import { SchemaPrinterOptions, SchemaComposerPrinterOptions } from './utils/schemaPrinter';
13declare type ExtraSchemaConfig = {
14 description?: string | null;
15 types?: GraphQLNamedType[] | null;
16 directives?: GraphQLDirective[] | null;
17 extensions?: any | null;
18 astNode?: SchemaDefinitionNode | null;
19 extensionASTNodes?: ReadonlyArray<SchemaExtensionNode> | null;
20 keepUnusedTypes?: boolean | null;
21};
22export declare type GraphQLToolsResolveMethods<TContext> = {
23 [typeName: string]: {
24 [fieldName: string]: ((source: any, args: Record<string, any>, context: TContext, info: GraphQLResolveInfo) => any) | string | number | Record<string, any>;
25 } | GraphQLNamedType | GraphQLScalarTypeConfig<any, any>;
26};
27export declare const BUILT_IN_DIRECTIVES: GraphQLDirective[];
28export declare class SchemaComposer<TContext = any> extends TypeStorage<any, NamedTypeComposer<TContext>> {
29 typeMapper: TypeMapper<TContext>;
30 _schemaMustHaveTypes: Array<AnyType<TContext>>;
31 _directives: Array<GraphQLDirective>;
32 _description: string | undefined;
33 constructor(schemaOrSDL?: GraphQLSchema | string);
34 get Query(): ObjectTypeComposer<any, TContext>;
35 get Mutation(): ObjectTypeComposer<any, TContext>;
36 get Subscription(): ObjectTypeComposer<any, TContext>;
37 buildSchema(extraConfig?: ExtraSchemaConfig): GraphQLSchema;
38 addSchemaMustHaveType(type: AnyType<TContext>): this;
39 removeEmptyTypes(tc: ObjectTypeComposer<any, TContext>, passedTypes?: Set<string>): void;
40 clone(): SchemaComposer<any>;
41 merge(schema: GraphQLSchema | SchemaComposer<any>): this;
42 getDescription(): string | undefined;
43 setDescription(description: string | undefined): this;
44 addTypeDefs(typeDefs: string): TypeStorage<string, NamedTypeComposer<any>>;
45 addResolveMethods(typesFieldsResolve: GraphQLToolsResolveMethods<TContext>): void;
46 createObjectTC<TSource = any>(typeDef: ObjectTypeComposerDefinition<TSource, TContext>): ObjectTypeComposer<TSource, TContext>;
47 createInputTC(typeDef: InputTypeComposerDefinition): InputTypeComposer<TContext>;
48 createEnumTC(typeDef: EnumTypeComposerDefinition): EnumTypeComposer<TContext>;
49 createInterfaceTC<TSource = any>(typeDef: InterfaceTypeComposerDefinition<TSource, TContext>): InterfaceTypeComposer<TSource, TContext>;
50 createUnionTC<TSource = any>(typeDef: UnionTypeComposerDefinition<TSource, TContext>): UnionTypeComposer<TSource, TContext>;
51 createScalarTC<TInternal = any, TExternal = any>(typeDef: ScalarTypeComposerDefinition<TInternal, TExternal>): ScalarTypeComposer<TContext>;
52 createResolver<TSource = any, TArgs = any>(opts: ResolverDefinition<TSource, TContext, TArgs>): Resolver<any, TContext>;
53 createTC(typeOrSDL: ComposeOutputTypeDefinition<any> | ComposeInputTypeDefinition): NamedTypeComposer<TContext>;
54 createTempTC(typeOrSDL: ComposeOutputTypeDefinition<any> | ComposeInputTypeDefinition): NamedTypeComposer<TContext>;
55 getOrCreateTC(typeName: string, onCreate?: (tc: ObjectTypeComposer<any, TContext>) => any): ObjectTypeComposer<any, TContext>;
56 getOrCreateOTC(typeName: string, onCreate?: (tc: ObjectTypeComposer<any, TContext>) => any): ObjectTypeComposer<any, TContext>;
57 getOrCreateITC(typeName: string, onCreate?: (tc: InputTypeComposer<TContext>) => any): InputTypeComposer<TContext>;
58 getOrCreateETC(typeName: string, onCreate?: (tc: EnumTypeComposer<TContext>) => any): EnumTypeComposer<TContext>;
59 getOrCreateIFTC(typeName: string, onCreate?: (tc: InterfaceTypeComposer<any, TContext>) => any): InterfaceTypeComposer<any, TContext>;
60 getOrCreateUTC(typeName: string, onCreate?: (tc: UnionTypeComposer<any, TContext>) => any): UnionTypeComposer<any, TContext>;
61 getOrCreateSTC(typeName: string, onCreate?: (tc: ScalarTypeComposer<TContext>) => any): ScalarTypeComposer<TContext>;
62 getOTC(typeName: unknown): ObjectTypeComposer<any, TContext>;
63 getITC(typeName: unknown): InputTypeComposer<TContext>;
64 getETC(typeName: unknown): EnumTypeComposer<TContext>;
65 getIFTC(typeName: unknown): InterfaceTypeComposer<any, TContext>;
66 getUTC(typeName: unknown): UnionTypeComposer<any, TContext>;
67 getSTC(typeName: unknown): ScalarTypeComposer<TContext>;
68 getAnyTC(typeOrName: string | AnyType<any> | GraphQLType): NamedTypeComposer<TContext>;
69 addAsComposer(typeOrSDL: ComposeOutputTypeDefinition<any> | ComposeInputTypeDefinition): string;
70 isObjectType(type: string | AnyType<any> | GraphQLType): boolean;
71 isInputObjectType(type: string | AnyType<any> | GraphQLType): boolean;
72 isScalarType(type: string | AnyType<any> | GraphQLType): boolean;
73 isEnumType(type: string | AnyType<any> | GraphQLType): boolean;
74 isInterfaceType(type: string | AnyType<any> | GraphQLType): boolean;
75 isUnionType(type: string | AnyType<any> | GraphQLType): boolean;
76 clear(): void;
77 add(typeOrSDL: ComposeOutputTypeDefinition<any> | ComposeInputTypeDefinition): string;
78 set(key: unknown, value: NamedTypeComposer<TContext>): this;
79 addDirective(directive: GraphQLDirective): this;
80 removeDirective(directive: GraphQLDirective): this;
81 getDirectives(): Array<GraphQLDirective>;
82 _getDirective(name: string): GraphQLDirective | undefined;
83 getDirective(name: string): GraphQLDirective;
84 hasDirective(directive: string | GraphQLDirective): boolean;
85 toString(): string;
86 toJSON(): string;
87 inspect(): string;
88 getTypeSDL(typeName: string, opts?: SchemaPrinterOptions & {
89 deep?: boolean;
90 exclude?: string[];
91 }): string;
92 toSDL(options?: SchemaComposerPrinterOptions): string;
93 getResolveMethods(opts?: {
94 exclude?: string[] | null;
95 }): GraphQLToolsResolveMethods<TContext>;
96}
97export {};
98//# sourceMappingURL=SchemaComposer.d.ts.map
\No newline at end of file