@graphql-codegen/visitor-plugin-common 6.0.0-alpha-20250907165954-8bbb206c35a5b3a6c720ebc9dfb218aca4149d1d → 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
- transformUnderscore: true,
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
- transformUnderscore: true,
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
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@graphql-codegen/visitor-plugin-common",
3
- "version": "6.0.0-alpha-20250907165954-8bbb206c35a5b3a6c720ebc9dfb218aca4149d1d",
3
+ "version": "6.0.1",
4
4
  "peerDependencies": {
5
5
  "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"
6
6
  },
7
7
  "dependencies": {
8
8
  "@graphql-tools/optimize": "^2.0.0",
9
- "@graphql-codegen/plugin-helpers": "6.0.0-alpha-20250907165954-8bbb206c35a5b3a6c720ebc9dfb218aca4149d1d",
9
+ "@graphql-codegen/plugin-helpers": "^6.0.0",
10
10
  "@graphql-tools/relay-operation-optimizer": "^7.0.0",
11
11
  "@graphql-tools/utils": "^10.0.0",
12
12
  "auto-bind": "~4.0.0",