@graphql-codegen/visitor-plugin-common 6.0.0 → 6.0.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.
|
@@ -9,6 +9,7 @@ const mappers_js_1 = require("./mappers.js");
|
|
|
9
9
|
const scalars_js_1 = require("./scalars.js");
|
|
10
10
|
const utils_js_1 = require("./utils.js");
|
|
11
11
|
const variables_to_object_js_1 = require("./variables-to-object.js");
|
|
12
|
+
const onlyUnderscoresPattern = /^_+$/;
|
|
12
13
|
class BaseTypesVisitor extends base_visitor_js_1.BaseVisitor {
|
|
13
14
|
_schema;
|
|
14
15
|
_argumentsTransformer;
|
|
@@ -319,7 +320,9 @@ class BaseTypesVisitor extends base_visitor_js_1.BaseVisitor {
|
|
|
319
320
|
.map(enumOption => {
|
|
320
321
|
const optionName = this.makeValidEnumIdentifier(this.convertName(enumOption, {
|
|
321
322
|
useTypesPrefix: false,
|
|
322
|
-
|
|
323
|
+
// We can only strip out the underscores if the value contains other
|
|
324
|
+
// characters. Otherwise we'll generate syntactically invalid code.
|
|
325
|
+
transformUnderscore: !onlyUnderscoresPattern.test(enumOption.name.value),
|
|
323
326
|
}));
|
|
324
327
|
const comment = this.getNodeComment(enumOption);
|
|
325
328
|
const schemaEnumValue = schemaEnumType && !this.config.ignoreEnumValuesFromSchema
|
|
@@ -6,6 +6,7 @@ import { transformDirectiveArgumentAndInputFieldMappings } from './mappers.js';
|
|
|
6
6
|
import { DEFAULT_SCALARS } from './scalars.js';
|
|
7
7
|
import { buildScalarsFromConfig, DeclarationBlock, getConfigValue, indent, isOneOfInputObjectType, transformComment, wrapWithSingleQuotes, } from './utils.js';
|
|
8
8
|
import { OperationVariablesToObject } from './variables-to-object.js';
|
|
9
|
+
const onlyUnderscoresPattern = /^_+$/;
|
|
9
10
|
export class BaseTypesVisitor extends BaseVisitor {
|
|
10
11
|
_schema;
|
|
11
12
|
_argumentsTransformer;
|
|
@@ -316,7 +317,9 @@ export class BaseTypesVisitor extends BaseVisitor {
|
|
|
316
317
|
.map(enumOption => {
|
|
317
318
|
const optionName = this.makeValidEnumIdentifier(this.convertName(enumOption, {
|
|
318
319
|
useTypesPrefix: false,
|
|
319
|
-
|
|
320
|
+
// We can only strip out the underscores if the value contains other
|
|
321
|
+
// characters. Otherwise we'll generate syntactically invalid code.
|
|
322
|
+
transformUnderscore: !onlyUnderscoresPattern.test(enumOption.name.value),
|
|
320
323
|
}));
|
|
321
324
|
const comment = this.getNodeComment(enumOption);
|
|
322
325
|
const schemaEnumValue = schemaEnumType && !this.config.ignoreEnumValuesFromSchema
|