Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin recently stopped working, all types erroring #438

Open
jmd01 opened this issue Mar 23, 2021 · 34 comments
Open

Plugin recently stopped working, all types erroring #438

jmd01 opened this issue Mar 23, 2021 · 34 comments

Comments

@jmd01
Copy link

jmd01 commented Mar 23, 2021

Describe the bug
Recently all types started error as unknown, however the schema discovery works fine and reports no errors, and the suggested fix pop-up is able to find the types.

Eg
"Unknown field "fieldId" on object type "TriggerCriteriaCheckCustomFieldToggle". Did you mean "fieldId"?

Expected behavior
Clearly it can still see the types as it is suggesting the same type as the fix, so it should not report types as unknown.

Screenshots
This is just one file but it is happening in all graphql files:
Screenshot 2021-03-23 at 09 56 08

Version and Environment Details
Operation system: macOS Version 10.15.7
IDE name and version: PHPStorm 2020.3.3
Plugin version: 2.9.1

Additional context
It worked fine until recently

@vepanimas
Copy link
Collaborator

@jmd01 hi! Could you please try invalidating caches?

@tinynumbers
Copy link

I recently encountered this same issue and invalidating the caches (and restarting) corrected the problem for me.

@jmd01
Copy link
Author

jmd01 commented Apr 20, 2021

Unfortunately this didn't work for me. It's a large project though, perhaps it's hitting some sort of limit?

@cmattick
Copy link

I managed to solve this via Help > Edit Custom Properties...

I inserted the following lines:

# Maximum file size (kilobytes) IDE should provide code assistance for.
idea.max.intellisense.filesize=10240

Default ist 2500, as soon as my schema file went above this I saw the described problems. Would be better though if the plugin could solve this somehow in another way, at least warn about this explicitely.

@stephane303
Copy link

Yes this really needs to be addressed ,idea.max.intellisense.filesize=10240, fixed it for me

@vepanimas vepanimas pinned this issue Nov 19, 2021
@vepanimas
Copy link
Collaborator

Should be fixed in the recent 3.1.0 release.

@TomasMatusek
Copy link

Same problem here, suddenly code objects linking stopped working, together with queries highlighting. Event basic types are showing error Unknown type "Int".

I tried invalidate cache, restart, reinstall plugin. Also set idea.max.intellisense.filesize as desscribed above but with no success.

IntelliJ IDEA 2021.3.2 (Ultimate Edition)
Build #IU-213.6777.52, built on January 28, 2022
You have a perpetual fallback license for this version.
Subscription is active until January 4, 2023.
Runtime version: 11.0.13+7-b1751.25 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.2.1
GC: G1 Young Generation, G1 Old Generation
Memory: 10096M
Cores: 12
Registry:
debugger.watches.in.variables=false
documentation.show.toolbar=true

Non-Bundled Plugins:
org.jetbrains.kotlin (213-1.6.10-release-961-IJ6777.52)
com.hazelcast.idea.plugins.tools (1.1)
GrepConsole (12.7.211.6693.1)
io.snyk.snyk-intellij-plugin (2.4.19)
com.intellij.lang.jsgraphql (3.1.2)

Kotlin: 213-1.6.10-release-961-IJ6777.52

image

@moddx
Copy link

moddx commented Apr 14, 2022

I have the same Problem as @TomasMatusek

Basic scalars are not recognized
image

Nor Discovered
image

If I define the scalars explicitly, it works.

IntelliJ IDEA 2021.3.3 (Ultimate Edition)
Build #IU-213.7172.25, built on March 15, 2022
Runtime version: 11.0.14.1+1-b1751.46 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

@mattes3
Copy link

mattes3 commented May 29, 2022

I have the same Problem as @TomasMatusek

All basic types like Int, String, etc. are marked as errors (with red text color).

@vepanimas
Copy link
Collaborator

@mattes3 hi, could you please enable one of these checkboxes and then apply settings? It can be related to some changes in that area.
Relay

@mattes3
Copy link

mattes3 commented May 29, 2022

Sorry, the checkboxes made no difference.

@vepanimas
Copy link
Collaborator

@mattes3 restarting the IDE doesn't help either?

@mmtondreau
Copy link

Having the same issue same issue. Have tried restart, invalidating cache, uninstall-reinstall, all to no avail. I did notice the following warning in the idea.log:

2022-06-18 17:17:51,826 [   3503]   WARN - s.impl.EditorColorsManagerImpl - Cannot find scheme: Monokai from plugins: com.intellij.lang.jsgraphql 

