Skip to content

fix: escape full @deprecated reason correctly - #32

Merged
rockneurotiko merged 1 commit into
rockneurotiko:mainfrom
fizzlebert:fix/deprecated-reason
May 6, 2026
Merged

rockneurotiko merged 1 commit into
rockneurotiko:mainfrom
fizzlebert:fix/deprecated-reason

Conversation

@fizzlebert

@fizzlebert fizzlebert commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

Currently if you use the remote schema with a schema that has newlines in the deprecated reason string it crashes. The cause is the render_deprecated/1 function which only escaped \ and " before now it escapes all characters from the graphql spec for StringValue specifically added support for characters \b, \r, \n, \f, \t along with a range of unicode characters from the spec.

If you have feedback eg. want to add a fixture to tests etc or think it's overkill supporting all of them I can change it.

PS, thanks for adding support for downloading remote schemas I was using a mix task calling a js package to do this before and I saw you updated the README saying this library is used in prod

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of special characters and Unicode in GraphQL deprecation reason values.
  • Tests

    • Added comprehensive tests for string escaping validation in GraphQL schema generation.

render_deprecated/1 only escaped `\` and `"` before now it escapes all
characters from the graphql spec for StringValue
@coderabbitai

coderabbitai Bot commented May 6, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f804b809-63a8-4cdf-9d84-4d6fffe02895

📥 Commits

Reviewing files that changed from the base of the PR and between 900365b and 164e9cc.

📒 Files selected for processing (2)
  • lib/graphql_query/schema/remote/introspection.ex
  • test/graphql_query/schema/remote/introspection_test.exs

📝 Walkthrough

Walkthrough

This pull request refactors deprecation string escaping in SDL generation by extracting inline escaping logic into dedicated escape_string_value/1 and escape_codepoint/1 helper functions that implement GraphQL string escaping per specification. Two comprehensive tests verify correct escaping of control characters and the full range of GraphQL StringValue escape sequences.

Changes

Deprecation String Escaping Refactor

Layer / File(s) Summary
Core Implementation
lib/graphql_query/schema/remote/introspection.ex
render_deprecated delegates escaping to new escape_string_value/1 helper; escape_string_value and escape_codepoint privates implement GraphQL-spec string escaping for backslashes, quotes, control characters, and Unicode.
Tests
test/graphql_query/schema/remote/introspection_test.exs
Two new tests validate escaping of control characters (newlines, etc.) and full GraphQL StringValue escape set in deprecation reasons; generated SDL is verified to parse correctly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A string must escape with GraphQL grace,
Quotes and newlines find their place,
Backslashes dance in codepoint land,
Tests ensure the rules are grand,
Escaping logic, clean and fair,
Deprecation reasons everywhere! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and specifically describes the main change: fixing deprecation reason escaping in GraphQL SDL generation, which aligns with the refactoring of deprecation string escaping and addition of proper StringValue escaping per the GraphQL spec.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rockneurotiko rockneurotiko left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better! Thanks for the PR!

Let me review it and test it locally 😄

@rockneurotiko
rockneurotiko merged commit f5ec38f into rockneurotiko:main May 6, 2026
6 checks passed
@rockneurotiko

Copy link
Copy Markdown
Owner

Thanks for the contribution! 🧡

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.

2 participants