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

Export identifiers from queries to the rest of the IDE #616

Open mslenc opened 1 year ago

mslenc commented 1 year ago

Say I have a query and a function like this:

let query = gql`{ viewer { id displayName } }`;

gqlFetch(query).then(data => sayHi(data.viewer));

function sayHi(viewer) {
   alert(`Hello, ${ viewer.displayName }`);
}

IDEA will report a warning "Unresolved variable displayName". It would be (increasingly) super cool if a) the warning didn't happen b) I could Go To Declaration (ctrl-B, ctrl-click) on the displayName and be taken to the query c) when there are multiple declarations of the same identifier (id is the worst obvious case), it would take some context into account and rank the more appropriate declarations higher. For example, viewer.id would put the declaration from the example above first, while client.id would prefer some other query that contains client { id }.

Or should that already happen and my IDE is misconfigured somehow? Kinda surprised that I can't find an existing issue about this.

The warning is fairly annoying in my project, as there are hundreds of plain old data fields that only come from queries, never appearing in any code that would cause the warning to shut up.