graphql / graphiql

GraphiQL & the GraphQL LSP Reference Ecosystem for building browser & IDE tools.
MIT License
16.1k stars 1.72k forks source link

Still some bug with string laterals comments #2336

Open johannpinson opened 6 years ago

johannpinson commented 6 years ago

hey @divyenduz

There are still some problems with string laterals comments, cf. screenshot:

capture d ecran 2018-08-08 a 18 23 52

Since """ for multiline looks goods, it not true for single line comments.

Thanks,

divyenduz commented 6 years ago

@johannpinson : Can you point out the place where the error is? Are you talking about the line after # USER ?

johannpinson commented 6 years ago

@divyenduz Yes for 2 comments: Check if current user has one of required role just after the directive @hasrole and Get the currently logged in user

There is the good "color" expected for a comment:

capture d ecran 2018-08-09 a 14 55 50

Personally, I use # for internal comment into the file and string comment like """ which will be displayed inside GraphQL Playground for example.

divyenduz commented 6 years ago

@johannpinson : Thanks! In the 1st image, the format is "<string>", is that even a valid comment?

To my understanding, comments can be represented via """ or #

johannpinson commented 6 years ago

Hello @divyenduz

Sorry for the delay. You can see in the specs that a comment can be use with single ": https://facebook.github.io/graphql/draft/#sec-Descriptions

johannpinson commented 6 years ago

In fact, in the specs, it's named "description" when we use " and a comment for #

plaa commented 5 years ago

The single-quote descriptions break the coloring completely. String literals is the proper way for documenting fields, so I think it's very important to fix this. The following is very hard to work with:

Screenshot 2019-05-06 at 14 20 53
thebrianbug commented 4 years ago

@divyenduz The later GraphQL specs introduced a new difference between what they call comments and descriptions. Originally, any text like so # a comment here was called a Comment and would show up in the GraphQL introspection docs. This has been changed in later specs with the addition of Descriptions. Descriptions are either wrapped in quotes in a single line or triple quotes for multi line. Comments are now completely ignored by the spec and treated as whitespace. Descriptions are not ignored, they are included in the autogenerated introspection documentation of GraphQL.

Therefore, we should add formatting support for text inside quotes like "A description here" to be the same as a multi-line description block, which is denoted by wrapping it with the triple quotes """

alan-cooney commented 4 years ago

I'm happy to submit a pull request for this, however it should be very straight-forward. Essentially it's this that needs editing:

/vscode-graphql/blob/master/grammars/graphql.json

From this:

  "graphql-description-singleline": {
      "name": "comment.line.number-sign.graphql",
      "match": "#(?=([^\"]*\"[^\"]*\")*[^\"]*$).*$"
  }

To this:

"graphql-description-singleline": {
      "name": "comment.line.number-sign.graphql",
      "match": "\".*\""
}
divyenduz commented 4 years ago

@alan-cooney Thank you, Please submit a pull-request. Do share some images of how the syntax highlighting looks like with the modified grammar.