fix: cli schema minification resulting in invalid sdl#7707
Conversation
Summary of ChangesHello @n1ru4l, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request rectifies a critical bug within the CLI's schema minification utility, which was inadvertently generating malformed Schema Definition Language (SDL). The core of the solution involves simplifying the minification algorithm to ensure that only whitespace is consistently processed, thereby guaranteeing the integrity and validity of the output schema. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
The PR simplifies the minifySchema function but introduces a regression by mangling whitespace within GraphQL descriptions and string literals. This destroys formatting in multi-line descriptions (such as Markdown lists) and can alter the values of string arguments, which contradicts the goal of preserving schema semantics during minification. It also reverts a fix introduced in version 0.58.1.
| return ' '; | ||
| }) | ||
| .trim(); | ||
| return schema.replace(/\s+/g, ' ').trim(); |
There was a problem hiding this comment.
This change mangles GraphQL descriptions and string literals by replacing internal whitespace with a single space. This breaks Markdown formatting in multi-line descriptions (e.g., lists or paragraphs in """ blocks) and alters the values of string arguments or default values.
Minification must preserve the content of string literals. The previous implementation's approach of identifying and skipping string blocks should be maintained and improved (e.g., to handle escaped quotes) rather than replaced with a destructive global whitespace replacement.
return schema
.replace(/(?:("""[\s\S]*?"""|"(?:\\.|[^"])*")|#[^\r\n]*|\s+)/g, (match, group1) => {
if (group1) return group1;
return ' ';
})
.trim();|
🐋 This PR was built and pushed to the following Docker images: Targets: Platforms: Image Tag: |
💻 Website PreviewThe latest changes are available as preview in: https://pr-7707.hive-landing-page.pages.dev |
No description provided.