UNPKG

7.94 kBTypeScriptView Raw
1import type { DocumentNode, ScalarTypeDefinitionNode, ObjectTypeDefinitionNode, InterfaceTypeDefinitionNode, UnionTypeDefinitionNode, SchemaDefinitionNode, DirectiveDefinitionNode, TypeNode, NamedTypeNode, DirectiveNode, InputValueDefinitionNode, EnumTypeDefinitionNode, InputObjectTypeDefinitionNode, DefinitionNode, ObjectTypeExtensionNode, InputObjectTypeExtensionNode, InterfaceTypeExtensionNode, UnionTypeExtensionNode, EnumTypeExtensionNode, ScalarTypeExtensionNode, StringValueNode, Location } from 'graphql/language/ast';
2import { GraphQLDirective } from './graphql';
3import type { GraphQLType } from './graphql';
4import type { InputTypeComposerFieldConfigMap, InputTypeComposerFieldConfigMapDefinition, InputTypeComposerFieldConfig, InputTypeComposerFieldConfigDefinition } from './InputTypeComposer';
5import type { ObjectTypeComposerFieldConfig, ObjectTypeComposerFieldConfigDefinition, ObjectTypeComposerFieldConfigMap, ObjectTypeComposerFieldConfigMapDefinition, ObjectTypeComposerArgumentConfig, ObjectTypeComposerArgumentConfigDefinition, ObjectTypeComposerArgumentConfigMap, ObjectTypeComposerArgumentConfigMapDefinition, ObjectTypeComposerDefinition } from './ObjectTypeComposer';
6import { ObjectTypeComposer } from './ObjectTypeComposer';
7import type { SchemaComposer } from './SchemaComposer';
8import { InputTypeComposer } from './InputTypeComposer';
9import { ScalarTypeComposer } from './ScalarTypeComposer';
10import { EnumTypeComposer, EnumTypeComposerValueConfigMapDefinition } from './EnumTypeComposer';
11import { InterfaceTypeComposer, InterfaceTypeComposerDefinition, InterfaceTypeComposerThunked } from './InterfaceTypeComposer';
12import { UnionTypeComposer } from './UnionTypeComposer';
13import { Resolver } from './Resolver';
14import { TypeStorage } from './TypeStorage';
15import type { ThunkWithSchemaComposer, Directive } from './utils/definitions';
16import { AnyTypeComposer, ComposeOutputType, ComposeOutputTypeDefinition, ComposeInputType, ComposeInputTypeDefinition, NamedTypeComposer } from './utils/typeHelpers';
17export declare type TypeDefinitionString = string;
18export declare type TypeWrappedString = string;
19export declare type TypeNameString = string;
20export declare type TypeAsString = TypeDefinitionString | TypeWrappedString | TypeNameString;
21export declare class TypeMapper<TContext = any> {
22 schemaComposer: SchemaComposer<TContext>;
23 constructor(schemaComposer: SchemaComposer<TContext>);
24 static isOutputType(type: unknown): boolean;
25 static isInputType(type: unknown): boolean;
26 static isTypeNameString(str: string): boolean;
27 static isTypeDefinitionString(str: string): boolean;
28 static isOutputTypeDefinitionString(str: string): boolean;
29 static isInputTypeDefinitionString(str: string): boolean;
30 static isEnumTypeDefinitionString(str: string): boolean;
31 static isScalarTypeDefinitionString(str: string): boolean;
32 static isInterfaceTypeDefinitionString(str: string): boolean;
33 static isUnionTypeDefinitionString(str: string): boolean;
34 convertGraphQLTypeToComposer(type: GraphQLType): AnyTypeComposer<TContext>;
35 convertSDLWrappedTypeName(str: TypeWrappedString | TypeNameString): AnyTypeComposer<TContext>;
36 convertSDLTypeDefinition(str: TypeDefinitionString): NamedTypeComposer<TContext> | void;
37 convertOutputTypeDefinition(typeDef: ThunkWithSchemaComposer<ComposeOutputTypeDefinition<any> | ObjectTypeComposerDefinition<any, any> | Readonly<Resolver<any, any>>, SchemaComposer<TContext>>, fieldName?: string, typeName?: string): ComposeOutputType<TContext> | void;
38 convertOutputFieldConfig<TSource>(composeFC: ObjectTypeComposerFieldConfigDefinition<TSource, TContext> | Readonly<Resolver<any, TContext>>, fieldName?: string, typeName?: string): ObjectTypeComposerFieldConfig<TSource, TContext>;
39 convertOutputFieldConfigMap<TSource>(composeFields: ObjectTypeComposerFieldConfigMapDefinition<TSource, TContext>, typeName?: string): ObjectTypeComposerFieldConfigMap<TSource, TContext>;
40 convertArgConfig(composeAC: ObjectTypeComposerArgumentConfigDefinition, argName?: string, fieldName?: string, typeName?: string): ObjectTypeComposerArgumentConfig;
41 convertArgConfigMap(composeArgsConfigMap: ObjectTypeComposerArgumentConfigMapDefinition<any>, fieldName?: string, typeName?: string): ObjectTypeComposerArgumentConfigMap<any>;
42 convertInputTypeDefinition(typeDef: ThunkWithSchemaComposer<ComposeInputTypeDefinition, SchemaComposer<TContext>>, fieldName?: string, typeName?: string): ComposeInputType | void;
43 convertInputFieldConfig(composeIFC: InputTypeComposerFieldConfigDefinition, fieldName?: string, typeName?: string): InputTypeComposerFieldConfig;
44 convertInputFieldConfigMap(composeFields: InputTypeComposerFieldConfigMapDefinition, typeName?: string): InputTypeComposerFieldConfigMap;
45 convertInterfaceTypeDefinition(typeDef: InterfaceTypeComposerDefinition<any, TContext>): InterfaceTypeComposerThunked<any, TContext>;
46 parseTypesFromString(str: string): TypeStorage<string, NamedTypeComposer<TContext>>;
47 parseTypes(astDocument: DocumentNode): Array<NamedTypeComposer<TContext>>;
48 typeFromAST(typeNode: TypeNode): AnyTypeComposer<TContext>;
49 typeFromASTInput(typeNode: TypeNode): ComposeInputType;
50 typeFromASTOutput(typeNode: TypeNode): ComposeOutputType<TContext>;
51 makeSchemaDef(def: DefinitionNode): NamedTypeComposer<any> | null;
52 makeArguments(values?: ReadonlyArray<InputValueDefinitionNode>): ObjectTypeComposerArgumentConfigMap<any>;
53 makeFieldDefMap(def: ObjectTypeDefinitionNode | InterfaceTypeDefinitionNode | ObjectTypeExtensionNode | InterfaceTypeExtensionNode): ObjectTypeComposerFieldConfigMap<any, any>;
54 makeInputFieldDef(def: InputObjectTypeDefinitionNode | InputObjectTypeExtensionNode): InputTypeComposerFieldConfigMapDefinition;
55 makeEnumDef(def: EnumTypeDefinitionNode): EnumTypeComposer<TContext>;
56 makeEnumValuesDef(def: EnumTypeDefinitionNode | EnumTypeExtensionNode): EnumTypeComposerValueConfigMapDefinition;
57 makeInputObjectDef(def: InputObjectTypeDefinitionNode): InputTypeComposer<TContext>;
58 makeDirectiveDef(def: DirectiveDefinitionNode): GraphQLDirective;
59 getBuiltInType(name: string): ScalarTypeComposer<TContext> | undefined;
60 makeScalarDef(def: ScalarTypeDefinitionNode): ScalarTypeComposer<TContext>;
61 makeImplementedInterfaces(def: ObjectTypeDefinitionNode | ObjectTypeExtensionNode | InterfaceTypeDefinitionNode | InterfaceTypeExtensionNode): Array<InterfaceTypeComposerThunked<any, TContext>>;
62 makeTypeDef(def: ObjectTypeDefinitionNode): ObjectTypeComposer<any, TContext>;
63 makeInterfaceDef(def: InterfaceTypeDefinitionNode): InterfaceTypeComposer<any, TContext>;
64 makeUnionDef(def: UnionTypeDefinitionNode): UnionTypeComposer<any, TContext>;
65 checkSchemaDef(def: SchemaDefinitionNode): void;
66 getNamedTypeAST(typeAST: TypeNode): NamedTypeNode;
67 buildWrappedTypeDef(innerType: AnyTypeComposer<any>, inputTypeAST: TypeNode): AnyTypeComposer<TContext>;
68 getDeprecationReason(directives: ReadonlyArray<DirectiveNode> | undefined): string | undefined;
69 parseDirectives(directives: ReadonlyArray<DirectiveNode> | undefined): Array<Directive>;
70 makeExtendTypeDef(def: ObjectTypeExtensionNode): ObjectTypeComposer<any, TContext>;
71 makeExtendInputObjectDef(def: InputObjectTypeExtensionNode): InputTypeComposer<TContext>;
72 makeExtendInterfaceDef(def: InterfaceTypeExtensionNode): InterfaceTypeComposer<any, TContext>;
73 makeExtendUnionDef(def: UnionTypeExtensionNode): UnionTypeComposer<any, TContext>;
74 makeExtendEnumDef(def: EnumTypeExtensionNode): EnumTypeComposer<TContext>;
75 makeExtendScalarDef(def: ScalarTypeExtensionNode): ScalarTypeComposer<TContext>;
76}
77export declare function getDescription(node: {
78 description?: StringValueNode;
79 loc?: Location;
80}, options?: {
81 commentDescriptions?: boolean;
82}): string | null | undefined;
83//# sourceMappingURL=TypeMapper.d.ts.map
\No newline at end of file