Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append newline to printed documents #391

Merged
merged 4 commits into from
Aug 18, 2024
Merged

Append newline to printed documents #391

merged 4 commits into from
Aug 18, 2024

Conversation

Shane32
Copy link
Member

@Shane32 Shane32 commented Aug 18, 2024

I'd like this merged in for v9.4.0 in preparation for GraphQL.NET v8.0. Note: GraphQL.NET v7.x uses the v8 parser.

@Shane32 Shane32 self-assigned this Aug 18, 2024
return VisitAsync(node, context);
await VisitAsync(node, context).ConfigureAwait(false);
if (!context.NewLinePrinted && node is GraphQLDocument)
await writer.WriteLineAsync().ConfigureAwait(false);
Copy link
Member Author

Choose a reason for hiding this comment

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

Changes were made only within PrintAsync and only for printed documents, not for individual nodes being printed, or where VisitAsync was called directly and the context could be examined to determine whether or not a newline had been printed.

@Shane32 Shane32 requested review from gao-artur and sungam3r August 18, 2024 03:51
Comment on lines 140 to 142

extend type Foo @onType No newline at end of file
extend type Foo @onType
Copy link
Member Author

Choose a reason for hiding this comment

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

This PR fixes these issues -- generated documents did not include a terminating newline before.

Copy link
Member

Choose a reason for hiding this comment

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

Hi, Shane! For the last year or two I completely abandoned GraphQL projects and GitHub from the moment of changing my work. Now I slowly read the accumulated mail and watch what has been done during this time. My progress is small and I'm not sure that someday I will catch everything completely. When dependabot has updated the version of the parser in one of my projects, I found that all my tests failed. It brought me here. Why do you generally call it an issue? I did not specifically add a new line at the end of the document. Are you faced with a specific problem like the impossibility of a correct search using grep? Honestly, I myself 50/50 about newline usage. I just want to feel good, knowing that there is a good reason why it is better to have newline than without it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hard to explain; perhaps it’s personal preference. First it just aggravates me to see GitHub warning stating no newline at the end of the file. Second, in other file types, it’s much easier with a terminating newline to copy and paste code when you’re copying full lines that end with a newline. For example you can’t paste code at the end of a file if there’s no newline. Finally, the lack of a terminating newline (not specifically here) causes “problems” with my tests when I want to concatenate the output with additional data. So all of my tests concatenate a newline before ShouldMatchApproved, which this PR eliminated.

Copy link
Member

Choose a reason for hiding this comment

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

Well, OK but I'm still 50/50 here. I updated my tests with trailing new line.

Copy link

codecov bot commented Aug 18, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 96.10%. Comparing base (b201d09) to head (10315dd).

Files Patch % Lines
src/GraphQLParser/Visitors/SDLPrinter.cs 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #391      +/-   ##
==========================================
- Coverage   96.12%   96.10%   -0.02%     
==========================================
  Files          89       89              
  Lines        5030     5032       +2     
  Branches      500      500              
==========================================
+ Hits         4835     4836       +1     
  Misses        194      194              
- Partials        1        2       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Shane32 Shane32 merged commit a440946 into master Aug 18, 2024
6 checks passed
@Shane32 Shane32 deleted the appendnewline branch August 18, 2024 04:21
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