← 输入框|github.com|刷新
Skip to content

split # comment descriptions on carriage returns in SchemaPrinter - #4511

Merged
bbakerman merged 1 commit into
graphql-java:masterfrom
nab-iha3:hash-comment-description-cr
Oct 26, 2026
Merged

bbakerman merged 1 commit into
graphql-java:masterfrom
nab-iha3:hash-comment-description-cr

Conversation

@nab-iha3

Copy link
Copy Markdown
Contributor

Spock, SchemaPrinter with descriptionsAsHashComments(true) on a type whose description is "x\rtype Injected { a: String }", then re-parsing the printed sdl:

!reparsed.getType("Injected").isPresent()
||        |                   true
||        Optional[ObjectTypeDefinition{name='Injected', ... fieldDefinitions=[FieldDefinition{name='a', ...}]}]

printComments splits the description on \n only before writing each line as a # comment, but the lexer's Comment token also stops at \r (SourceCharacterWithoutLineFeed in GraphqlCommon.g4), so everything after a carriage return is parsed as sdl. The description can come from a \r escape in sdl or from a remote introspection result fed through IntrospectionResultToSchema and SchemaGenerator, so whoever controls a description can add definitions to the printed schema.

The hash comment branch now splits on \r\n, \r and \n. Block string and single line descriptions are unaffected: there the CR stays inside the block string or is escaped by escapeJsonString. The regression test in SchemaPrinterTest fails before the patch.

@github-actions

Copy link
Copy Markdown
Contributor

Test Report

Test Results

Java Version Total Passed Failed Errors Skipped
Java 11 6012 (+1 🟢) 5956 (+1 🟢) 0 (±0) 0 (±0) 56 (±0)
Java 17 6012 (+1 🟢) 5955 (+1 🟢) 0 (±0) 0 (±0) 57 (±0)
Java 21 6012 (+1 🟢) 5955 (+1 🟢) 0 (±0) 0 (±0) 57 (±0)
Java 25 6012 (+1 🟢) 5955 (+1 🟢) 0 (±0) 0 (±0) 57 (±0)
jcstress 32 (±0) 32 (±0) 0 (±0) 0 (±0) 0 (±0)
Total 24080 (+4 🟢) 23853 (+4 🟢) 0 (±0) 0 (±0) 227 (±0)

Code Coverage (Java 25)

Metric Covered Missed Coverage vs Master
Lines 30181 3102 90.7% ±0.0%
Branches 8852 1516 85.4% ±0.0%
Methods 8056 1202 87.0% ±0.0%

Changed Class Coverage (1 class)

Class Line Branch Method
g.s.i.TypeDefinitionRegistry +0.3% 🟢 ±0.0% +1.3% 🟢

Full HTML report: build artifact jacoco-html-report

Updated: 2026-10-25 17:23:29 UTC

@bbakerman bbakerman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks

@bbakerman
bbakerman merged commit 4864a3a into graphql-java:master Oct 26, 2026
10 checks passed
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