@tmtron
Copy link

tmtron commented Jun 30, 2022

In my case the basic types still work, but scalars, etc. do not:

image

What I have tried, and did not work:

  • renaming the schema file from schema.gql to schema.graphql
  • setting ,idea.max.intellisense.filesize=10240
  • invalidate/caches / restart

Found the issue:

  • another plugin has marked the directory where my schema file is stored as Excluded.
  • Fix is to right-click on the directory in Project view and select Mark Directory as... - Cancel exclusion

@angelica-snowit
Copy link

angelica-snowit commented Mar 28, 2023

I have the same problem: "Error:(1, 21) Unknown type "ID""
Someone has resolved?

@BorysShulyak
Copy link

The same problem, all types started error as unknown.

@ItaiYosephi
Copy link

ItaiYosephi commented Apr 20, 2023

Also having the this same issue since the last version.
My Webstorm workspace contains multiple project roots, and all files outside the folder that contains the config file have this issue.
For now I had to downgrade to version 3.4.0

@DRD161
Copy link

DRD161 commented Apr 22, 2023

Having the same issue unfortunately with version 4.0 of the plugin. Tried downgrading to version 3.4 but I'm still getting the error. Unknown field "id": The parent selection or operation does not resolve to a valid schema type

@vepanimas
Copy link
Collaborator

There are many possible reasons why such errors could occur 😞. If you encounter issues after updating to version 4.0.0, please refer to the new docs on plugin configuration.

If it didn't help, the first thing to do is to run "invalidate caches and restart" (how to).

Then, if you have any unresolved built-in types, please check that you can see a Specification.graphql file in the External libraries section of the project view:

built-in-types

Next, open the logs and search for anything containing "GraphQL". If you find something suspicious, it might be a clue. You can open the location of the logs directory using the corresponding Help menu action: Show Log in Explorer on Windows or Show Log in Finder on macOS.

Regarding your case, @ItaiYosephi, the plugin will fall back to the global scope if you don't have any configurations. However, when you have at least one GraphQL configuration file in the project, as you do, it is necessary to configure all scopes correctly. A GraphQL configuration file defines a "module root", and all files under it will be matched against it. Files without such configuration will use a local scope, not a global one. This is done to prevent weird issues like "duplicate type" errors and make scope handling strict and explicit. For example, both a GraphQL Language Service and a VSCode extension based on it requires you to have a configuration file.

The simplest fix you can apply is to create an empty GraphQL config in the root of the monorepo. This way, all files under this directory will use it as a scope, except the nested projects that have their specific configs. I understand that it could be inconvenient, but we also have a long history of issues caused by implicitly included files in the scope, which have led to very confusing errors.

If anyone has problems with a new configuration file format or with the migration of .graphqlconfig, I am willing to help on a case-by-case basis. Feel free to open a new issue or simply ask a question here. Just please provide detailed information about your project structure and the desired configuration to make it easier 🙏.

@RemyMachado
Copy link

RemyMachado commented Apr 24, 2023

Same problem here since upgrading to V4.
I downgraded to version (3.4.0 eap) and it's working again. Thanks @ItaiYosephi
I'm relieved


If you are wondering how to downgrade the plugin, here's the simple steps:

  • uninstall the plugin
  • download the downgraded version, here
  • in your IDE, use install Plugin from disk...

@angelica-snowit
Copy link

angelica-snowit commented Apr 26, 2023

I was expericing a problem with scalars like ID and String. I followed the suggestion to update the plugin, now everything is marked as error, the schema always says is empty, even the one generated by the introspection of the plugin itself.
The only thing that seems working right is just removing this plugin.

@jorrit
Copy link

jorrit commented Apr 26, 2023

My old config had:

"includes": ["*.graphql"],

This got migrated to:

include: '*.graphql'

This didn't work. What worked was:

include: './**/*.graphql'

@vepanimas
Copy link
Collaborator

@jorrit include: '*.graphql' matches only the files in the same directory, it should work the same way as in the graphql-config. As you mentioned, something like include: './**/*.graphql' or just include: '**/*.graphql' will achieve the desired result.

Please, note that in the v3 config, you can use a schema key for that instead of include if you don't need a more complicated setup:

schema: 
  - schema.graphql # specific file
  - src/schemas/**/*.graphql # all files inside src/schemas recursively
  - lib/*.graphql # all files inside lib directory only
documents: '**/*.graphql' # documents from every graphql file, but only documents, not type definitions (SDLs)

