-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Support comments in schema #3133
Conversation
This adds comment detection to lexer. A comment starts with # and ends with new line or EOF. When new line is detected, it's emitted so the caller can handle it. If EOF is found, that should end further parsing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on @srfrog)
schema/state.go, line 111 at r1 (raw file):
// lexComment lexes a comment text. func lexComment(l *lex.Lexer) lex.StateFn {
There's another func like this in gql/state.go. Can you move that func within lex pkg, and use that in both places?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on @manishrjain)
schema/state.go, line 111 at r1 (raw file):
Previously, manishrjain (Manish R Jain) wrote…
There's another func like this in gql/state.go. Can you move that func within lex pkg, and use that in both places?
They are named the same but don't work the same. This one is specific to schema lexText
function and needs newlines emitted. I will rename this one to lexTextComment
to remove ambiguity.
Package gql has another function called lexComment that works slightly different to this one, so I renamed this one to avoid confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking care of this quickly.
Reviewed 2 of 3 files at r1, 1 of 1 files at r2.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @manishrjain)
* schema/state.go: add comment state to lexer This adds comment detection to lexer. A comment starts with # and ends with new line or EOF. When new line is detected, it's emitted so the caller can handle it. If EOF is found, that should end further parsing. * schema/parse_test.go: add test for comments in schema types * gql/parser.go: fixed typo * schema/state.go: rename func lexComment to lexTextComment Package gql has another function called lexComment that works slightly different to this one, so I renamed this one to avoid confusion.
This PR adds support for comments in schemas. Comments begin with
#
and end with new line or when EOF is reached. A schema with only comments is treated as a no-op.Example:
Example with type system:
Closes #3130
This change is