Maintain comments when parsing schema
See original GitHub issuetype GlobalCinemaVenue implements Node @preLoad {
# @todo Refactor into a dynamic set of identifiers, i.e.
"""
https://webediamoviespro.com identifier.
"""
foreignWebediaId: String
}
Currently when using parse, the @todo Refactor into a dynamic set of identifiers, i.e. is not made available in AST. As a result, this data is lost when implementing utilities for formatting SDL, e.g. https://github.com/gajus/sort-graphql-sdl.
It would be nice if there was a way to parse/ print SDL while maintaining comments and descriptions.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Can comments be used in JSON? - Stack Overflow
No. JSON is data-only. If you include a comment, then it must be data too. You could have a designated data element called...
Read more >JSON Comment Example — How to Comment in JSON Files
A way to skirt around the comments issue is to add data to your JSON file that function as comments. Let's go through...
Read more >Comments Within SQL Statements - Oracle Help Center
Comments associated with schema and nonschema objects are stored in the data dictionary. Refer to COMMENT for a description of this form of...
Read more >Using Comments in JSON with Node.js and JavaScript ...
I removed comments from JSON because I saw people were using them to hold parsing directives, a practice which would have destroyed ...
Read more >Disposition of comments for the Efficient Extensible ... - W3C
EXI enables limited typed encoding support in schema-less encoding. ... So, an EXI parser use large memory to keep grammar data, if the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@IvanGoncharov A number of eslint plugins (e.g. eslint-plugin-relay, eslint-plugin-graphql) make use of this parser to parse GraphQL syntax in their lint rules.
One such use case for parsed comments is within GraphQL tagged template literals.
Today, it’s not possible for someone to disable a specific eslint (or other linter) rule in the tagged literal. With parsed comments, we could allow that with:
Obviously, this would not actually be supported in eslint itself. The comment could be prefixed with any arbitrary string. Parsing comments would allow GraphQL lint rule authors to make use of comments in whatever format to skip linting that particular line.
Without parsed comments, the only way today to disable a GraphQL lint rule is by wrapping the entire block with
/* eslint-disable */, which is far too coarse grained as it disables the lint rule for the entire tagged literal.I’ve gone back and forth on whether this needs to be addressed in the GraphQL parser or in eslint. I think that it makes the most sense to parse comments here because it’s a common feature for parsers and clearly needed for other use cases. I also don’t believe this is possible to be reasonably addressed in eslint, because:
TemplateElementnode) is an unstructured string and therefore un-visitable without a third-party, domain specific parserHi @IvanGoncharov 👋 . We use graphql-eslint but are currently unable to disable linting rules because of tooling we have that uses the
parse,visitandprintfunctions fromgraphql, therefore causing the comments to be stripped from the transformed document. Any update on when this might become possible now that we’re in the16.xrange?