ATTENTION: All SDLs must now be explicitly configured in the configuration file. The plugin will no longer implicitly grab them. Therefore, files containing SDLs must explicitly match either schema or include (schemaPath or includes in legacy config). https://github.com/JetBrains/js-graphql-intellij-plugin#legacy-configuration

@bosycom
Copy link

bosycom commented Apr 27, 2023

For me it worked like this: I opened the old file <project-root>/graphqlconfig

{
  "name": "My project GraphQL Schema",
  "schemaPath": "schema.graphql",
  "extensions": {
    "endpoints": {
      "Default GraphQL Endpoint": {
        "url": "http://localhost:3333/graphql",
        "headers": {
          "user-agent": "JS GraphQL"
        },
        "introspect": false
      }
    }
  }
}

Then a Jetbrains bar at the top was offering to migrate the file which changed the filename to <project-root>/graphql.config.yml with this content:

schema: schema.graphql
extensions:
  endpoints:
    Default GraphQL Endpoint:
      url: http://localhost:3333/graphql
      headers:
        user-agent: JS GraphQL
      introspect: false

Finally, I simply had to change the first line from schema: schema.graphql to schema: schema.gql, because that's how my ApolloDriver setup generates it. I hope that helps.

@energyd
Copy link

energyd commented Apr 27, 2023

Same, I have to downgrade to version 3.4.0 to get it back working. That's a bummer :(

ATTENTION: All SDLs must now be explicitly configured in the configuration file. The plugin will no longer implicitly grab them. Therefore, files containing SDLs must explicitly match either schema or include (schemaPath or includes in legacy config).

Is it possible bring back the old behavior of implicitly grabbing the SDLs?

@vepanimas
Copy link
Collaborator

@energyd what's the point of configuring a plugin if it ignores a configuration 🤔? Look at the case above, it worked with an obviously incorrect configuration with a path to a missing schema file. And we had a lot of issues when people tried to configure a slightly more complex project, but instead, got a lot of errors with "duplicated types" because of the implicit inclusion of parts that shouldn't be included.

I really don't get the point here. This simple graphql.config.yml

schema: '**/*.graphql'

will build a schema from all GraphQL files you have. It's predictable and gives full control over what's going on with schema discovery.

The same approach applies to graphql-config and the GraphQL language server, you must specify paths to all schema parts. This plugin should also conform to that behavior to be interoperable with other editors and IDEs. Additionally, the legacy .graphqlconfig has been deprecated for a long time, so we need to do this now or later.

I spent a tremendous amount of time trying to support the modern config, and all its features and make it backward-compatible to at least some extent, it was a complete rewrite. Of course, I could break something or miss some use cases, there could be bugs and I've already fixed some of them. So, it would be great if we could find a solution together. I'm ready to fix any issues, help with configuration, and investigate what goes wrong, but I can't just "revert" something.

@energyd
Copy link

energyd commented Apr 28, 2023

@vepanimas thanks for the reply.

