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 IDEA GraphQL language injections #307

Open MegaJSDeveloper opened 4 years ago

MegaJSDeveloper commented 4 years ago

image version 2.3.0

but in .graphql file works correct image

jimkyndemeyer commented 4 years ago

Hi,

Thanks for using the plugin.

Schema discovery looks for tagged template literals named gql or graphql. This is done for performance reasons to support very large projects.

If you prefer to declare your schema types in a JS file, and don't use frameworks such as Apollo or Relay, you can define your own simple graphql function, in which types are picked up by the plugin, as follows:

function graphql(strings, ...placeholders) {
    return strings[0];
}

const schema = graphql`
    type User {
        name: String
    }

    type Query {
        user: User
    }
`;

Best regards, Jim.

MegaJSDeveloper commented 4 years ago

@jimkyndemeyer Language Injection is a JetBrains feature that does not work correctly with your plugin. I just found the bug. language = LANGNAME is the standard feature of JetBrains to activate Language Injection feature, this is not just my comment, this is a utility syntax construction for Idea engine.

I could do the same by pressing alt + enter and selecting "language injection":

image

the same can be achieved in the IDE by adding a special comment: image

Language Injection is a JetBrains feature that does not work correctly with your plugin. All GraphQL language injections should be parsed by your plugin as separate .graphql files. If the problem is not with your plugin, then report a bug of Language Injection to JetBrains

vepanimas commented 4 years ago

Related #308