@graphql-codegen/visitor-plugin-common 6.1.0-alpha-20250924130447-97c31f2800d347c286bd857f8b06e7744a119b81 → 6.1.0-alpha-20251005124346-991afbf77854938477209f677661e6b12c413c71

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/visitor-plugin-common",
3
- "version": "6.1.0-alpha-20250924130447-97c31f2800d347c286bd857f8b06e7744a119b81",
3
+ "version": "6.1.0-alpha-20251005124346-991afbf77854938477209f677661e6b12c413c71",
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
  },
@@ -640,13 +640,13 @@ export interface RawResolversConfig extends RawConfig {
640
640
  avoidCheckingAbstractTypesRecursively?: boolean;
641
641
  /**
642
642
  * @description If true, add field resolver types to Interfaces.
643
- * By default, GraphQL Interfaces does not trigger any field resolvers,
643
+ * By default, GraphQL Interfaces do not trigger any field resolvers,
644
644
  * meaning every implementing type must implement the same resolver for the shared fields.
645
645
  *
646
646
  * Some tools provide a way to change the default behaviour by making GraphQL Objects inherit
647
647
  * missing resolvers from their Interface types. In these cases, it is fine to turn this option to true.
648
648
  *
649
- * For example, if you are using @graphql-tools/schema#makeExecutableSchema with `inheritResolversFromInterfaces: true`,
649
+ * For example, if you are using `@graphql-tools/schema#makeExecutableSchema` with `inheritResolversFromInterfaces: true`,
650
650
  * you can make `addInterfaceFieldResolverTypes: true` as well
651
651
  * https://the-guild.dev/graphql/tools/docs/generate-schema#makeexecutableschema
652
652
  *
@@ -640,13 +640,13 @@ export interface RawResolversConfig extends RawConfig {
640
640
  avoidCheckingAbstractTypesRecursively?: boolean;
641
641
  /**
642
642
  * @description If true, add field resolver types to Interfaces.
643
- * By default, GraphQL Interfaces does not trigger any field resolvers,
643
+ * By default, GraphQL Interfaces do not trigger any field resolvers,
644
644
  * meaning every implementing type must implement the same resolver for the shared fields.
645
645
  *
646
646
  * Some tools provide a way to change the default behaviour by making GraphQL Objects inherit
647
647
  * missing resolvers from their Interface types. In these cases, it is fine to turn this option to true.
648
648
  *
649
- * For example, if you are using @graphql-tools/schema#makeExecutableSchema with `inheritResolversFromInterfaces: true`,
649
+ * For example, if you are using `@graphql-tools/schema#makeExecutableSchema` with `inheritResolversFromInterfaces: true`,
650
650
  * you can make `addInterfaceFieldResolverTypes: true` as well
651
651
  * https://the-guild.dev/graphql/tools/docs/generate-schema#makeexecutableschema
652
652
  *