Skip to content

Conversation

@adambenhassen
Copy link
Collaborator

@adambenhassen adambenhassen commented Nov 3, 2025

Description

Adds a escapeSingleQuotes configuration option to ConsiderUsageConfig that allows users to control whether enum change messages single-quotes should be escaped or not. When enabled, enum-related changes messages containing single-quotes will be escaped (e.g., Enum value 'C' was deprecated with reason 'don\'t use this anymore or else!!1').

When disabled or omitted, the default behavior of single quotes is maintained for backward compatibility. The implementation adds a fmt() utility function in utils/string.ts that handles the quote formatting based on the configuration, and updates all enum change message builders to use this utility.

Addresses #2903

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Screenshots/Sandbox:

Current behavior causes this issue, where an example UI fails to discriminate when to labelize single quoted words/messages:
Screenshot 2025-10-30 at 12 04 41

How Has This Been Tested?

  • Added comprehensive unit tests for the fmt() utility function covering all scenarios (default, undefined config, explicit true/false)
  • Added tests for all enum change types with escapeSingleQuotes: true option
  • Verified existing tests pass to ensure backward compatibility
  • Ran pnpm test to verify all tests pass

Checklist:

  • I have followed the CONTRIBUTING doc and the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Further comments

The fmt() utility is designed to be easily extensible to other change types beyond enums if needed in the future. The configuration option is placed in ConsiderUsageConfig to maintain consistency with other diff configuration options.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2025

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-inspector/action 5.0.9-alpha-20251106163027-1170e5ffdb51e87c07ba7290e5ec949460591b5c npm ↗︎ unpkg ↗︎
@graphql-inspector/cli 5.0.9-alpha-20251106163027-1170e5ffdb51e87c07ba7290e5ec949460591b5c npm ↗︎ unpkg ↗︎
@graphql-inspector/audit-command 5.0.9-alpha-20251106163027-1170e5ffdb51e87c07ba7290e5ec949460591b5c npm ↗︎ unpkg ↗︎
@graphql-inspector/coverage-command 6.1.3-alpha-20251106163027-1170e5ffdb51e87c07ba7290e5ec949460591b5c npm ↗︎ unpkg ↗︎
@graphql-inspector/diff-command 5.0.9-alpha-20251106163027-1170e5ffdb51e87c07ba7290e5ec949460591b5c npm ↗︎ unpkg ↗︎
@graphql-inspector/introspect-command 5.0.9-alpha-20251106163027-1170e5ffdb51e87c07ba7290e5ec949460591b5c npm ↗︎ unpkg ↗︎
@graphql-inspector/similar-command 5.0.9-alpha-20251106163027-1170e5ffdb51e87c07ba7290e5ec949460591b5c npm ↗︎ unpkg ↗︎
@graphql-inspector/validate-command 5.0.9-alpha-20251106163027-1170e5ffdb51e87c07ba7290e5ec949460591b5c npm ↗︎ unpkg ↗︎
@graphql-inspector/core 6.3.0-alpha-20251106163027-1170e5ffdb51e87c07ba7290e5ec949460591b5c npm ↗︎ unpkg ↗︎

@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2025

💻 Website Preview

The latest changes are available as preview in: https://pr-2904.graphql-inspector.pages.dev

@n1ru4l
Copy link
Collaborator

n1ru4l commented Nov 4, 2025

It seems to me like we could instead just escape the output of the description in packages/core/src/diff/changes/enum.ts, as we do not want to stylize a deprecation reason anyways.

@adambenhassen adambenhassen force-pushed the adam/1180 branch 2 times, most recently from 893520f to 9740de8 Compare November 4, 2025 12:19
@adambenhassen adambenhassen changed the title feat(core): add useDoubleQuotes option for enum change messages feat(core): add escapeSingleQuotes option for enum change messages Nov 4, 2025
@n1ru4l n1ru4l requested a review from jdolle November 4, 2025 16:10
@adambenhassen adambenhassen force-pushed the adam/1180 branch 3 times, most recently from 4937326 to e50dffa Compare November 4, 2025 16:46
@jdolle
Copy link
Collaborator

jdolle commented Nov 5, 2025

I think it'd be reasonable to escape all descriptions/string values, and not bother with adding a config.
Regardless of us applying special formatting or not -- being able to distinguish these escape characters is important.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants