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

Support for string literal comments #21

Open
mikevalstar opened this issue Dec 13, 2018 · 8 comments
Open

Support for string literal comments #21

mikevalstar opened this issue Dec 13, 2018 · 8 comments

Comments

@mikevalstar
Copy link

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.

@rmosolgo
Copy link
Owner

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.

@brendanfalkowski
Copy link

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.

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.

@rmosolgo
Copy link
Owner

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!

@brendanfalkowski
Copy link

brendanfalkowski commented Jan 21, 2019

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.

graphql/graphql-js#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: " \""
    }
  }
}

@pthrasher
Copy link

@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.

@awilkins
Copy link

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).

@eduardohueso
Copy link

Commas in comments seem to break syntax highlighting after the comma.

@shellscape
Copy link

shellscape commented Feb 6, 2020

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.

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

No branches or pull requests

7 participants