UNPKG

3.26 kBTypeScriptView Raw
1import { BaseTypesVisitor, DeclarationKind, NormalizedAvoidOptionalsConfig, ParsedTypesConfig } from '@graphql-codegen/visitor-plugin-common';
2import { EnumTypeDefinitionNode, FieldDefinitionNode, GraphQLSchema, InputValueDefinitionNode, ListTypeNode, NamedTypeNode, NonNullTypeNode, TypeDefinitionNode, UnionTypeDefinitionNode } from 'graphql';
3import { TypeScriptPluginConfig } from './config.js';
4export interface TypeScriptPluginParsedConfig extends ParsedTypesConfig {
5 avoidOptionals: NormalizedAvoidOptionalsConfig;
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 const MAKE_EMPTY_SIGNATURE = "type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };";
24export declare const MAKE_INCREMENTAL_SIGNATURE = "type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };";
25export declare class TsVisitor<TRawConfig extends TypeScriptPluginConfig = TypeScriptPluginConfig, TParsedConfig extends TypeScriptPluginParsedConfig = TypeScriptPluginParsedConfig> extends BaseTypesVisitor<TRawConfig, TParsedConfig> {
26 constructor(schema: GraphQLSchema, pluginConfig: TRawConfig, additionalConfig?: Partial<TParsedConfig>);
27 protected _getTypeForNode(node: NamedTypeNode, isVisitingInputType: boolean): string;
28 getWrapperDefinitions(): string[];
29 getExactDefinition(): string;
30 getMakeOptionalDefinition(): string;
31 getMakeMaybeDefinition(): string;
32 getMakeEmptyDefinition(): string;
33 getIncrementalDefinition(): string;
34 getMaybeValue(): string;
35 getInputMaybeValue(): string;
36 protected clearOptional(str: string): string;
37 protected getExportPrefix(): string;
38 getMaybeWrapper(ancestors: any): string;
39 NamedType(node: NamedTypeNode, key: any, parent: any, path: any, ancestors: any): string;
40 ListType(node: ListTypeNode, key: any, parent: any, path: any, ancestors: any): string;
41 UnionTypeDefinition(node: UnionTypeDefinitionNode, key: string | number | undefined, parent: any): string;
42 protected wrapWithListType(str: string): string;
43 NonNullType(node: NonNullTypeNode): string;
44 FieldDefinition(node: FieldDefinitionNode, key?: number | string, parent?: any): string;
45 InputValueDefinition(node: InputValueDefinitionNode, key?: number | string, parent?: any, _path?: Array<string | number>, ancestors?: Array<TypeDefinitionNode>): string;
46 EnumTypeDefinition(node: EnumTypeDefinitionNode): string;
47 protected getPunctuation(_declarationKind: DeclarationKind): string;
48}