@graphql-codegen/c-sharp 4.3.1-alpha-0814e49cc.0 → 4.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/typings/config.d.cts +109 -0
- package/typings/index.d.cts +3 -0
- package/typings/json-attributes.d.cts +8 -0
- package/typings/visitor.d.cts +35 -0
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/c-sharp",
|
|
3
|
-
"version": "4.3.1
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"description": "GraphQL Code Generator plugin for generating CSharp code based on a GraphQL schema",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@graphql-codegen/plugin-helpers": "^2.6.
|
|
11
|
-
"@graphql-codegen/visitor-plugin-common": "^2.12.1
|
|
12
|
-
"@graphql-codegen/c-sharp-common": "0.1.1
|
|
10
|
+
"@graphql-codegen/plugin-helpers": "^2.6.2",
|
|
11
|
+
"@graphql-codegen/visitor-plugin-common": "^2.12.1",
|
|
12
|
+
"@graphql-codegen/c-sharp-common": "0.1.1",
|
|
13
13
|
"tslib": "~2.4.0",
|
|
14
14
|
"unixify": "^1.0.0",
|
|
15
15
|
"change-case-all": "1.0.14"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"exports": {
|
|
27
27
|
".": {
|
|
28
28
|
"require": {
|
|
29
|
-
"types": "./typings/index.d.
|
|
29
|
+
"types": "./typings/index.d.cts",
|
|
30
30
|
"default": "./cjs/index.js"
|
|
31
31
|
},
|
|
32
32
|
"import": {
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { RawConfig, EnumValuesMap } from '@graphql-codegen/visitor-plugin-common';
|
|
2
|
+
import { JsonAttributesSource } from './json-attributes.cjs';
|
|
3
|
+
/**
|
|
4
|
+
* @description This plugin generates C# `class` identifier for your schema types.
|
|
5
|
+
*/
|
|
6
|
+
export interface CSharpResolversPluginRawConfig extends RawConfig {
|
|
7
|
+
/**
|
|
8
|
+
* @description Overrides the default value of enum values declared in your GraphQL schema.
|
|
9
|
+
* @exampleMarkdown
|
|
10
|
+
* ## With Custom Values
|
|
11
|
+
* ```yaml
|
|
12
|
+
* config:
|
|
13
|
+
* enumValues:
|
|
14
|
+
* MyEnum:
|
|
15
|
+
* A: 'foo'
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
enumValues?: EnumValuesMap;
|
|
19
|
+
/**
|
|
20
|
+
* @default GraphQLCodeGen
|
|
21
|
+
* @description Allow you to customize the namespace name.
|
|
22
|
+
*
|
|
23
|
+
* @exampleMarkdown
|
|
24
|
+
* ```yaml
|
|
25
|
+
* generates:
|
|
26
|
+
* src/main/c-sharp/my-org/my-app/MyTypes.cs:
|
|
27
|
+
* plugins:
|
|
28
|
+
* - c-sharp
|
|
29
|
+
* config:
|
|
30
|
+
* namespaceName: MyCompany.MyNamespace
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
namespaceName?: string;
|
|
34
|
+
/**
|
|
35
|
+
* @default Types
|
|
36
|
+
* @description Allow you to customize the parent class name.
|
|
37
|
+
*
|
|
38
|
+
* @exampleMarkdown
|
|
39
|
+
* ```yaml
|
|
40
|
+
* generates:
|
|
41
|
+
* src/main/c-sharp/my-org/my-app/MyGeneratedTypes.cs:
|
|
42
|
+
* plugins:
|
|
43
|
+
* - c-sharp
|
|
44
|
+
* config:
|
|
45
|
+
* className: MyGeneratedTypes
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
className?: string;
|
|
49
|
+
/**
|
|
50
|
+
* @default IEnumerable
|
|
51
|
+
* @description Allow you to customize the list type
|
|
52
|
+
*
|
|
53
|
+
* @exampleMarkdown
|
|
54
|
+
* ```yaml
|
|
55
|
+
* generates:
|
|
56
|
+
* src/main/c-sharp/my-org/my-app/Types.cs:
|
|
57
|
+
* plugins:
|
|
58
|
+
* - c-sharp
|
|
59
|
+
* config:
|
|
60
|
+
* listType: Map
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
listType?: string;
|
|
64
|
+
/**
|
|
65
|
+
* @default false
|
|
66
|
+
* @description Emit C# 9.0+ records instead of classes
|
|
67
|
+
*
|
|
68
|
+
* @exampleMarkdown
|
|
69
|
+
* ```yaml
|
|
70
|
+
* generates:
|
|
71
|
+
* src/main/c-sharp/my-org/my-app/Types.cs:
|
|
72
|
+
* plugins:
|
|
73
|
+
* - c-sharp
|
|
74
|
+
* config:
|
|
75
|
+
* emitRecords: true
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
emitRecords?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* @default true
|
|
81
|
+
* @description Should JSON attributes be emitted for produced types and properties ot not
|
|
82
|
+
*
|
|
83
|
+
* @exampleMarkdown
|
|
84
|
+
* ```yaml
|
|
85
|
+
* generates:
|
|
86
|
+
* src/main/c-sharp/my-org/my-app/Types.cs:
|
|
87
|
+
* plugins:
|
|
88
|
+
* - c-sharp
|
|
89
|
+
* config:
|
|
90
|
+
* emitJsonAttributes: false
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
emitJsonAttributes?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* @default Newtonsoft.Json
|
|
96
|
+
* @description Library that should be used to emit JSON attributes. Ignored when `emitJsonAttributes` is `false` or not specified
|
|
97
|
+
*
|
|
98
|
+
* @exampleMarkdown
|
|
99
|
+
* ```yaml
|
|
100
|
+
* generates:
|
|
101
|
+
* src/main/c-sharp/my-org/my-app/Types.cs:
|
|
102
|
+
* plugins:
|
|
103
|
+
* - c-sharp
|
|
104
|
+
* config:
|
|
105
|
+
* jsonAttributesSource: System.Text.Json
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
jsonAttributesSource?: JsonAttributesSource;
|
|
109
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare type JsonAttributesSource = 'Newtonsoft.Json' | 'System.Text.Json';
|
|
2
|
+
export declare class JsonAttributesSourceConfiguration {
|
|
3
|
+
readonly namespace: string;
|
|
4
|
+
readonly propertyAttribute: string;
|
|
5
|
+
readonly requiredAttribute: string;
|
|
6
|
+
constructor(namespace: string, propertyAttribute: string, requiredAttribute: string);
|
|
7
|
+
}
|
|
8
|
+
export declare function getJsonAttributeSourceConfiguration(attributesSource: JsonAttributesSource): JsonAttributesSourceConfiguration;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ParsedConfig, BaseVisitor, EnumValuesMap } from '@graphql-codegen/visitor-plugin-common';
|
|
2
|
+
import { CSharpResolversPluginRawConfig } from './config.cjs';
|
|
3
|
+
import { GraphQLSchema, EnumTypeDefinitionNode, EnumValueDefinitionNode, InterfaceTypeDefinitionNode, InputObjectTypeDefinitionNode, ObjectTypeDefinitionNode, FieldDefinitionNode, InputValueDefinitionNode, TypeNode, DirectiveNode, StringValueNode, NamedTypeNode } from 'graphql';
|
|
4
|
+
import { CSharpFieldType } from '@graphql-codegen/c-sharp-common';
|
|
5
|
+
import { JsonAttributesSource } from './json-attributes.cjs';
|
|
6
|
+
export interface CSharpResolverParsedConfig extends ParsedConfig {
|
|
7
|
+
namespaceName: string;
|
|
8
|
+
className: string;
|
|
9
|
+
listType: string;
|
|
10
|
+
enumValues: EnumValuesMap;
|
|
11
|
+
emitRecords: boolean;
|
|
12
|
+
emitJsonAttributes: boolean;
|
|
13
|
+
jsonAttributesSource: JsonAttributesSource;
|
|
14
|
+
}
|
|
15
|
+
export declare class CSharpResolversVisitor extends BaseVisitor<CSharpResolversPluginRawConfig, CSharpResolverParsedConfig> {
|
|
16
|
+
private _schema;
|
|
17
|
+
private readonly jsonAttributesConfiguration;
|
|
18
|
+
constructor(rawConfig: CSharpResolversPluginRawConfig, _schema: GraphQLSchema);
|
|
19
|
+
getImports(): string;
|
|
20
|
+
wrapWithNamespace(content: string): string;
|
|
21
|
+
wrapWithClass(content: string): string;
|
|
22
|
+
protected getEnumValue(enumName: string, enumOption: string): string;
|
|
23
|
+
EnumValueDefinition(node: EnumValueDefinitionNode): (enumName: string) => string;
|
|
24
|
+
EnumTypeDefinition(node: EnumTypeDefinitionNode): string;
|
|
25
|
+
getFieldHeader(node: InputValueDefinitionNode | FieldDefinitionNode | EnumValueDefinitionNode, fieldType?: CSharpFieldType): string;
|
|
26
|
+
getDeprecationReason(directive: DirectiveNode): string;
|
|
27
|
+
protected resolveInputFieldType(typeNode: TypeNode, hasDefaultValue?: Boolean): CSharpFieldType;
|
|
28
|
+
protected buildRecord(name: string, description: StringValueNode, inputValueArray: ReadonlyArray<FieldDefinitionNode>, interfaces?: ReadonlyArray<NamedTypeNode>): string;
|
|
29
|
+
protected buildClass(name: string, description: StringValueNode, inputValueArray: ReadonlyArray<FieldDefinitionNode>, interfaces?: ReadonlyArray<NamedTypeNode>): string;
|
|
30
|
+
protected buildInterface(name: string, description: StringValueNode, inputValueArray: ReadonlyArray<FieldDefinitionNode>): string;
|
|
31
|
+
protected buildInputTransformer(name: string, description: StringValueNode, inputValueArray: ReadonlyArray<InputValueDefinitionNode>): string;
|
|
32
|
+
InputObjectTypeDefinition(node: InputObjectTypeDefinitionNode): string;
|
|
33
|
+
ObjectTypeDefinition(node: ObjectTypeDefinitionNode): string;
|
|
34
|
+
InterfaceTypeDefinition(node: InterfaceTypeDefinitionNode): string;
|
|
35
|
+
}
|