js-graphql-intellij-plugin
js-graphql-intellij-plugin copied to clipboard
Fragments are not recognised inside strings with injected GraphQL language in some cases
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
I've just run into this problem after adding GraphQL support for my .NET package ShopifySharp. Using Rider, fragments aren't recognized inside strings that use .NET's StringSyntaxAttribute, nor does adding the //lang=graphql comment work.
Version and Environment Details IDE name and version: JetBrains Rider 2024.3.5 Plugin version: 243.24978.46
I'm hit by this, too. Using F# with StringSyntaxAttribute to trigger language injection. I also get the error if I use Rider's "Edit GraphQL fragment" feature on the injected string.
Having the same issue in Rider 2025.2.3, plugin version 252.25557.23. Can't seem to suppress the error either.