Skip to content

Add method to AstPrinter to allow supplying Appendable #3853

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

Merged
merged 1 commit into from
Mar 23, 2025

Conversation

kilink
Copy link
Contributor

@kilink kilink commented Mar 18, 2025

Add printAstTo to AstPrinter, which allows the caller to supply their own target Appendable. This can be useful for reusing StringBuilders for instance.

@@ -1,9 +1,11 @@
package graphql.language;

import com.google.common.io.CharStreams;
Copy link
Member

Choose a reason for hiding this comment

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

Note: we only shade in selected classes of Guava, before merging in this PR the Gradle config should be changed to shade in this new class

Copy link
Member

Choose a reason for hiding this comment

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

Our copy the code in -

Hmmm com.google.common.io.AppendableWriter is kinda large.

But we dont really want the wholecom.google.common.io classes in here - just some select ones say

Can we tighten this down some how in shadow jar config ??

Copy link
Member

Choose a reason for hiding this comment

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

 relocate('com.google.common', 'graphql.com.google.common') {
        include 'com.google.common.collect.*'
        include 'com.google.common.base.*'
        include 'com.google.common.math.*'
        include 'com.google.common.primitives.*'
    }

is what we have today - I wonder if we can do specific classes say rather than all of common.io

Copy link
Member

Choose a reason for hiding this comment

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

Thanks @kilink for updating the PR to use a non-Guava alternative, that's a great idea

@dondonz dondonz added this to the 23.x breaking changes milestone Mar 20, 2025
Add printAstTo to AstPrinter, which allows the caller to supply their own
target Appendable. This can be useful for reusing StringBuilders for instance.
@bbakerman bbakerman merged commit c46c07a into graphql-java:master Mar 23, 2025
1 check passed
Copy link
Member

@andimarek andimarek left a comment

Choose a reason for hiding this comment

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

See my comment

@@ -757,8 +781,11 @@ public static String printAst(Node node) {
*/
public static void printAst(Writer writer, Node node) {
String ast = printAst(node);
PrintWriter printer = new PrintWriter(writer);
printer.write(ast);
try {
Copy link
Member

Choose a reason for hiding this comment

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

@kilink @bbakerman @dondonz why did we change that? What is the consequence of that?

Copy link
Member

Choose a reason for hiding this comment

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

PrintWriter never throws an exception but just drops data.

This is better really. Change in behavior yes... but much better behavior

Copy link
Member

Choose a reason for hiding this comment

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

Is that a breaking change needs to be documented?

Copy link
Member

Choose a reason for hiding this comment

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

We can call out that it's a change in the release notes, I can add the label

@dondonz dondonz added the breaking change requires a new major version to be relased label Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change requires a new major version to be relased
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants