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

Help: Unknown type "ID" #651

Closed angelica-snowit closed 1 year ago

angelica-snowit commented 1 year ago

I cant't find a way for the plugin recognize standard scalars, like ID or String. I keep getting Error:(1, 33) Unknown type "ID" All the custom types works well.

I've a basic configuration:

{
  "name": "GraphQL Schema",
  "schemaPath": "./src/GraphQL/schema.json"
}

The local schema file is generated by GraphQL Code Generator.

vepanimas commented 1 year ago

Hi @angelica-snowit! Sorry for the late reply. If it's still an issue for you, please follow the instructions here https://github.com/JetBrains/js-graphql-intellij-plugin/issues/438#issuecomment-1518797152.

It's also worth trying to update your installed GraphQL plugin to the latest version 4.0.0.

angelica-snowit commented 1 year ago

Updated this morning. Wonderful: now not only ID and other scalars are not recognized, everything is marked as error. The schema appears to be empty, no matter how many time I clear cache and restart.

vepanimas commented 1 year ago

@angelica-snowit I'm sorry to hear that 😞. Have you checked the logs? Is there anything related to GraphQL there?

If you're using a schema in JSON format, you may try converting it into GraphQL to see if it helps. The easiest way to do this is by following the instructions in the screenshot below. Don't forget to change the schemaPath parameter to point to the newly created file.

image

angelica-snowit commented 1 year ago

Yes, I've already tried graphql schema (both generated that the same created by the plugin using the remote url), same result :( Also checked the logs, nothing.

vepanimas commented 1 year ago

@angelica-snowit Okay, that seems very strange. We have some issues, but in your case, it doesn't work at all despite any efforts to fix it.

We had some weird cases when it could behave that way:

  1. Make sure that neither the directory containing the configuration file nor the directory containing the schema are marked as excluded in the IDE. This may not be applicable to you, but it's still worth mentioning.

  2. Do you use a .graphqlconfig? We had an old issue related to it when a file association was broken by the IDE, so a plugin couldn't grab a config at all. Probably, the best thing you can do here to ensure that it's not the reason is to create a graphql.config.yml with

    schema: ./src/GraphQL/schema.json

    Note, that it will work only in 4.0.0 plugin version.

  3. A similar issue with file associations could happen with GraphQL files. Please, ensure, that when you create a query.graphql file, it's recognized by the IDE and has a correct icon, it shouldn't be just a plain text file.

  4. Which IDE do you use? For example, in Rider, it's possible that some files are excluded from indexing due to the C# project model.

  5. Regarding an issue with unresolved built-in types. Do you have that file in external libraries?

image

angelica-snowit commented 1 year ago

Than you for the follow-up. I've already tried all this:

  1. The directory is not excluded
  2. I used a .graphqlconfig but I switched to the .yml after upgrading. I've also tried all the other file names in the docs :D btw, the config file should not be a problem because the plugin seems configurated correctly, with endpoints etc.
  3. Files are recognized as graphql (or I wouldn't have seen that initial alert about the scalar type)
  4. I use PhpStorm 2023.1
  5. I had also checked already the specification, is there where it should be
vepanimas commented 1 year ago

Maybe it's related to the schema itself then? Could you share a schema file (probably not, but I couldn't resist asking)? Have you tried providing some simple types as SDL definitions instead of using your current schema? Like:

type User {
  id: Int
}

type Query {
  user: User
}
cstephens-cni commented 9 months ago

I'm having a similar issue, if not the same issue.

Screenshot 2023-09-26 at 11 06 33 AM

I used your simple schema

cstephens-cni commented 9 months ago

I found my issue, I had to add my root directory as the project root, so it was an .idea issue in this project. I'm the only one using webstorm so I typically gitignore the idea file....I may change that practice.