JetBrains / js-graphql-intellij-plugin

GraphQL language support for WebStorm, IntelliJ IDEA and other IDEs based on the IntelliJ Platform.
https://jimkyndemeyer.github.io/js-graphql-intellij-plugin/
MIT License
879 stars 97 forks source link

Support for """ comments before a query #625

Closed TheNavigateur closed 1 year ago

TheNavigateur commented 1 year ago

Thank you for this plugin!

I am wondering if there can be support for "documentation comments" as per https://dgraph.io/docs/graphql/schema/documentation/#schema-documentation-processed--by-generated-api

When I use them, they build OK and insert the comments into the generated class's JavaDoc, but the parsing describes and error and subsequent syntax highling fails:

When inserting a """ comment before a query, such as:

"""
    My doc comment
"""
query ...

I get the following error message at end of the last """: directive, enum, input, interface, scalar, schema, type or union expected, got 'query'. There is no syntax highlighting after this error in the GraphQL file.

Normal comments with # work fine but they don't get inserted into the generated class's JavaDoc.

Operation system: Windows 10 IDE name and version: Android Studio Dolphin | 2021.3.1 Plugin version: 3.3.0

vepanimas commented 1 year ago

Hi @TheNavigateur! Documentation strings for operations are not supported in GraphQL. https://spec.graphql.org/October2021/#sec-Descriptions https://spec.graphql.org/October2021/#sec-Language.Operations

For example, if you try to reformat that snippet with the GraphQL plugin for Prettier, you'll get the following exception:

"""
    Comment
"""
query {
    node {
        id
    }
}
Syntax Error: Unexpected Name "query". (4:1)
  2 |     Comment
  3 | """
> 4 | query {
    | ^
  5 |     node {
  6 |         id
  7 |     }
SyntaxError: Syntax Error: Unexpected Name "query". (4:1)
  2 |     Comment
  3 | """
> 4 | query {
    | ^
  5 |     node {
  6 |         id
  7 |     }