Skip to content

Add SchemaPrinter AST comments support #3287

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 6 commits into from
Aug 22, 2023
Merged

Add SchemaPrinter AST comments support #3287

merged 6 commits into from
Aug 22, 2023

Conversation

vadimofd
Copy link
Contributor

@vadimofd vadimofd commented Aug 11, 2023

This PR is related to #3250 discussion. by adding comments support when creating schema programmatically instead of using SDL.

}
}

String comments(java.util.List<graphql.language.Comment> comments) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: import of List

}
}

String comments(java.util.List<graphql.language.Comment> comments) {
Copy link
Member

Choose a reason for hiding this comment

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

private method unless its unit tested

caliber: Int
# gun 'name' input value comment
name: String
}
'''
}
}
Copy link
Member

Choose a reason for hiding this comment

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

graphql.schema.idl.SchemaGenerator.Options#useCommentsAsDescriptions exists so it would be nice to test that we can generate from SDL with comments AND round drip it back out via a schema printer

This may well discover bugs if we have them in the SchemaGenerator

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call! I've added a test for this. Looks like it's not printing comments for directive and scalar. Will take a look at that later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From what I can tell, the schema parser is not capturing directive and scalar comments in getComments - the tokens seem to be ignored. I am not very familiar Antlr and don't see anything different for these two schema elements vs. all the other that seem to work fine. Any ideas?

Copy link
Member

Choose a reason for hiding this comment

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

I dont off hand - what I would do is leave the SDL test in place BUT change the assertion string to leave our directives and scalars. We can circle back to fix SDL scalar comment capture say later but this code can progress in the meantime

Added a review recommended round-trip (parse > generate > print) test.
Copy link
Member

@bbakerman bbakerman left a comment

Choose a reason for hiding this comment

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

This is an excellent contribution - and really well done

Thank you

@bbakerman bbakerman added this to the 2023 October milestone Aug 13, 2023
@vadimofd
Copy link
Contributor Author

This is an excellent contribution - and really well done

Thank you

Very happy to contribute and really appreciate your help!

@vadimofd vadimofd marked this pull request as ready for review August 15, 2023 04:22
@vadimofd vadimofd requested a review from bbakerman August 21, 2023 21:55
Copy link
Member

@bbakerman bbakerman left a comment

Choose a reason for hiding this comment

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

Thanks very much for this

@dondonz
Copy link
Member

dondonz commented Aug 22, 2023

FYI I resolved a merge conflict from another PR that was just merged, which added a test

@dondonz
Copy link
Member

dondonz commented Aug 22, 2023

😄 I tried being clever with the web UI and left an extra bracket... I'll fix it

@dondonz dondonz added this pull request to the merge queue Aug 22, 2023
Merged via the queue into graphql-java:master with commit 3b1736f Aug 22, 2023
@vadimofd
Copy link
Contributor Author

Thank you!

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