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

Comments / Descriptions #116

Closed
alpox opened this issue Feb 24, 2016 · 3 comments
Closed

Comments / Descriptions #116

alpox opened this issue Feb 24, 2016 · 3 comments

Comments

@alpox
Copy link

alpox commented Feb 24, 2016

I am currently working on a module for generating a graphql-go/graphql schema from the type definition of the graphql language on graphql-go-gen.
For doing that i am using the parser from this project which parses the system but doesnt make use of it.
Now I wanted to integrate the descriptions for the types. Other projects like mine make use of the comment tags which are prefixed by a # in graphql but it seems these don't even get parsed in this project? It would be great if you could implement this.
Keep up the good work!

@sogko sogko added this to the 0.4.18 milestone Mar 7, 2016
@chris-ramon
Copy link
Member

Hi @alpox!, thumbs up for graphql-go-gen pretty useful project 👍 & really looking forward to try it out.

In regards graphql/language/parser/parser.go ignoring comments, I think its the expected behavior, the next following points confirms it, which are based on the graphql-js reference implementation:

  • There is not a comment TokenKind listed on the possible tokens.

  • readToken from graphql-js/src/language/lexer.js ignores comments:

    This skips over whitespace and comments until it finds the next lexable token ...

    Source: https://github.com/graphql/graphql-js/blob/master/src/language/lexer.js#L139

  • There is a test for graphql-js/src/language/lexer.js which effectively includes comments on the query and they are ignored by the lexer & parser.

One workaround would be to copy lexer & parser and include those to graphql-go-gen, then extend their functionality to not ignore comments, perhaps starting from func positionAfterWhitespace(body string, startPosition int) int { ... }, similar to github.com/ForbesLindesay/graphql-schema-gen strategy.

Keep it up the great work!

@alpox
Copy link
Author

alpox commented Mar 16, 2016

Thanks @chris-ramon for your response. I will try to do like you suggested. It could take me a while to finish since i'm quite busy these days and i'm not familiar with compilers 😃 I'll try my best!

@chris-ramon
Copy link
Member

Alright @alpox, take it easy, keep up the great work and feel free to re-open the issue as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants