js-graphql-intellij-plugin icon indicating copy to clipboard operation
js-graphql-intellij-plugin copied to clipboard

Plugin recently stopped working, all types erroring

Open jmd01 opened this issue 3 years ago • 34 comments

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

jmd01 avatar Mar 23 '21 09:03 jmd01

@jmd01 hi! Could you please try invalidating caches?

vepanimas avatar Mar 29 '21 13:03 vepanimas

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

tinynumbers avatar Apr 13 '21 16:04 tinynumbers

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

jmd01 avatar Apr 20 '21 08:04 jmd01

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.

cmattick avatar Jun 18 '21 09:06 cmattick

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

stephane303 avatar Sep 29 '21 10:09 stephane303

Should be fixed in the recent 3.1.0 release.

vepanimas avatar Dec 07 '21 15:12 vepanimas

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

TomasMatusek avatar Mar 03 '22 11:03 TomasMatusek

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.

moddx avatar Apr 14 '22 11:04 moddx

I have the same Problem as @TomasMatusek

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

mattes3 avatar May 29 '22 13:05 mattes3

@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

vepanimas avatar May 29 '22 19:05 vepanimas

Sorry, the checkboxes made no difference.

mattes3 avatar May 29 '22 21:05 mattes3

@mattes3 restarting the IDE doesn't help either?

vepanimas avatar May 31 '22 18:05 vepanimas

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 

mmtondreau avatar Jun 19 '22 01:06 mmtondreau

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

tmtron avatar Jun 30 '22 13:06 tmtron

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

angelica-snowit avatar Mar 28 '23 10:03 angelica-snowit

The same problem, all types started error as unknown.

BorysShulyak avatar Apr 20 '23 04:04 BorysShulyak

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

ItaiYosephi avatar Apr 20 '23 14:04 ItaiYosephi

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

DRD161 avatar Apr 22 '23 18:04 DRD161

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 🙏.

vepanimas avatar Apr 22 '23 20:04 vepanimas

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...

RemyMachado avatar Apr 24 '23 12:04 RemyMachado

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.

angelica-snowit avatar Apr 26 '23 07:04 angelica-snowit

My old config had:

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

This got migrated to:

include: '*.graphql'

This didn't work. What worked was:

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

jorrit avatar Apr 26 '23 08:04 jorrit

@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

vepanimas avatar Apr 26 '23 14:04 vepanimas

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.

bosycom avatar Apr 27 '23 12:04 bosycom

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?

energyd avatar Apr 27 '23 21:04 energyd

@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.

vepanimas avatar Apr 27 '23 22:04 vepanimas

@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.

energyd avatar Apr 28 '23 07:04 energyd

@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.

vepanimas avatar Apr 28 '23 13:04 vepanimas

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!

roelofjan-elsinga avatar Jun 14 '23 07:06 roelofjan-elsinga

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.

adamlamaa avatar Jul 19 '23 11:07 adamlamaa