UNPKG

2.99 kBTypeScriptView Raw
1import { ParsedConfig, BaseVisitor, EnumValuesMap } from '@graphql-codegen/visitor-plugin-common';
2import { CSharpResolversPluginRawConfig } from './config';
3import { GraphQLSchema, EnumTypeDefinitionNode, EnumValueDefinitionNode, InterfaceTypeDefinitionNode, InputObjectTypeDefinitionNode, ObjectTypeDefinitionNode, FieldDefinitionNode, InputValueDefinitionNode, TypeNode, DirectiveNode, StringValueNode, NamedTypeNode } from 'graphql';
4import { CSharpFieldType } from '../../common/common';
5export interface CSharpResolverParsedConfig extends ParsedConfig {
6 namespaceName: string;
7 className: string;
8 listType: string;
9 enumValues: EnumValuesMap;
10 emitRecords: boolean;
11}
12export declare class CSharpResolversVisitor extends BaseVisitor<CSharpResolversPluginRawConfig, CSharpResolverParsedConfig> {
13 private _schema;
14 private readonly keywords;
15 constructor(rawConfig: CSharpResolversPluginRawConfig, _schema: GraphQLSchema);
16 /**
17 * Checks name against list of keywords. If it is, will prefix value with @
18 *
19 * Note:
20 * This class should first invoke the convertName from base-visitor to convert the string or node
21 * value according the naming configuration, eg upper or lower case. Then resulting string checked
22 * against the list or keywords.
23 * However the generated C# code is not yet able to handle fields that are in a different case so
24 * the invocation of convertName is omitted purposely.
25 */
26 private convertSafeName;
27 getImports(): string;
28 wrapWithNamespace(content: string): string;
29 wrapWithClass(content: string): string;
30 protected getEnumValue(enumName: string, enumOption: string): string;
31 EnumValueDefinition(node: EnumValueDefinitionNode): (enumName: string) => string;
32 EnumTypeDefinition(node: EnumTypeDefinitionNode): string;
33 getFieldHeader(node: InputValueDefinitionNode | FieldDefinitionNode | EnumValueDefinitionNode, fieldType?: CSharpFieldType): string;
34 getDeprecationReason(directive: DirectiveNode): string;
35 protected resolveInputFieldType(typeNode: TypeNode, hasDefaultValue?: Boolean): CSharpFieldType;
36 protected buildRecord(name: string, description: StringValueNode, inputValueArray: ReadonlyArray<FieldDefinitionNode>, interfaces?: ReadonlyArray<NamedTypeNode>): string;
37 protected buildClass(name: string, description: StringValueNode, inputValueArray: ReadonlyArray<FieldDefinitionNode>, interfaces?: ReadonlyArray<NamedTypeNode>): string;
38 protected buildInterface(name: string, description: StringValueNode, inputValueArray: ReadonlyArray<FieldDefinitionNode>): string;
39 protected buildInputTransformer(name: string, description: StringValueNode, inputValueArray: ReadonlyArray<InputValueDefinitionNode>): string;
40 InputObjectTypeDefinition(node: InputObjectTypeDefinitionNode): string;
41 ObjectTypeDefinition(node: ObjectTypeDefinitionNode): string;
42 InterfaceTypeDefinition(node: InterfaceTypeDefinitionNode): string;
43}