language-graphql
language-graphql copied to clipboard
Support for string literal comments
as of graphql 0.12.3 you can now add comments as string literals
"This is a description."
schema {
query: Query
}
if we could highlight this somehow, maybe even as comments. note: they can be multi line.
Hi! these should be fixed and highlighted like normal strings in 1.0.0 . please share a screenshot if you run into any more trouble.
Semi-related, but I used CMD + /
to comment some lines in my schema, which inserted #
.
It took me about 5 hours to figure out my JSON kept breaking because those aren't parsed as comments anymore, but the syntax highlighting made it seem that way.
I tried tracing the logic for this through here, and it seems this is not coming back from being a non-default feature flag in the parser.
- https://github.com/graphql/graphql-js/pull/927
- https://github.com/facebook/graphql/pull/90
Might be a good idea to disable that in the Atom language because it's pretty confusing to have what look like comments become the bug.
Wow, so you can't even have non-description comments in the SDL? Interesting 😖
Atom lets you tell it how comments work: https://github.com/rmosolgo/language-graphql/blob/master/settings/language-graphql.json#L4 But if # ...
is invalid in the SDL, I'm not sure what to put there!
I could be totally wrong because I'm more "1 in 1000 depedencies" than "this is my baby" relative to GraphQL, but based on this it seems string literal "comment here"
fully replaced # comment here
.
https://github.com/graphql/graphql-js/issues/1245
I'm not an Atom extension expert either — hey, I can name most dinosaurs — but maybe change this:
{
".source.graphql": {
"editor": {
"commentStart": "# "
}
}
}
To this?
{
".source.graphql": {
"editor": {
"commentStart": "\" ",
"commentEnd: " \""
}
}
}
@rmosolgo It appears the current docstring syntax requires that every field definition be followed by a comma. That's not required in the spec, and newlines are valid. As such, my current schema sdl files don't use commas for field definitions and that breaks the syntax highlighting when using doc strings.
Changing line 109 of graphql.json
to
"end": "(?=\\s*(([_A-Za-z][_0-9A-Za-z]*)\\s*(\\(|:)|(})))|\\s*(,|\\n)",
Highlights properly for me (no idea if this gets the scopes right, but not sure they were being used for anything meaningful).
Commas in comments seem to break syntax highlighting after the comma.
Not sure how to report properly on this, but I'm using the gql
tagged template literal and no highlighting is being performed. Here's a snippet that's affected:
const typeDefs = gql`
"""
String input format MM-DD-YYYY
"""
scalar DateInput
input DateRangeInput {
start: DateInput
end: DateInput
}`;
The gql
tagged template literal is available as an export in just about every top-level apollo package, so it's pretty widely used.