@graphql-codegen/c-sharp 5.0.1-alpha-20231126041150-01a328d1e → 5.1.0
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/cjs/visitor.js +11 -12
- package/esm/visitor.js +12 -13
- package/package.json +5 -5
- package/typings/config.d.cts +2 -1
- package/typings/config.d.ts +2 -1
- package/typings/visitor.d.cts +2 -1
- package/typings/visitor.d.ts +2 -1
package/cjs/visitor.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CSharpResolversVisitor = void 0;
|
|
4
|
-
const change_case_all_1 = require("change-case-all");
|
|
5
4
|
const graphql_1 = require("graphql");
|
|
6
5
|
const c_sharp_common_1 = require("@graphql-codegen/c-sharp-common");
|
|
7
6
|
const visitor_plugin_common_1 = require("@graphql-codegen/visitor-plugin-common");
|
|
@@ -18,6 +17,7 @@ class CSharpResolversVisitor extends visitor_plugin_common_1.BaseVisitor {
|
|
|
18
17
|
emitJsonAttributes: (_a = rawConfig.emitJsonAttributes) !== null && _a !== void 0 ? _a : true,
|
|
19
18
|
jsonAttributesSource: rawConfig.jsonAttributesSource || 'Newtonsoft.Json',
|
|
20
19
|
scalars: (0, visitor_plugin_common_1.buildScalarsFromConfig)(_schema, rawConfig, c_sharp_common_1.C_SHARP_SCALARS),
|
|
20
|
+
memberNamingFunction: (0, c_sharp_common_1.getMemberNamingFunction)(rawConfig),
|
|
21
21
|
});
|
|
22
22
|
this._schema = _schema;
|
|
23
23
|
if (this._parsedConfig.emitJsonAttributes) {
|
|
@@ -137,9 +137,9 @@ class CSharpResolversVisitor extends visitor_plugin_common_1.BaseVisitor {
|
|
|
137
137
|
const baseType = this.scalars[schemaType.name];
|
|
138
138
|
result = new c_sharp_common_1.CSharpFieldType({
|
|
139
139
|
baseType: {
|
|
140
|
-
type: baseType,
|
|
140
|
+
type: baseType.input,
|
|
141
141
|
required,
|
|
142
|
-
valueType: (0, c_sharp_common_1.isValueType)(baseType),
|
|
142
|
+
valueType: (0, c_sharp_common_1.isValueType)(baseType.input),
|
|
143
143
|
},
|
|
144
144
|
listType,
|
|
145
145
|
});
|
|
@@ -200,7 +200,7 @@ class CSharpResolversVisitor extends visitor_plugin_common_1.BaseVisitor {
|
|
|
200
200
|
.map(arg => {
|
|
201
201
|
const fieldType = this.resolveInputFieldType(arg.type);
|
|
202
202
|
const fieldHeader = this.getFieldHeader(arg, fieldType);
|
|
203
|
-
const fieldName = (0, c_sharp_common_1.convertSafeName)(
|
|
203
|
+
const fieldName = (0, c_sharp_common_1.convertSafeName)(this._parsedConfig.memberNamingFunction(this.convertName(arg.name)));
|
|
204
204
|
const csharpFieldType = (0, c_sharp_common_1.wrapFieldType)(fieldType, fieldType.listType, this.config.listType);
|
|
205
205
|
return (fieldHeader +
|
|
206
206
|
(0, visitor_plugin_common_1.indent)(`public ${csharpFieldType} ${fieldName} { get; init; } = ${fieldName};`));
|
|
@@ -209,7 +209,7 @@ class CSharpResolversVisitor extends visitor_plugin_common_1.BaseVisitor {
|
|
|
209
209
|
const recordInitializer = inputValueArray
|
|
210
210
|
.map(arg => {
|
|
211
211
|
const fieldType = this.resolveInputFieldType(arg.type);
|
|
212
|
-
const fieldName = (0, c_sharp_common_1.convertSafeName)(
|
|
212
|
+
const fieldName = (0, c_sharp_common_1.convertSafeName)(this._parsedConfig.memberNamingFunction(this.convertName(arg.name)));
|
|
213
213
|
const csharpFieldType = (0, c_sharp_common_1.wrapFieldType)(fieldType, fieldType.listType, this.config.listType);
|
|
214
214
|
return `${csharpFieldType} ${fieldName}`;
|
|
215
215
|
})
|
|
@@ -231,10 +231,10 @@ ${recordMembers}
|
|
|
231
231
|
const classMembers = inputValueArray
|
|
232
232
|
.map(arg => {
|
|
233
233
|
const fieldType = this.resolveInputFieldType(arg.type);
|
|
234
|
-
const
|
|
235
|
-
const fieldName = (0, c_sharp_common_1.convertSafeName)(arg.name);
|
|
234
|
+
const fieldAttribute = this.getFieldHeader(arg, fieldType);
|
|
235
|
+
const fieldName = (0, c_sharp_common_1.convertSafeName)(this._parsedConfig.memberNamingFunction(arg.name));
|
|
236
236
|
const csharpFieldType = (0, c_sharp_common_1.wrapFieldType)(fieldType, fieldType.listType, this.config.listType);
|
|
237
|
-
return
|
|
237
|
+
return fieldAttribute + (0, visitor_plugin_common_1.indent)(`public ${csharpFieldType} ${fieldName} { get; set; }`);
|
|
238
238
|
})
|
|
239
239
|
.join('\n\n');
|
|
240
240
|
return `
|
|
@@ -256,12 +256,11 @@ ${classMembers}
|
|
|
256
256
|
let getterSetter;
|
|
257
257
|
if (this.config.emitRecords) {
|
|
258
258
|
// record
|
|
259
|
-
fieldName = (0, c_sharp_common_1.convertSafeName)(
|
|
259
|
+
fieldName = (0, c_sharp_common_1.convertSafeName)(this._parsedConfig.memberNamingFunction(this.convertName(arg.name)));
|
|
260
260
|
getterSetter = '{ get; }';
|
|
261
261
|
}
|
|
262
262
|
else {
|
|
263
|
-
|
|
264
|
-
fieldName = (0, c_sharp_common_1.convertSafeName)(arg.name);
|
|
263
|
+
fieldName = (0, c_sharp_common_1.convertSafeName)(this._parsedConfig.memberNamingFunction(arg.name));
|
|
265
264
|
getterSetter = '{ get; set; }';
|
|
266
265
|
}
|
|
267
266
|
const csharpFieldType = (0, c_sharp_common_1.wrapFieldType)(fieldType, fieldType.listType, this.config.listType);
|
|
@@ -279,7 +278,7 @@ ${classMembers}
|
|
|
279
278
|
.map(arg => {
|
|
280
279
|
const fieldType = this.resolveInputFieldType(arg.type, !!arg.defaultValue);
|
|
281
280
|
const fieldHeader = this.getFieldHeader(arg, fieldType);
|
|
282
|
-
const fieldName = (0, c_sharp_common_1.convertSafeName)(arg.name);
|
|
281
|
+
const fieldName = (0, c_sharp_common_1.convertSafeName)(this._parsedConfig.memberNamingFunction(arg.name));
|
|
283
282
|
const csharpFieldType = (0, c_sharp_common_1.wrapFieldType)(fieldType, fieldType.listType, this.config.listType);
|
|
284
283
|
return fieldHeader + (0, visitor_plugin_common_1.indent)(`public ${csharpFieldType} ${fieldName} { get; set; }`);
|
|
285
284
|
})
|
package/esm/visitor.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { pascalCase } from 'change-case-all';
|
|
2
1
|
import { isEnumType, isInputObjectType, isScalarType, Kind, } from 'graphql';
|
|
3
|
-
import { C_SHARP_SCALARS, convertSafeName, CSharpDeclarationBlock, CSharpFieldType, getListInnerTypeNode, getListTypeField, isValueType, transformComment, wrapFieldType, } from '@graphql-codegen/c-sharp-common';
|
|
2
|
+
import { C_SHARP_SCALARS, convertSafeName, CSharpDeclarationBlock, CSharpFieldType, getListInnerTypeNode, getListTypeField, getMemberNamingFunction, isValueType, transformComment, wrapFieldType, } from '@graphql-codegen/c-sharp-common';
|
|
4
3
|
import { BaseVisitor, buildScalarsFromConfig, getBaseTypeNode, indent, indentMultiline, } from '@graphql-codegen/visitor-plugin-common';
|
|
5
4
|
import { getJsonAttributeSourceConfiguration, } from './json-attributes.js';
|
|
6
5
|
export class CSharpResolversVisitor extends BaseVisitor {
|
|
@@ -15,6 +14,7 @@ export class CSharpResolversVisitor extends BaseVisitor {
|
|
|
15
14
|
emitJsonAttributes: (_a = rawConfig.emitJsonAttributes) !== null && _a !== void 0 ? _a : true,
|
|
16
15
|
jsonAttributesSource: rawConfig.jsonAttributesSource || 'Newtonsoft.Json',
|
|
17
16
|
scalars: buildScalarsFromConfig(_schema, rawConfig, C_SHARP_SCALARS),
|
|
17
|
+
memberNamingFunction: getMemberNamingFunction(rawConfig),
|
|
18
18
|
});
|
|
19
19
|
this._schema = _schema;
|
|
20
20
|
if (this._parsedConfig.emitJsonAttributes) {
|
|
@@ -134,9 +134,9 @@ export class CSharpResolversVisitor extends BaseVisitor {
|
|
|
134
134
|
const baseType = this.scalars[schemaType.name];
|
|
135
135
|
result = new CSharpFieldType({
|
|
136
136
|
baseType: {
|
|
137
|
-
type: baseType,
|
|
137
|
+
type: baseType.input,
|
|
138
138
|
required,
|
|
139
|
-
valueType: isValueType(baseType),
|
|
139
|
+
valueType: isValueType(baseType.input),
|
|
140
140
|
},
|
|
141
141
|
listType,
|
|
142
142
|
});
|
|
@@ -197,7 +197,7 @@ export class CSharpResolversVisitor extends BaseVisitor {
|
|
|
197
197
|
.map(arg => {
|
|
198
198
|
const fieldType = this.resolveInputFieldType(arg.type);
|
|
199
199
|
const fieldHeader = this.getFieldHeader(arg, fieldType);
|
|
200
|
-
const fieldName = convertSafeName(
|
|
200
|
+
const fieldName = convertSafeName(this._parsedConfig.memberNamingFunction(this.convertName(arg.name)));
|
|
201
201
|
const csharpFieldType = wrapFieldType(fieldType, fieldType.listType, this.config.listType);
|
|
202
202
|
return (fieldHeader +
|
|
203
203
|
indent(`public ${csharpFieldType} ${fieldName} { get; init; } = ${fieldName};`));
|
|
@@ -206,7 +206,7 @@ export class CSharpResolversVisitor extends BaseVisitor {
|
|
|
206
206
|
const recordInitializer = inputValueArray
|
|
207
207
|
.map(arg => {
|
|
208
208
|
const fieldType = this.resolveInputFieldType(arg.type);
|
|
209
|
-
const fieldName = convertSafeName(
|
|
209
|
+
const fieldName = convertSafeName(this._parsedConfig.memberNamingFunction(this.convertName(arg.name)));
|
|
210
210
|
const csharpFieldType = wrapFieldType(fieldType, fieldType.listType, this.config.listType);
|
|
211
211
|
return `${csharpFieldType} ${fieldName}`;
|
|
212
212
|
})
|
|
@@ -228,10 +228,10 @@ ${recordMembers}
|
|
|
228
228
|
const classMembers = inputValueArray
|
|
229
229
|
.map(arg => {
|
|
230
230
|
const fieldType = this.resolveInputFieldType(arg.type);
|
|
231
|
-
const
|
|
232
|
-
const fieldName = convertSafeName(arg.name);
|
|
231
|
+
const fieldAttribute = this.getFieldHeader(arg, fieldType);
|
|
232
|
+
const fieldName = convertSafeName(this._parsedConfig.memberNamingFunction(arg.name));
|
|
233
233
|
const csharpFieldType = wrapFieldType(fieldType, fieldType.listType, this.config.listType);
|
|
234
|
-
return
|
|
234
|
+
return fieldAttribute + indent(`public ${csharpFieldType} ${fieldName} { get; set; }`);
|
|
235
235
|
})
|
|
236
236
|
.join('\n\n');
|
|
237
237
|
return `
|
|
@@ -253,12 +253,11 @@ ${classMembers}
|
|
|
253
253
|
let getterSetter;
|
|
254
254
|
if (this.config.emitRecords) {
|
|
255
255
|
// record
|
|
256
|
-
fieldName = convertSafeName(
|
|
256
|
+
fieldName = convertSafeName(this._parsedConfig.memberNamingFunction(this.convertName(arg.name)));
|
|
257
257
|
getterSetter = '{ get; }';
|
|
258
258
|
}
|
|
259
259
|
else {
|
|
260
|
-
|
|
261
|
-
fieldName = convertSafeName(arg.name);
|
|
260
|
+
fieldName = convertSafeName(this._parsedConfig.memberNamingFunction(arg.name));
|
|
262
261
|
getterSetter = '{ get; set; }';
|
|
263
262
|
}
|
|
264
263
|
const csharpFieldType = wrapFieldType(fieldType, fieldType.listType, this.config.listType);
|
|
@@ -276,7 +275,7 @@ ${classMembers}
|
|
|
276
275
|
.map(arg => {
|
|
277
276
|
const fieldType = this.resolveInputFieldType(arg.type, !!arg.defaultValue);
|
|
278
277
|
const fieldHeader = this.getFieldHeader(arg, fieldType);
|
|
279
|
-
const fieldName = convertSafeName(arg.name);
|
|
278
|
+
const fieldName = convertSafeName(this._parsedConfig.memberNamingFunction(arg.name));
|
|
280
279
|
const csharpFieldType = wrapFieldType(fieldType, fieldType.listType, this.config.listType);
|
|
281
280
|
return fieldHeader + indent(`public ${csharpFieldType} ${fieldName} { get; set; }`);
|
|
282
281
|
})
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/c-sharp",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
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/c-sharp-common": "1.0
|
|
11
|
-
"@graphql-codegen/plugin-helpers": "^
|
|
12
|
-
"@graphql-codegen/visitor-plugin-common": "^
|
|
13
|
-
"change-case-all": "
|
|
10
|
+
"@graphql-codegen/c-sharp-common": "1.1.0",
|
|
11
|
+
"@graphql-codegen/plugin-helpers": "^5.0.4",
|
|
12
|
+
"@graphql-codegen/visitor-plugin-common": "^5.3.1",
|
|
13
|
+
"change-case-all": "1.0.15",
|
|
14
14
|
"tslib": "~2.6.0",
|
|
15
15
|
"unixify": "^1.0.0"
|
|
16
16
|
},
|
package/typings/config.d.cts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { MemberNameConventionConfig } from '@graphql-codegen/c-sharp-common';
|
|
1
2
|
import { EnumValuesMap, RawConfig } from '@graphql-codegen/visitor-plugin-common';
|
|
2
3
|
import { JsonAttributesSource } from './json-attributes.cjs';
|
|
3
4
|
/**
|
|
4
5
|
* @description This plugin generates C# `class` identifier for your schema types.
|
|
5
6
|
*/
|
|
6
|
-
export interface CSharpResolversPluginRawConfig extends RawConfig {
|
|
7
|
+
export interface CSharpResolversPluginRawConfig extends RawConfig, MemberNameConventionConfig {
|
|
7
8
|
/**
|
|
8
9
|
* @description Overrides the default value of enum values declared in your GraphQL schema.
|
|
9
10
|
* @exampleMarkdown
|
package/typings/config.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { MemberNameConventionConfig } from '@graphql-codegen/c-sharp-common';
|
|
1
2
|
import { EnumValuesMap, RawConfig } from '@graphql-codegen/visitor-plugin-common';
|
|
2
3
|
import { JsonAttributesSource } from './json-attributes.js';
|
|
3
4
|
/**
|
|
4
5
|
* @description This plugin generates C# `class` identifier for your schema types.
|
|
5
6
|
*/
|
|
6
|
-
export interface CSharpResolversPluginRawConfig extends RawConfig {
|
|
7
|
+
export interface CSharpResolversPluginRawConfig extends RawConfig, MemberNameConventionConfig {
|
|
7
8
|
/**
|
|
8
9
|
* @description Overrides the default value of enum values declared in your GraphQL schema.
|
|
9
10
|
* @exampleMarkdown
|
package/typings/visitor.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DirectiveNode, EnumTypeDefinitionNode, EnumValueDefinitionNode, FieldDefinitionNode, GraphQLSchema, InputObjectTypeDefinitionNode, InputValueDefinitionNode, InterfaceTypeDefinitionNode, NamedTypeNode, ObjectTypeDefinitionNode, StringValueNode, TypeNode } from 'graphql';
|
|
2
|
-
import { CSharpFieldType } from '@graphql-codegen/c-sharp-common';
|
|
2
|
+
import { CSharpFieldType, MemberNamingFn } from '@graphql-codegen/c-sharp-common';
|
|
3
3
|
import { BaseVisitor, EnumValuesMap, ParsedConfig } from '@graphql-codegen/visitor-plugin-common';
|
|
4
4
|
import { CSharpResolversPluginRawConfig } from './config.cjs';
|
|
5
5
|
import { JsonAttributesSource } from './json-attributes.cjs';
|
|
@@ -11,6 +11,7 @@ export interface CSharpResolverParsedConfig extends ParsedConfig {
|
|
|
11
11
|
emitRecords: boolean;
|
|
12
12
|
emitJsonAttributes: boolean;
|
|
13
13
|
jsonAttributesSource: JsonAttributesSource;
|
|
14
|
+
memberNamingFunction: MemberNamingFn;
|
|
14
15
|
}
|
|
15
16
|
export declare class CSharpResolversVisitor extends BaseVisitor<CSharpResolversPluginRawConfig, CSharpResolverParsedConfig> {
|
|
16
17
|
private _schema;
|
package/typings/visitor.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DirectiveNode, EnumTypeDefinitionNode, EnumValueDefinitionNode, FieldDefinitionNode, GraphQLSchema, InputObjectTypeDefinitionNode, InputValueDefinitionNode, InterfaceTypeDefinitionNode, NamedTypeNode, ObjectTypeDefinitionNode, StringValueNode, TypeNode } from 'graphql';
|
|
2
|
-
import { CSharpFieldType } from '@graphql-codegen/c-sharp-common';
|
|
2
|
+
import { CSharpFieldType, MemberNamingFn } from '@graphql-codegen/c-sharp-common';
|
|
3
3
|
import { BaseVisitor, EnumValuesMap, ParsedConfig } from '@graphql-codegen/visitor-plugin-common';
|
|
4
4
|
import { CSharpResolversPluginRawConfig } from './config.js';
|
|
5
5
|
import { JsonAttributesSource } from './json-attributes.js';
|
|
@@ -11,6 +11,7 @@ export interface CSharpResolverParsedConfig extends ParsedConfig {
|
|
|
11
11
|
emitRecords: boolean;
|
|
12
12
|
emitJsonAttributes: boolean;
|
|
13
13
|
jsonAttributesSource: JsonAttributesSource;
|
|
14
|
+
memberNamingFunction: MemberNamingFn;
|
|
14
15
|
}
|
|
15
16
|
export declare class CSharpResolversVisitor extends BaseVisitor<CSharpResolversPluginRawConfig, CSharpResolverParsedConfig> {
|
|
16
17
|
private _schema;
|