@graphql-codegen/c-sharp-operations 2.3.1 → 3.0.0-alpha-20230524082546-d7e1d0a4a
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/config.js +0 -2
- package/cjs/index.js +9 -4
- package/cjs/visitor.js +11 -5
- package/esm/config.js +0 -1
- package/esm/index.js +9 -4
- package/esm/visitor.js +12 -6
- package/package.json +7 -4
- package/typings/index.d.cts +2 -2
- package/typings/index.d.ts +2 -2
- package/typings/visitor.d.cts +4 -4
- package/typings/visitor.d.ts +4 -4
package/cjs/config.js
CHANGED
package/cjs/index.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CSharpOperationsVisitor = exports.validate = exports.addToSchema = exports.plugin = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const path_1 = require("path");
|
|
6
6
|
const graphql_1 = require("graphql");
|
|
7
|
+
const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
|
|
8
|
+
const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
|
|
7
9
|
const visitor_js_1 = require("./visitor.js");
|
|
8
10
|
Object.defineProperty(exports, "CSharpOperationsVisitor", { enumerable: true, get: function () { return visitor_js_1.CSharpOperationsVisitor; } });
|
|
9
|
-
const path_1 = require("path");
|
|
10
|
-
const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
|
|
11
11
|
const plugin = (schema, documents, config) => {
|
|
12
12
|
const schemaAST = (0, plugin_helpers_1.getCachedDocumentNodeFromSchema)(schema);
|
|
13
13
|
const allAst = (0, graphql_1.concatAST)(documents.map(v => v.document).concat(schemaAST));
|
|
@@ -26,7 +26,12 @@ const plugin = (schema, documents, config) => {
|
|
|
26
26
|
const openNameSpace = `namespace ${visitor.config.namespaceName} {`;
|
|
27
27
|
return {
|
|
28
28
|
prepend: [],
|
|
29
|
-
content: [
|
|
29
|
+
content: [
|
|
30
|
+
imports,
|
|
31
|
+
openNameSpace,
|
|
32
|
+
...visitorResult.definitions.filter(t => typeof t === 'string'),
|
|
33
|
+
'}',
|
|
34
|
+
]
|
|
30
35
|
.filter(a => a)
|
|
31
36
|
.join('\n'),
|
|
32
37
|
};
|
package/cjs/visitor.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CSharpOperationsVisitor = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const visitor_plugin_common_1 = require("@graphql-codegen/visitor-plugin-common");
|
|
6
5
|
const auto_bind_1 = tslib_1.__importDefault(require("auto-bind"));
|
|
7
6
|
const graphql_1 = require("graphql");
|
|
8
|
-
const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
|
|
9
7
|
const c_sharp_common_1 = require("@graphql-codegen/c-sharp-common");
|
|
8
|
+
const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
|
|
9
|
+
const visitor_plugin_common_1 = require("@graphql-codegen/visitor-plugin-common");
|
|
10
10
|
const defaultSuffix = 'GQL';
|
|
11
11
|
const R_NAME = /name:\s*"([^"]+)"/;
|
|
12
12
|
function R_DEF(directive) {
|
|
@@ -76,14 +76,18 @@ class CSharpOperationsVisitor extends visitor_plugin_common_1.ClientSideBaseVisi
|
|
|
76
76
|
return doc.replace(/"/g, '""');
|
|
77
77
|
}
|
|
78
78
|
_getDocumentNodeVariable(node, documentVariableName) {
|
|
79
|
-
return this.config.documentMode === visitor_plugin_common_1.DocumentMode.external
|
|
79
|
+
return this.config.documentMode === visitor_plugin_common_1.DocumentMode.external
|
|
80
|
+
? `Operations.${node.name.value}`
|
|
81
|
+
: documentVariableName;
|
|
80
82
|
}
|
|
81
83
|
_gqlInputSignature(variable) {
|
|
82
84
|
const typeNode = variable.type;
|
|
83
85
|
const innerType = (0, visitor_plugin_common_1.getBaseTypeNode)(typeNode);
|
|
84
86
|
const schemaType = this._schema.getType(innerType.name.value);
|
|
85
87
|
const name = variable.variable.name.value;
|
|
86
|
-
const baseType = !(0, graphql_1.isScalarType)(schemaType)
|
|
88
|
+
const baseType = !(0, graphql_1.isScalarType)(schemaType)
|
|
89
|
+
? innerType.name.value
|
|
90
|
+
: this.scalars[schemaType.name] || 'object';
|
|
87
91
|
const listType = (0, c_sharp_common_1.getListTypeField)(typeNode);
|
|
88
92
|
const required = (0, c_sharp_common_1.getListInnerTypeNode)(typeNode).kind === graphql_1.Kind.NON_NULL_TYPE;
|
|
89
93
|
return {
|
|
@@ -94,7 +98,9 @@ class CSharpOperationsVisitor extends visitor_plugin_common_1.ClientSideBaseVisi
|
|
|
94
98
|
};
|
|
95
99
|
}
|
|
96
100
|
getCSharpImports() {
|
|
97
|
-
return (['System', 'Newtonsoft.Json', 'GraphQL', 'GraphQL.Client.Abstractions']
|
|
101
|
+
return (['System', 'Newtonsoft.Json', 'GraphQL', 'GraphQL.Client.Abstractions']
|
|
102
|
+
.map(i => `using ${i};`)
|
|
103
|
+
.join('\n') + '\n');
|
|
98
104
|
}
|
|
99
105
|
_operationSuffix(operationType) {
|
|
100
106
|
switch (operationType) {
|
package/esm/config.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/esm/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getCachedDocumentNodeFromSchema, oldVisit, } from '@graphql-codegen/plugin-helpers';
|
|
2
|
-
import { concatAST, Kind } from 'graphql';
|
|
3
|
-
import { CSharpOperationsVisitor } from './visitor.js';
|
|
4
1
|
import { extname } from 'path';
|
|
2
|
+
import { concatAST, Kind } from 'graphql';
|
|
5
3
|
import gql from 'graphql-tag';
|
|
4
|
+
import { getCachedDocumentNodeFromSchema, oldVisit, } from '@graphql-codegen/plugin-helpers';
|
|
5
|
+
import { CSharpOperationsVisitor } from './visitor.js';
|
|
6
6
|
export const plugin = (schema, documents, config) => {
|
|
7
7
|
const schemaAST = getCachedDocumentNodeFromSchema(schema);
|
|
8
8
|
const allAst = concatAST(documents.map(v => v.document).concat(schemaAST));
|
|
@@ -21,7 +21,12 @@ export const plugin = (schema, documents, config) => {
|
|
|
21
21
|
const openNameSpace = `namespace ${visitor.config.namespaceName} {`;
|
|
22
22
|
return {
|
|
23
23
|
prepend: [],
|
|
24
|
-
content: [
|
|
24
|
+
content: [
|
|
25
|
+
imports,
|
|
26
|
+
openNameSpace,
|
|
27
|
+
...visitorResult.definitions.filter(t => typeof t === 'string'),
|
|
28
|
+
'}',
|
|
29
|
+
]
|
|
25
30
|
.filter(a => a)
|
|
26
31
|
.join('\n'),
|
|
27
32
|
};
|
package/esm/visitor.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ClientSideBaseVisitor, DocumentMode, indentMultiline, getBaseTypeNode, indent, buildScalarsFromConfig, } from '@graphql-codegen/visitor-plugin-common';
|
|
2
1
|
import autoBind from 'auto-bind';
|
|
3
|
-
import {
|
|
2
|
+
import { isEnumType, isInputObjectType, isScalarType, Kind, print, visit, } from 'graphql';
|
|
3
|
+
import { C_SHARP_SCALARS, convertSafeName, CSharpDeclarationBlock, CSharpFieldType, getListInnerTypeNode, getListTypeDepth, getListTypeField, isValueType, wrapFieldType, } from '@graphql-codegen/c-sharp-common';
|
|
4
4
|
import { getCachedDocumentNodeFromSchema } from '@graphql-codegen/plugin-helpers';
|
|
5
|
-
import {
|
|
5
|
+
import { buildScalarsFromConfig, ClientSideBaseVisitor, DocumentMode, getBaseTypeNode, indent, indentMultiline, } from '@graphql-codegen/visitor-plugin-common';
|
|
6
6
|
const defaultSuffix = 'GQL';
|
|
7
7
|
const R_NAME = /name:\s*"([^"]+)"/;
|
|
8
8
|
function R_DEF(directive) {
|
|
@@ -72,14 +72,18 @@ export class CSharpOperationsVisitor extends ClientSideBaseVisitor {
|
|
|
72
72
|
return doc.replace(/"/g, '""');
|
|
73
73
|
}
|
|
74
74
|
_getDocumentNodeVariable(node, documentVariableName) {
|
|
75
|
-
return this.config.documentMode === DocumentMode.external
|
|
75
|
+
return this.config.documentMode === DocumentMode.external
|
|
76
|
+
? `Operations.${node.name.value}`
|
|
77
|
+
: documentVariableName;
|
|
76
78
|
}
|
|
77
79
|
_gqlInputSignature(variable) {
|
|
78
80
|
const typeNode = variable.type;
|
|
79
81
|
const innerType = getBaseTypeNode(typeNode);
|
|
80
82
|
const schemaType = this._schema.getType(innerType.name.value);
|
|
81
83
|
const name = variable.variable.name.value;
|
|
82
|
-
const baseType = !isScalarType(schemaType)
|
|
84
|
+
const baseType = !isScalarType(schemaType)
|
|
85
|
+
? innerType.name.value
|
|
86
|
+
: this.scalars[schemaType.name] || 'object';
|
|
83
87
|
const listType = getListTypeField(typeNode);
|
|
84
88
|
const required = getListInnerTypeNode(typeNode).kind === Kind.NON_NULL_TYPE;
|
|
85
89
|
return {
|
|
@@ -90,7 +94,9 @@ export class CSharpOperationsVisitor extends ClientSideBaseVisitor {
|
|
|
90
94
|
};
|
|
91
95
|
}
|
|
92
96
|
getCSharpImports() {
|
|
93
|
-
return (['System', 'Newtonsoft.Json', 'GraphQL', 'GraphQL.Client.Abstractions']
|
|
97
|
+
return (['System', 'Newtonsoft.Json', 'GraphQL', 'GraphQL.Client.Abstractions']
|
|
98
|
+
.map(i => `using ${i};`)
|
|
99
|
+
.join('\n') + '\n');
|
|
94
100
|
}
|
|
95
101
|
_operationSuffix(operationType) {
|
|
96
102
|
switch (operationType) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/c-sharp-operations",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha-20230524082546-d7e1d0a4a",
|
|
4
4
|
"description": "GraphQL Code Generator plugin for generating CSharp code based on GraphQL operations",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
@@ -8,15 +8,18 @@
|
|
|
8
8
|
"graphql-tag": "2.12.6"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@graphql-codegen/
|
|
11
|
+
"@graphql-codegen/c-sharp-common": "1.0.0-alpha-20230524082546-d7e1d0a4a",
|
|
12
|
+
"@graphql-codegen/plugin-helpers": "^3.0.0",
|
|
12
13
|
"@graphql-codegen/visitor-plugin-common": "^2.12.1",
|
|
13
|
-
"@graphql-codegen/c-sharp-common": "0.1.1",
|
|
14
14
|
"auto-bind": "~4.0.0",
|
|
15
|
-
"change-case-all": "1.0.
|
|
15
|
+
"change-case-all": "1.0.15",
|
|
16
16
|
"tslib": "~2.4.0"
|
|
17
17
|
},
|
|
18
18
|
"repository": "git@github.com:dotansimha/graphql-code-generator.git",
|
|
19
19
|
"license": "MIT",
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">= 16.0.0"
|
|
22
|
+
},
|
|
20
23
|
"main": "cjs/index.js",
|
|
21
24
|
"module": "esm/index.js",
|
|
22
25
|
"typings": "typings/index.d.ts",
|
package/typings/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CSharpOperationsVisitor } from './visitor.cjs';
|
|
1
|
+
import { PluginFunction, PluginValidateFn } from '@graphql-codegen/plugin-helpers';
|
|
3
2
|
import { CSharpOperationsRawPluginConfig } from './config.cjs';
|
|
3
|
+
import { CSharpOperationsVisitor } from './visitor.cjs';
|
|
4
4
|
export declare const plugin: PluginFunction<CSharpOperationsRawPluginConfig>;
|
|
5
5
|
export declare const addToSchema: import("graphql").DocumentNode;
|
|
6
6
|
export declare const validate: PluginValidateFn<any>;
|
package/typings/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CSharpOperationsVisitor } from './visitor.js';
|
|
1
|
+
import { PluginFunction, PluginValidateFn } from '@graphql-codegen/plugin-helpers';
|
|
3
2
|
import { CSharpOperationsRawPluginConfig } from './config.js';
|
|
3
|
+
import { CSharpOperationsVisitor } from './visitor.js';
|
|
4
4
|
export declare const plugin: PluginFunction<CSharpOperationsRawPluginConfig>;
|
|
5
5
|
export declare const addToSchema: import("graphql").DocumentNode;
|
|
6
6
|
export declare const validate: PluginValidateFn<any>;
|
package/typings/visitor.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { OperationDefinitionNode, GraphQLSchema, TypeNode, InputObjectTypeDefinitionNode, EnumTypeDefinitionNode } from 'graphql';
|
|
3
|
-
import { CSharpOperationsRawPluginConfig } from './config.cjs';
|
|
4
|
-
import { Types } from '@graphql-codegen/plugin-helpers';
|
|
1
|
+
import { EnumTypeDefinitionNode, GraphQLSchema, InputObjectTypeDefinitionNode, OperationDefinitionNode, TypeNode } from 'graphql';
|
|
5
2
|
import { CSharpFieldType } from '@graphql-codegen/c-sharp-common';
|
|
3
|
+
import { Types } from '@graphql-codegen/plugin-helpers';
|
|
4
|
+
import { ClientSideBasePluginConfig, ClientSideBaseVisitor, LoadedFragment } from '@graphql-codegen/visitor-plugin-common';
|
|
5
|
+
import { CSharpOperationsRawPluginConfig } from './config.cjs';
|
|
6
6
|
export interface CSharpOperationsPluginConfig extends ClientSideBasePluginConfig {
|
|
7
7
|
namespaceName: string;
|
|
8
8
|
namedClient: string;
|
package/typings/visitor.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { OperationDefinitionNode, GraphQLSchema, TypeNode, InputObjectTypeDefinitionNode, EnumTypeDefinitionNode } from 'graphql';
|
|
3
|
-
import { CSharpOperationsRawPluginConfig } from './config.js';
|
|
4
|
-
import { Types } from '@graphql-codegen/plugin-helpers';
|
|
1
|
+
import { EnumTypeDefinitionNode, GraphQLSchema, InputObjectTypeDefinitionNode, OperationDefinitionNode, TypeNode } from 'graphql';
|
|
5
2
|
import { CSharpFieldType } from '@graphql-codegen/c-sharp-common';
|
|
3
|
+
import { Types } from '@graphql-codegen/plugin-helpers';
|
|
4
|
+
import { ClientSideBasePluginConfig, ClientSideBaseVisitor, LoadedFragment } from '@graphql-codegen/visitor-plugin-common';
|
|
5
|
+
import { CSharpOperationsRawPluginConfig } from './config.js';
|
|
6
6
|
export interface CSharpOperationsPluginConfig extends ClientSideBasePluginConfig {
|
|
7
7
|
namespaceName: string;
|
|
8
8
|
namedClient: string;
|