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

Fragments are not recognised inside strings with injected GraphQL language in some cases #674

Open arlampin opened 1 year ago

arlampin commented 1 year ago

Describe the bug Fragments are not recognised inside strings with injected GraphQL language in some cases.

To Reproduce Using the following text block in TS file

`
    query {
      me {
        ...AuthFragment
      }
    }

    fragment AuthFragment on User {
      email
    }
`;

and then from context actions selecting "Inject language" -> GraphQL.

Everything should be valid, but ...AuthFragment is highlighted with Unknown fragment spread "AuthFragment".

Adding explicit

// language=GraphQL

to the top fixes the issue.

  // language=GraphQL
`
    query {
      me {
        ...AuthFragment
      }
    }

    fragment AuthFragment on User {
      email
    }
`;

The same thing happens in Java files, but there adding language=GraphQL or org.intellij.lang.annotations.Language("GraphQL") annotation doesn't fix the issue.

Expected behavior Valid GraphQL queries should not be marked with errors

Version and Environment Details IDE name and version: IntelliJ IDEA 2023.1.2 (Ultimate Edition) Plugin version: 4.0.1