I just want to say that the previous version actually perform above and beyond my expectation. I didn't have to "configure" anything and it just worked(this is amazing because we have hundreds of graphQL schema/fragments scattered all over the place). I really didn't know anything about what happened behind the scenes (I don't even know that there is a configuration file). The new update that broke what was working before led me here to this thread.

I'm really new to GraphQL and I don't understand a lot of the context you've given here. But as a programmer myself I know how hard it is to make a product that satisfy everyone. There is no silver bullet that solves all problem. I think I am really not in a good position to make any suggestion to this project. My apologies. I'm happy to learn how to configure the plugin if that's the only path going forward.

@vepanimas
Copy link
Collaborator

@energyd

I didn't have to "configure" anything

That's weird, if you don't have any configuration settings and it stopped working, it could be a bug. Without any GraphQL configuration, it should work in the global scope, which includes every GraphQL file in your project.

Also, if you have a configuration, but it's empty or contains only the extensions property with API endpoints, it should also include every possible GraphQL file under containing directory. Here's an example of such a configuration:

extensions:
  endpoints:
    dev: https://example.com/graphql

You may still have some schemaPath or similar configuration in your code that was overlooked before. Then it works as expected, reading a schema from schemaPath. If you had a more complicated setup, then it was recommended to use includes for that even before the recent update:

{
  "name": "Relay GraphQL Schema",
  "schemaPath": "relay-schema.graphql",
  "includes": ["components/**"]
}

The point of the latest update is quite straightforward: configurations should be explicit, correct, and function consistently across different editors. However, if you don't have any configuration and your project is simple, it should work out of the box without any additional steps.

@roelofjan-elsinga
Copy link

I've got a set-up where all types are in separate files, and @vepanimas's suggestion in the previous comment solved the problem for me (<root>/graphql.config.yml):

Old:

schema: schemas/schema.graphqls

New:

schema: schemas/schema.graphqls
include: ["schemas/**"]

Hope this helps others!

@adamlamaa
Copy link

Sharing to help debug for others.

I upgraded to Webstorm 2023.1.4 and Graphql plugin 4.0.1.

This resulted in my schema.graphql.ts file, giving warnings on all types like below:
image

Looking at @roelofjan-elsinga comment I changed my graphql.config.yml from

schema: http://localhost:8000/api/graphql
documents:
  - "src/**/*.graphql"
  - "api-src/src/**/*.graphql"

to

schema: schema.graphql.ts
documents:
  - "src/**/*.graphql"
  - "api-src/src/**/*.graphql"

This solved the issue for me.

@hopefull12
Copy link

hopefull12 commented Jul 29, 2023

Hi Guys, In my case all the basic types (ID, String, Boolean....) are showing as errors. I tried invalidating the cache, reinstalling the plugin, restarting, and upgrading to the latest IntelliJ as well.

For some of my teammates, it works, and not sure what is different in my case.

Any help on how to resolve this will be greatly appreciated.

IntelliJ IDEA 2023.2 (Ultimate Edition)
Build #IU-232.8660.185, built on July 26, 2023
Expiration date: July 31, 2023
Runtime version: 17.0.7+7-b1000.6 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 13.2.1
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 10
Metal Rendering is ON
Non-Bundled Plugins:
google-java-format (1.15.0.0)
com.intellij.lang.jsgraphql (4.0.2)
org.intellij.scala (2023.2.17)
Kotlin: 232-1.9.0-IJ8660.185

image

@SergioFaya
Copy link

After trying all of the above I think I fixed it for good. I have autocomplete, String and all types in between working.

The steps I have identified for fixing it are:

  • having the schema stored as .graphql and the queries as .gql.
  • The most important step was to associate the .graphql file to the GraphQl language in IntelliJ. For some reason wasn't picking it up properly and right after adding it worked as a charm. (This can be done selecting the file)
  • Last I tried with several configs and this seems to work and to replace the need of annoying caches (just add the file to .gitingore and off you go)

Here is the config

schema: src/main/resources/local.graphql
documents:
    - "src/main/resources/templates/**/*.graphql"
    - "src/main/resources/templates/**/*.gql"
extensions:
    endpoints:
        url: https://url/graphql
        headers:
          Authorization: Bearer xyz
          Content-Type: "application/json"
          Accept: "*/*"

hope this helps you fixing it and to reproduce the scenario 👋

@onyshchuk
Copy link

onyshchuk commented Sep 15, 2023

nothing helps, the autocomplete just not working, interesting that config is working and I am receiving schema.graphql file from end point.

{
  "name": "Untitled GraphQL Schema",
  "schemaPath": "schema.graphql",
  "extensions": {
    "endpoints": {
      "Default GraphQL Endpoint": {
        "url": "https://graphql-ling-placeholder",
        "headers": {
          "user-agent": "JS GraphQL"
        },
        "introspect": true
      }
    }
  }
}

and my gql file looks like so with all fields => unknown
image

maybe someone can see where I am wrong, cause I am going crazy with this ....

UPDATE: Ok, I finally managed to make it work, thanks to the @SergioFaya , I read his comment once more, the one and only important thing is the 2nd one. What I did:

  • went to settings => editor => file types, removed *.graphql from typescript and add it to the graphql
  • opened my schema.graphql, File => File properties => associate with file type .... and assigned its type to GraphQL.
  • after this my schema becomes typed and didn't show any errors, and all files also had autocomplete etc...

@h3ll3r
Copy link

h3ll3r commented Nov 24, 2023

Hi guys! I was also struggling with the same problem as @TomasMatusek and basic GraphQL types such as String, Int and so on were not recognized by IDE.

The problem in my case was that for some reason IDE was not recognizing some files with .graphql extension as GraphQL files. As you can see on the screenshot the Specification.graphql has an icon of a regular text file:

image

The solution for me was to manually override file type for the Specification.graphql file:

image

Also as suggested by @onyshchuk check your Editor | File types settings and ensure that *.graphql (or other extensions you use for your GraphQL schemes) pattern is present in the File name patterns list for GraphQL.

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests