UNPKG

2.74 kBTypeScriptView Raw
1import { BaseTypesVisitor, ParsedTypesConfig, DeclarationKind, AvoidOptionalsConfig } from '@graphql-codegen/visitor-plugin-common';
2import { TypeScriptPluginConfig } from './config';
3import { FieldDefinitionNode, NamedTypeNode, ListTypeNode, NonNullTypeNode, EnumTypeDefinitionNode, InputValueDefinitionNode, GraphQLSchema, UnionTypeDefinitionNode } from 'graphql';
4export interface TypeScriptPluginParsedConfig extends ParsedTypesConfig {
5 avoidOptionals: AvoidOptionalsConfig;
6 constEnums: boolean;
7 enumsAsTypes: boolean;
8 futureProofEnums: boolean;
9 futureProofUnions: boolean;
10 enumsAsConst: boolean;
11 numericEnums: boolean;
12 onlyEnums: boolean;
13 onlyOperationTypes: boolean;
14 immutableTypes: boolean;
15 maybeValue: string;
16 inputMaybeValue: string;
17 noExport: boolean;
18 useImplementingTypes: boolean;
19}
20export declare const EXACT_SIGNATURE = "type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };";
21export declare const MAKE_OPTIONAL_SIGNATURE = "type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };";
22export declare const MAKE_MAYBE_SIGNATURE = "type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };";
23export declare class TsVisitor<TRawConfig extends TypeScriptPluginConfig = TypeScriptPluginConfig, TParsedConfig extends TypeScriptPluginParsedConfig = TypeScriptPluginParsedConfig> extends BaseTypesVisitor<TRawConfig, TParsedConfig> {
24 constructor(schema: GraphQLSchema, pluginConfig: TRawConfig, additionalConfig?: Partial<TParsedConfig>);
25 protected _getTypeForNode(node: NamedTypeNode): string;
26 getWrapperDefinitions(): string[];
27 getExactDefinition(): string;
28 getMakeOptionalDefinition(): string;
29 getMakeMaybeDefinition(): string;
30 getMaybeValue(): string;
31 getInputMaybeValue(): string;
32 protected clearOptional(str: string): string;
33 protected getExportPrefix(): string;
34 getMaybeWrapper(ancestors: any): string;
35 NamedType(node: NamedTypeNode, key: any, parent: any, path: any, ancestors: any): string;
36 ListType(node: ListTypeNode, key: any, parent: any, path: any, ancestors: any): string;
37 UnionTypeDefinition(node: UnionTypeDefinitionNode, key: string | number | undefined, parent: any): string;
38 protected wrapWithListType(str: string): string;
39 NonNullType(node: NonNullTypeNode): string;
40 FieldDefinition(node: FieldDefinitionNode, key?: number | string, parent?: any): string;
41 InputValueDefinition(node: InputValueDefinitionNode, key?: number | string, parent?: any): string;
42 EnumTypeDefinition(node: EnumTypeDefinitionNode): string;
43 protected getPunctuation(_declarationKind: DeclarationKind): string;
44}